Skip to content

Commit db30fca

Browse files
committed
refactor: improve ESLint and Prettier configurations
- Updated ESLint commands in package.json to use caching and concurrency for better performance. - Enhanced ESLint rules across various plugins to improve code quality and consistency. - Refactored code formatting in multiple files for better readability and maintainability. - Adjusted TypeScript and JSONC handling in configuration files for improved compatibility.
1 parent 3e1cb7b commit db30fca

39 files changed

+1180
-1182
lines changed

package.json

Lines changed: 134 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,136 @@
11
{
2-
"name": "javascript-style-guide",
3-
"private": true,
4-
"description": "This project is a code style guide of all basic back- and front end project used at Anolilab.",
5-
"keywords": [
6-
"es2015",
7-
"es2018",
8-
"es6",
9-
"anolilab",
10-
"javascript",
11-
"browserslist",
12-
"browserslist-config",
13-
"browsers",
14-
"lint",
15-
"styleguide",
16-
"eslint",
17-
"eslintconfig",
18-
"config",
19-
"es2016",
20-
"es2017",
21-
"es2020",
22-
"css",
23-
"prettier",
24-
"prettier-config",
25-
"semantic-release",
26-
"semantic-release-config",
27-
"changelog",
28-
"publish",
29-
"release",
30-
"npm",
31-
"github",
32-
"git",
33-
"sass",
34-
"scss",
35-
"style",
36-
"stylelint",
37-
"stylelint-config",
38-
"text",
39-
"textlint",
40-
"write-good"
41-
],
42-
"homepage": "https://github.com/anolilab/javascript-style-guide#readme",
43-
"bugs": {
44-
"url": "https://github.com/anolilab/javascript-style-guide/issues"
45-
},
46-
"repository": {
47-
"type": "git",
48-
"url": "git+https://github.com/anolilab/javascript-style-guide.git"
49-
},
50-
"license": "MIT",
51-
"author": "Daniel Bannert <d.bannert@anolilab.de>",
52-
"type": "module",
53-
"workspaces": [
54-
"packages/*"
55-
],
56-
"scripts": {
57-
"audit": "audit-ci --config ./audit-ci.jsonc",
58-
"build:affected:packages": "nx affected --target=build --exclude=*-bench,docs,storybook --nxBail",
59-
"build:affected:prod:packages": "nx affected --target=build:prod --exclude=*-bench,docs,storybook --nxBail",
60-
"build:packages": "nx run-many --target=build --parallel --projects=tag:type:package",
61-
"build:packages:prod": "nx run-many --target=build:prod --parallel --projects=tag:type:package",
62-
"clean": "nx run-many --target=clean && rimraf node_modules",
63-
"preinstall": "node -e \"if(process.env.CI == 'true') {console.info('Skipping preinstall...')} else {process.exit(1)}\" || (node verify-node-version.js && npm -y exec only-allow pnpm)",
64-
"postinstall": "is-ci || husky || exit 0",
65-
"lint": "pnpm run lint:prettier && pnpm run lint:eslint",
66-
"lint:affected:attw": "nx affected --target=lint:attw --parallel --exclude=*-bench,docs,storybook --nxBail",
67-
"lint:affected:eslint": "nx affected --target=lint:eslint --parallel --exclude=*-bench,docs,storybook --nxBail",
68-
"lint:affected:eslint:fix": "nx affected --target=lint:eslint:fix --parallel --exclude=*-bench,docs,storybook --nxBail",
69-
"lint:affected:package-json": "nx affected --target=lint:package-json --parallel --exclude=*-bench,docs,storybook --nxBail",
70-
"lint:affected:types": "nx affected --target=lint:types --parallel --exclude=*-bench,docs,storybook --nxBail",
71-
"lint:attw": "nx run-many --target=lint:attw --all --parallel",
72-
"lint:eslint": "nx run-many --target=lint:eslint --all --parallel",
73-
"lint:eslint:fix": "nx run-many --target=lint:eslint:fix --all --parallel",
74-
"lint:fix": "pnpm run lint:prettier:fix && pnpm run lint:eslint:fix",
75-
"lint:prettier": "nx run-many --target=lint:prettier --all --parallel",
76-
"lint:prettier:fix": "nx run-many --target=lint:prettier:fix --all --parallel",
77-
"lint:secrets": "secretlint **/*",
78-
"lint:staged": "lint-staged --verbose --concurrent false --debug",
79-
"lint:styles": "stylelint",
80-
"lint:text": "textlint ./.github/ ./packages/** ./README.md ./UPGRADE.md --parallel --experimental --cache --dry-run",
81-
"lint:text:fix": "textlint ./.github/ ./packages/** ./README.md ./UPGRADE.md --parallel --experimental --fix",
82-
"lint:types": "nx run-many --target=lint:types --all --parallel",
83-
"sort-package-json": "sort-package-json packages/**/package.json apps/**/package.json ./package.json examples/**/package.json",
84-
"test:affected": "nx affected --target=test --parallel --exclude=*-bench,docs,storybook --nxBail",
85-
"test:affected:coverage": "nx affected --target=test:coverage --parallel --exclude=*-bench,docs,storybook --nxBail",
86-
"test:all": "nx run-many --target=test:coverage --projects=browserslist-config-anolilab,stylelint-config,eslint-config && pnpm test:stylelint",
87-
"test:browserslist-config-anolilab": "pnpm --filter \"browserslist-config-anolilab\" run test",
88-
"test:coverage:browserslist-config-anolilab": "pnpm --filter \"browserslist-config-anolilab\" run test:coverage",
89-
"test:coverage:lint-staged-config": "pnpm --filter \"lint-staged-config\" run test:coverage",
90-
"test:coverage:stylelint-config": "pnpm --filter \"stylelint-config\" run test:coverage",
91-
"test:eslint-config": "pnpm --filter \"eslint-config\" run test",
92-
"test:lint-staged-config": "pnpm --filter \"lint-staged-config\" run test",
93-
"test:stylelint": "node scripts/isNotWindows || stylelint --formatter verbose --config packages/stylelint-config/index.mjs ./packages/stylelint-config/__tests__/css/**/*.css",
94-
"test:stylelint-config": "pnpm --filter \"stylelint-config\" run test",
95-
"update:deps": "taze"
96-
},
97-
"dependencies": {
98-
"@anolilab/multi-semantic-release": "catalog:cli",
99-
"@commitlint/cli": "catalog:lint",
100-
"@commitlint/config-conventional": "catalog:lint",
101-
"@commitlint/core": "catalog:lint",
102-
"@secretlint/secretlint-rule-preset-recommend": "catalog:lint",
103-
"@tsconfig/node16": "catalog:tsc",
104-
"@tsconfig/strictest": "catalog:tsc",
105-
"@types/node": "catalog:types",
106-
"@vitest/coverage-v8": "catalog:test",
107-
"audit-ci": "catalog:prod",
108-
"commitizen": "catalog:cli",
109-
"conventional-changelog-conventionalcommits": "catalog:prod",
110-
"cross-env": "catalog:node",
111-
"cz-conventional-changelog": "catalog:prod",
112-
"eslint": "catalog:lint",
113-
"husky": "catalog:lint",
114-
"is-ci": "catalog:prod",
115-
"lint-staged": "catalog:lint",
116-
"nx": "catalog:monorepo",
117-
"pkg-pr-new": "catalog:node",
118-
"postcss": "catalog:style",
119-
"prettier": "catalog:lint",
120-
"publint": "catalog:lint",
121-
"read-pkg": "catalog:node",
122-
"rimraf": "catalog:node",
123-
"secretlint": "catalog:lint",
124-
"semantic-release": "catalog:cli",
125-
"sort-package-json": "catalog:prod",
126-
"stylelint": "catalog:lint",
127-
"taze": "catalog:cli",
128-
"textlint": "catalog:lint",
129-
"typescript": "catalog:tsc",
130-
"vitest": "catalog:test"
131-
},
132-
"packageManager": "pnpm@10.18.3",
133-
"engines": {
134-
"node": ">=20.18.* <=24.*"
135-
}
2+
"name": "javascript-style-guide",
3+
"private": true,
4+
"description": "This project is a code style guide of all basic back- and front end project used at Anolilab.",
5+
"keywords": [
6+
"es2015",
7+
"es2018",
8+
"es6",
9+
"anolilab",
10+
"javascript",
11+
"browserslist",
12+
"browserslist-config",
13+
"browsers",
14+
"lint",
15+
"styleguide",
16+
"eslint",
17+
"eslintconfig",
18+
"config",
19+
"es2016",
20+
"es2017",
21+
"es2020",
22+
"css",
23+
"prettier",
24+
"prettier-config",
25+
"semantic-release",
26+
"semantic-release-config",
27+
"changelog",
28+
"publish",
29+
"release",
30+
"npm",
31+
"github",
32+
"git",
33+
"sass",
34+
"scss",
35+
"style",
36+
"stylelint",
37+
"stylelint-config",
38+
"text",
39+
"textlint",
40+
"write-good"
41+
],
42+
"homepage": "https://github.com/anolilab/javascript-style-guide#readme",
43+
"bugs": {
44+
"url": "https://github.com/anolilab/javascript-style-guide/issues"
45+
},
46+
"repository": {
47+
"type": "git",
48+
"url": "git+https://github.com/anolilab/javascript-style-guide.git"
49+
},
50+
"license": "MIT",
51+
"author": "Daniel Bannert <d.bannert@anolilab.de>",
52+
"type": "module",
53+
"workspaces": [
54+
"packages/*"
55+
],
56+
"scripts": {
57+
"audit": "audit-ci --config ./audit-ci.jsonc",
58+
"build:affected:packages": "nx affected --target=build --exclude=*-bench,docs,storybook --nxBail",
59+
"build:affected:prod:packages": "nx affected --target=build:prod --exclude=*-bench,docs,storybook --nxBail",
60+
"build:packages": "nx run-many --target=build --parallel --projects=tag:type:package",
61+
"build:packages:prod": "nx run-many --target=build:prod --parallel --projects=tag:type:package",
62+
"clean": "nx run-many --target=clean && rimraf node_modules",
63+
"preinstall": "node -e \"if(process.env.CI == 'true') {console.info('Skipping preinstall...')} else {process.exit(1)}\" || (node verify-node-version.js && npm -y exec only-allow pnpm)",
64+
"postinstall": "is-ci || husky || exit 0",
65+
"lint": "pnpm run lint:prettier && pnpm run lint:eslint",
66+
"lint:affected:attw": "nx affected --target=lint:attw --parallel --exclude=*-bench,docs,storybook --nxBail",
67+
"lint:affected:eslint": "nx affected --target=lint:eslint --parallel --exclude=*-bench,docs,storybook --nxBail",
68+
"lint:affected:eslint:fix": "nx affected --target=lint:eslint:fix --parallel --exclude=*-bench,docs,storybook --nxBail",
69+
"lint:affected:package-json": "nx affected --target=lint:package-json --parallel --exclude=*-bench,docs,storybook --nxBail",
70+
"lint:affected:types": "nx affected --target=lint:types --parallel --exclude=*-bench,docs,storybook --nxBail",
71+
"lint:attw": "nx run-many --target=lint:attw --all --parallel",
72+
"lint:eslint": "nx run-many --target=lint:eslint --all --parallel",
73+
"lint:eslint:fix": "nx run-many --target=lint:eslint:fix --all --parallel",
74+
"lint:fix": "pnpm run lint:prettier:fix && pnpm run lint:eslint:fix",
75+
"lint:prettier": "nx run-many --target=lint:prettier --all --parallel",
76+
"lint:prettier:fix": "nx run-many --target=lint:prettier:fix --all --parallel",
77+
"lint:secrets": "secretlint **/*",
78+
"lint:staged": "lint-staged --verbose --concurrent false --debug",
79+
"lint:styles": "stylelint",
80+
"lint:text": "textlint ./.github/ ./packages/** ./README.md ./UPGRADE.md --parallel --experimental --cache --dry-run",
81+
"lint:text:fix": "textlint ./.github/ ./packages/** ./README.md ./UPGRADE.md --parallel --experimental --fix",
82+
"lint:types": "nx run-many --target=lint:types --all --parallel",
83+
"sort-package-json": "sort-package-json packages/**/package.json apps/**/package.json ./package.json examples/**/package.json",
84+
"test:affected": "nx affected --target=test --parallel --exclude=*-bench,docs,storybook --nxBail",
85+
"test:affected:coverage": "nx affected --target=test:coverage --parallel --exclude=*-bench,docs,storybook --nxBail",
86+
"test:all": "nx run-many --target=test:coverage --projects=browserslist-config-anolilab,stylelint-config,eslint-config && pnpm test:stylelint",
87+
"test:browserslist-config-anolilab": "pnpm --filter \"browserslist-config-anolilab\" run test",
88+
"test:coverage:browserslist-config-anolilab": "pnpm --filter \"browserslist-config-anolilab\" run test:coverage",
89+
"test:coverage:lint-staged-config": "pnpm --filter \"lint-staged-config\" run test:coverage",
90+
"test:coverage:stylelint-config": "pnpm --filter \"stylelint-config\" run test:coverage",
91+
"test:eslint-config": "pnpm --filter \"eslint-config\" run test",
92+
"test:lint-staged-config": "pnpm --filter \"lint-staged-config\" run test",
93+
"test:stylelint": "node scripts/isNotWindows || stylelint --formatter verbose --config packages/stylelint-config/index.mjs ./packages/stylelint-config/__tests__/css/**/*.css",
94+
"test:stylelint-config": "pnpm --filter \"stylelint-config\" run test",
95+
"update:deps": "taze"
96+
},
97+
"dependencies": {
98+
"@anolilab/multi-semantic-release": "catalog:cli",
99+
"@commitlint/cli": "catalog:lint",
100+
"@commitlint/config-conventional": "catalog:lint",
101+
"@commitlint/core": "catalog:lint",
102+
"@secretlint/secretlint-rule-preset-recommend": "catalog:lint",
103+
"@tsconfig/node16": "catalog:tsc",
104+
"@tsconfig/strictest": "catalog:tsc",
105+
"@types/node": "catalog:types",
106+
"@vitest/coverage-v8": "catalog:test",
107+
"audit-ci": "catalog:prod",
108+
"commitizen": "catalog:cli",
109+
"conventional-changelog-conventionalcommits": "catalog:prod",
110+
"cross-env": "catalog:node",
111+
"cz-conventional-changelog": "catalog:prod",
112+
"eslint": "catalog:lint",
113+
"husky": "catalog:lint",
114+
"is-ci": "catalog:prod",
115+
"lint-staged": "catalog:lint",
116+
"nx": "catalog:monorepo",
117+
"pkg-pr-new": "catalog:node",
118+
"postcss": "catalog:style",
119+
"prettier": "catalog:lint",
120+
"publint": "catalog:lint",
121+
"read-pkg": "catalog:node",
122+
"rimraf": "catalog:node",
123+
"secretlint": "catalog:lint",
124+
"semantic-release": "catalog:cli",
125+
"sort-package-json": "catalog:prod",
126+
"stylelint": "catalog:lint",
127+
"taze": "catalog:cli",
128+
"textlint": "catalog:lint",
129+
"typescript": "catalog:tsc",
130+
"vitest": "catalog:test"
131+
},
132+
"packageManager": "pnpm@10.18.3",
133+
"engines": {
134+
"node": ">=20.18.* <=24.*"
135+
}
136136
}

