Skip to content

Commit 7ec4b4b

Browse files
authored
Merge pull request #2024 from github/koesie10/eslint-config
Unify ESLint configuration
2 parents 3fa7bec + a3c6b36 commit 7ec4b4b

File tree

10 files changed

+122
-162
lines changed

10 files changed

+122
-162
lines changed

extensions/ql-vscode/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.vscode-test/
22
node_modules/
33
out/
4+
build/
45

56
# Include the Storybook config
67
!.storybook

extensions/ql-vscode/.eslintrc.js

Lines changed: 115 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
module.exports = {
1+
const { resolve } = require("path");
2+
3+
const baseConfig = {
24
parser: "@typescript-eslint/parser",
35
parserOptions: {
46
ecmaVersion: 2018,
57
sourceType: "module",
6-
project: ["tsconfig.json", "./src/**/tsconfig.json", "./test/**/tsconfig.json", "./gulpfile.ts/tsconfig.json", "./scripts/tsconfig.json", "./.storybook/tsconfig.json"],
8+
project: [
9+
resolve(__dirname, "tsconfig.lint.json"),
10+
resolve(__dirname, "src/**/tsconfig.json"),
11+
resolve(__dirname, "test/**/tsconfig.json"),
12+
resolve(__dirname, "gulpfile.ts/tsconfig.json"),
13+
resolve(__dirname, "scripts/tsconfig.json"),
14+
resolve(__dirname, ".storybook/tsconfig.json"),
15+
],
716
},
8-
plugins: [
9-
"github",
10-
"@typescript-eslint",
11-
"etc"
12-
],
17+
plugins: ["github", "@typescript-eslint", "etc"],
1318
env: {
1419
node: true,
1520
es6: true,
@@ -21,7 +26,7 @@ module.exports = {
2126
"plugin:github/typescript",
2227
"plugin:jest-dom/recommended",
2328
"plugin:prettier/recommended",
24-
"plugin:@typescript-eslint/recommended"
29+
"plugin:@typescript-eslint/recommended",
2530
],
2631
rules: {
2732
"@typescript-eslint/no-use-before-define": 0,
@@ -37,14 +42,14 @@ module.exports = {
3742
"@typescript-eslint/explicit-module-boundary-types": "off",
3843
"@typescript-eslint/no-non-null-assertion": "off",
3944
"@typescript-eslint/no-explicit-any": "off",
40-
"@typescript-eslint/no-floating-promises": [ "error", { ignoreVoid: true } ],
45+
"@typescript-eslint/no-floating-promises": ["error", { ignoreVoid: true }],
4146
"@typescript-eslint/no-invalid-this": "off",
4247
"@typescript-eslint/no-shadow": "off",
4348
"prefer-const": ["warn", { destructuring: "all" }],
4449
"@typescript-eslint/no-throw-literal": "error",
4550
"no-useless-escape": 0,
46-
"camelcase": "off",
47-
"eqeqeq": "off",
51+
camelcase: "off",
52+
eqeqeq: "off",
4853
"escompat/no-regexp-lookbehind": "off",
4954
"etc/no-implicit-any-catch": "error",
5055
"filenames/match-regex": "off",
@@ -72,3 +77,102 @@ module.exports = {
7277
"github/no-then": "off",
7378
},
7479
};
80+
81+
module.exports = {
82+
root: true,
83+
...baseConfig,
84+
overrides: [
85+
{
86+
files: ["src/stories/**/*"],
87+
parserOptions: {
88+
project: resolve(__dirname, "src/stories/tsconfig.json"),
89+
},
90+
extends: [
91+
...baseConfig.extends,
92+
"plugin:react/recommended",
93+
"plugin:react-hooks/recommended",
94+
"plugin:storybook/recommended",
95+
],
96+
rules: {
97+
...baseConfig.rules,
98+
},
99+
settings: {
100+
react: {
101+
version: "detect",
102+
},
103+
},
104+
},
105+
{
106+
files: ["src/view/**/*"],
107+
parserOptions: {
108+
project: resolve(__dirname, "src/view/tsconfig.json"),
109+
},
110+
extends: [
111+
...baseConfig.extends,
112+
"plugin:react/recommended",
113+
"plugin:react-hooks/recommended",
114+
],
115+
rules: {
116+
...baseConfig.rules,
117+
},
118+
settings: {
119+
react: {
120+
version: "detect",
121+
},
122+
},
123+
},
124+
{
125+
files: ["test/**/*"],
126+
parserOptions: {
127+
project: resolve(__dirname, "test/tsconfig.json"),
128+
},
129+
env: {
130+
jest: true,
131+
},
132+
},
133+
{
134+
files: ["test/vscode-tests/**/*"],
135+
parserOptions: {
136+
project: resolve(__dirname, "test/tsconfig.json"),
137+
},
138+
env: {
139+
jest: true,
140+
},
141+
rules: {
142+
...baseConfig.rules,
143+
"@typescript-eslint/ban-types": [
144+
"error",
145+
{
146+
// For a full list of the default banned types, see:
147+
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-types.md
148+
extendDefaults: true,
149+
types: {
150+
// Don't complain about the `Function` type in test files. (Default is `true`.)
151+
Function: false,
152+
},
153+
},
154+
],
155+
},
156+
},
157+
{
158+
files: [
159+
".eslintrc.js",
160+
"test/**/jest-runner-vscode.config.js",
161+
"test/**/jest-runner-vscode.config.base.js",
162+
],
163+
parser: undefined,
164+
plugins: ["github"],
165+
extends: [
166+
"eslint:recommended",
167+
"plugin:github/recommended",
168+
"plugin:prettier/recommended",
169+
],
170+
rules: {
171+
"import/no-commonjs": "off",
172+
"prefer-template": "off",
173+
"filenames/match-regex": "off",
174+
"@typescript-eslint/no-var-requires": "off",
175+
},
176+
},
177+
],
178+
};

extensions/ql-vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@
13301330
"cli-integration": "jest --projects test/vscode-tests/cli-integration",
13311331
"update-vscode": "node ./node_modules/vscode/bin/install",
13321332
"format": "prettier --write **/*.{ts,tsx} && eslint . --ext .ts,.tsx --fix",
1333-
"lint": "eslint . --ext .ts,.tsx --max-warnings=0",
1333+
"lint": "eslint . --ext .js,.ts,.tsx --max-warnings=0",
13341334
"format-staged": "lint-staged",
13351335
"storybook": "start-storybook -p 6006",
13361336
"build-storybook": "build-storybook",

extensions/ql-vscode/src/stories/.eslintrc.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

extensions/ql-vscode/src/view/.eslintrc.js

Lines changed: 0 additions & 44 deletions
This file was deleted.

extensions/ql-vscode/test/.eslintrc.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

extensions/ql-vscode/test/matchers/toEqualPath.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { expect } from "@jest/globals";
22
import type { MatcherFunction } from "expect";
33
import { pathsEqual } from "../../src/pure/files";
44

5-
// eslint-disable-next-line func-style -- We need to have access to this and specify the type of the function
65
const toEqualPath: MatcherFunction<[expectedPath: unknown]> = function (
76
actual,
87
expectedPath,
@@ -15,20 +14,16 @@ const toEqualPath: MatcherFunction<[expectedPath: unknown]> = function (
1514
if (pass) {
1615
return {
1716
message: () =>
18-
// eslint-disable-next-line @typescript-eslint/no-invalid-this
1917
`expected ${this.utils.printReceived(
2018
actual,
21-
// eslint-disable-next-line @typescript-eslint/no-invalid-this
2219
)} to equal path ${this.utils.printExpected(expectedPath)}`,
2320
pass: true,
2421
};
2522
} else {
2623
return {
2724
message: () =>
28-
// eslint-disable-next-line @typescript-eslint/no-invalid-this
2925
`expected ${this.utils.printReceived(
3026
actual,
31-
// eslint-disable-next-line @typescript-eslint/no-invalid-this
3227
)} to equal path ${this.utils.printExpected(expectedPath)}`,
3328
pass: false,
3429
};

extensions/ql-vscode/test/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"extends": "../tsconfig.json",
3-
"include": ["**/*.ts", "../src/**/*.ts"],
3+
"include": ["**/*.ts", "../src/**/*.ts", "**/.eslintrc.js", "**/*.config.js"],
44
"exclude": [],
55
"compilerOptions": {
66
"noEmit": true,

extensions/ql-vscode/test/vscode-tests/.eslintrc.js

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": ["src/**/*.ts", "**/.eslintrc.js", "jest.config.js"]
4+
}

0 commit comments

Comments
 (0)