Skip to content

Commit d53fd0a

Browse files
Create per-project lint configurations
This allows for linting a single focused workspace instead of all workspaces. Isolate project-specific ESLint configs in their respective config files.
1 parent 9fba0d4 commit d53fd0a

File tree

9 files changed

+61
-33
lines changed

9 files changed

+61
-33
lines changed

.eslintrc.json

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2+
"root": true,
23
"parser": "@typescript-eslint/parser",
34
"extends": [
45
"airbnb-base",
5-
"plugin:jest/recommended",
66
"plugin:@typescript-eslint/eslint-recommended",
77
"plugin:@typescript-eslint/recommended",
88
"prettier"
@@ -11,47 +11,25 @@
1111
"ecmaVersion": 2018,
1212
"project": ["./**/tsconfig.json", "./**/tsconfig.test.json"]
1313
},
14+
"ignorePatterns": ["coverage/", "lib/"],
1415
"rules": {
1516
"import/extensions": [
1617
"error",
1718
{
1819
"ts": "never"
1920
}
2021
],
21-
"import/no-cycle": "off",
22-
"import/no-extraneous-dependencies": [
23-
"error",
24-
{
25-
"devDependencies": ["**/*.spec.{js,ts}", "**/*.config.js"]
26-
}
27-
],
28-
"import/no-unresolved": [
29-
"error",
30-
{
31-
"ignore": [
32-
"history",
33-
"lodash",
34-
// Workaround for alexgorbatchev/eslint-import-resolver-typescript#17
35-
"regexp-tree/ast",
36-
"RegexColorizer"
37-
]
38-
}
39-
],
4022
"import/prefer-default-export": "off",
41-
"no-else-return": "off",
4223
"no-plusplus": "off",
43-
// This rule excludes too many escape sequences we need, like \p
44-
"no-useless-escape": "off",
4524
// Allow ForOfStatement, preserve the rest of Airbnb's restrictions
4625
"no-restricted-syntax": [
4726
"error",
4827
"ForInStatement",
4928
"LabeledStatement",
5029
"WithStatement"
51-
],
52-
"@typescript-eslint/explicit-function-return-type": "off",
53-
"@typescript-eslint/explicit-module-boundary-types": "off"
30+
]
5431
},
32+
"reportUnusedDisableDirectives": true,
5533
"settings": {
5634
"import/parsers": {
5735
"@typescript-eslint/parser": [".ts"]

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
- run: npx prettier --check .
5151
working-directory: ./
5252
- run: yarn run build
53-
- run: yarn run lint
53+
- run: yarn run -T lint
5454
- run: yarn run test
5555

5656
- run: npx testpack-cli --keep=@types/*,ts-jest,typescript jest.config.js tsconfig.test.json src/e2e.spec.ts

demo/.eslintrc.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"rules": {
3+
"import/no-extraneous-dependencies": [
4+
"error",
5+
{
6+
"devDependencies": ["**/*.config.js"]
7+
}
8+
],
9+
"import/no-unresolved": [
10+
"error",
11+
{
12+
"ignore": ["history", "lodash", "RegexColorizer"]
13+
}
14+
]
15+
}
16+
}

demo/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
"private": true,
55
"scripts": {
66
"build": "wp --config webpack.config.js",
7+
"lint": "tsc -b ./tsconfig.lint.json && eslint .",
78
"test": "exit 0"
89
},
910
"devDependencies": {
1011
"@types/lodash": "^4.14.140",
12+
"@types/node": "^24.8.1",
1113
"clean-webpack-plugin": "^4.0.0",
1214
"css-loader": "^7.1.1",
1315
"node-sass": "^9.0.0",

tsconfig.lint.json renamed to demo/tsconfig.lint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"compilerOptions": {
33
"noEmit": true
44
},
5-
"extends": "./tsconfig.json",
5+
"extends": "../tsconfig.json",
66
"references": [{ "path": "./" }]
77
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"scripts": {
99
"build": "yarn workspaces run build",
1010
"format": "prettier --write .",
11-
"lint": "tsc -b ./tsconfig.lint.json && eslint . --report-unused-disable-directives",
11+
"lint": "yarn workspaces foreach --all run lint",
1212
"test": "yarn workspaces run test"
1313
},
1414
"devDependencies": {
@@ -19,7 +19,7 @@
1919
"eslint-config-prettier": "^10.0.1",
2020
"eslint-import-resolver-typescript": "^4.3.1",
2121
"eslint-plugin-import": "^2.25.3",
22-
"eslint-plugin-jest": "^27.0.4",
23-
"prettier": "2.2.1"
22+
"prettier": "2.2.1",
23+
"typescript": "^4.2.3"
2424
}
2525
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"extends": ["plugin:jest/recommended"],
3+
"rules": {
4+
"import/no-cycle": "off",
5+
"import/no-extraneous-dependencies": [
6+
"error",
7+
{
8+
"devDependencies": ["**/*.spec.{js,ts}", "**/*.config.js"]
9+
}
10+
],
11+
"import/no-unresolved": [
12+
"error",
13+
{
14+
"ignore": [
15+
// Workaround for alexgorbatchev/eslint-import-resolver-typescript#17
16+
"regexp-tree/ast"
17+
]
18+
}
19+
],
20+
"no-else-return": "off",
21+
// This rule excludes too many escape sequences we need, like \p
22+
"no-useless-escape": "off"
23+
}
24+
}

packages/regex-to-strings/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"scripts": {
3030
"build": "tsc -b --clean && tsc -b",
3131
"changelog": "npx auto-changelog",
32+
"lint": "tsc -b ./tsconfig.lint.json && eslint .",
3233
"release": "npx release-it --no-increment",
3334
"test": "jest --coverage"
3435
},
@@ -37,11 +38,11 @@
3738
"@types/jest-when": "^3.5.0",
3839
"jest": "^29.7.0",
3940
"jest-when": "^3.2.1",
40-
"ts-jest": "^29.2.5",
41-
"typescript": "^4.2.3"
41+
"ts-jest": "^29.2.5"
4242
},
4343
"dependencies": {
4444
"escape-string-regexp": "^4.0.0",
45+
"eslint-plugin-jest": "^27.0.4",
4546
"pandemonium": "^2.0.0",
4647
"regexp-tree": "^0.1.23"
4748
},
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"compilerOptions": {
3+
"noEmit": true
4+
},
5+
"extends": "../../tsconfig.json",
6+
"references": [{ "path": "./" }]
7+
}

0 commit comments

Comments
 (0)