packages/eslint-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"clean": "rimraf node_modules dist",
112112
"debug:rules": "pnpm exec eslint-config-inspector --config ./debug-eslint.config.mjs",
113113
"lint:attw": "attw --pack",
114-
"lint:eslint": "eslint .",
114+
"lint:eslint": "eslint . --cache --concurrency auto",
115115
"lint:eslint:fix": "eslint . --cache --concurrency auto --fix",
116116
"lint:prettier": "prettier .",
117117
"lint:prettier:fix": "prettier --write .",

packages/eslint-config/scripts/global-vitest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ const extract = (file: string) => {
3636
ts.forEachChild(mNode, (vNode) => {
3737
if (ts.isVariableDeclarationList(vNode)) {
3838
for (const declaration of vNode.declarations) {
39-
const name
40-
= ts.getNameOfDeclaration(declaration);
39+
const name =
40+
ts.getNameOfDeclaration(declaration);
4141

4242
const escaped = (
4343
name as unknown as { escapedText?: unknown }

packages/eslint-config/src/config/es6.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export const es6Rules: (isInEditor: boolean) => Partial<Linter.RulesRecord> = (
127127
},
128128
{
129129
message:
130-
"Is legacy, npm version got deprecated, migrate to URLSearchParams as recommended or try \"qs\" as a package",
130+
'Is legacy, npm version got deprecated, migrate to URLSearchParams as recommended or try "qs" as a package',
131131
name: "querystring",
132132
},
133133
{
@@ -141,7 +141,7 @@ export const es6Rules: (isInEditor: boolean) => Partial<Linter.RulesRecord> = (
141141
},
142142
{
143143
message:
144-
"Please use \"@faker-js/faker\" as a replacement",
144+
'Please use "@faker-js/faker" as a replacement',
145145
name: "faker",
146146
},
147147
{
@@ -164,23 +164,23 @@ export const es6Rules: (isInEditor: boolean) => Partial<Linter.RulesRecord> = (
164164
name: "rimraf",
165165
},
166166
{
167-
message: "just use \"\".padStart() and \"\".padEnd()",
167+
message: 'just use "".padStart() and "".padEnd()',
168168
name: "pad-left",
169169
},
170170
{
171-
message: "just use \"\".padStart() and \"\".padEnd()",
171+
message: 'just use "".padStart() and "".padEnd()',
172172
name: "pad-right",
173173
},
174174
{
175-
message: "just use \"\".padStart() and \"\".padEnd()",
175+
message: 'just use "".padStart() and "".padEnd()',
176176
name: "left-pad",
177177
},
178178
{
179-
message: "just use \"\".padStart() and \"\".padEnd()",
179+
message: 'just use "".padStart() and "".padEnd()',
180180
name: "right-pad",
181181
},
182182
{
183-
message: "just use \"\".padStart() and \"\".padEnd()",
183+
message: 'just use "".padStart() and "".padEnd()',
184184
name: "pad",
185185
},
186186
{
@@ -273,12 +273,12 @@ export const es6Rules: (isInEditor: boolean) => Partial<Linter.RulesRecord> = (
273273
"prefer-const": isInEditor
274274
? "off"
275275
: [
276-
"error",
277-
{
278-
destructuring: "any",
279-
ignoreReadBeforeAssign: true,
280-
},
281-
],
276+
"error",
277+
{
278+
destructuring: "any",
279+
ignoreReadBeforeAssign: true,
280+
},
281+
],
282282

283283
// Prefer destructuring from arrays and objects
284284
// https://eslint.org/docs/rules/prefer-destructuring

packages/eslint-config/src/config/plugins/antfu.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import { createConfig } from "../../utils/create-config";
99
import interopDefault from "../../utils/interop-default";
1010

1111
export default createConfig<
12-
OptionsFiles
13-
& OptionsOverrides
14-
& OptionsPackageJson & {
15-
lessOpinionated?: boolean;
16-
}
12+
OptionsFiles &
13+
OptionsOverrides &
14+
OptionsPackageJson & {
15+
lessOpinionated?: boolean;
16+
}
1717
>("all", async (config, oFiles) => {
1818
const {
1919
files = oFiles,
@@ -50,14 +50,14 @@ export default createConfig<
5050
"antfu/prefer-inline-type-import": "off",
5151
"antfu/top-level-function": "off",
5252

53-
...lessOpinionated
53+
...(lessOpinionated
5454
? {
55-
curly: ["error", "all"],
56-
}
55+
curly: ["error", "all"],
56+
}
5757
: {
58-
"antfu/curly": "error",
59-
"antfu/if-newline": "error",
60-
},
58+
"antfu/curly": "error",
59+
"antfu/if-newline": "error",
60+
}),
6161

6262
...overrides,
6363
},

0 commit comments

Comments
 (0)