Merge pull request #2024 from github/koesie10/eslint-config
Unify ESLint configuration
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
.vscode-test/
|
||||
node_modules/
|
||||
out/
|
||||
build/
|
||||
|
||||
# Include the Storybook config
|
||||
!.storybook
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
module.exports = {
|
||||
const { resolve } = require("path");
|
||||
|
||||
const baseConfig = {
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
ecmaVersion: 2018,
|
||||
sourceType: "module",
|
||||
project: ["tsconfig.json", "./src/**/tsconfig.json", "./test/**/tsconfig.json", "./gulpfile.ts/tsconfig.json", "./scripts/tsconfig.json", "./.storybook/tsconfig.json"],
|
||||
project: [
|
||||
resolve(__dirname, "tsconfig.lint.json"),
|
||||
resolve(__dirname, "src/**/tsconfig.json"),
|
||||
resolve(__dirname, "test/**/tsconfig.json"),
|
||||
resolve(__dirname, "gulpfile.ts/tsconfig.json"),
|
||||
resolve(__dirname, "scripts/tsconfig.json"),
|
||||
resolve(__dirname, ".storybook/tsconfig.json"),
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
"github",
|
||||
"@typescript-eslint",
|
||||
"etc"
|
||||
],
|
||||
plugins: ["github", "@typescript-eslint", "etc"],
|
||||
env: {
|
||||
node: true,
|
||||
es6: true,
|
||||
@@ -21,7 +26,7 @@ module.exports = {
|
||||
"plugin:github/typescript",
|
||||
"plugin:jest-dom/recommended",
|
||||
"plugin:prettier/recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
],
|
||||
rules: {
|
||||
"@typescript-eslint/no-use-before-define": 0,
|
||||
@@ -37,14 +42,14 @@ module.exports = {
|
||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-floating-promises": [ "error", { ignoreVoid: true } ],
|
||||
"@typescript-eslint/no-floating-promises": ["error", { ignoreVoid: true }],
|
||||
"@typescript-eslint/no-invalid-this": "off",
|
||||
"@typescript-eslint/no-shadow": "off",
|
||||
"prefer-const": ["warn", { destructuring: "all" }],
|
||||
"@typescript-eslint/no-throw-literal": "error",
|
||||
"no-useless-escape": 0,
|
||||
"camelcase": "off",
|
||||
"eqeqeq": "off",
|
||||
camelcase: "off",
|
||||
eqeqeq: "off",
|
||||
"escompat/no-regexp-lookbehind": "off",
|
||||
"etc/no-implicit-any-catch": "error",
|
||||
"filenames/match-regex": "off",
|
||||
@@ -72,3 +77,102 @@ module.exports = {
|
||||
"github/no-then": "off",
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
root: true,
|
||||
...baseConfig,
|
||||
overrides: [
|
||||
{
|
||||
files: ["src/stories/**/*"],
|
||||
parserOptions: {
|
||||
project: resolve(__dirname, "src/stories/tsconfig.json"),
|
||||
},
|
||||
extends: [
|
||||
...baseConfig.extends,
|
||||
"plugin:react/recommended",
|
||||
"plugin:react-hooks/recommended",
|
||||
"plugin:storybook/recommended",
|
||||
],
|
||||
rules: {
|
||||
...baseConfig.rules,
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: "detect",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["src/view/**/*"],
|
||||
parserOptions: {
|
||||
project: resolve(__dirname, "src/view/tsconfig.json"),
|
||||
},
|
||||
extends: [
|
||||
...baseConfig.extends,
|
||||
"plugin:react/recommended",
|
||||
"plugin:react-hooks/recommended",
|
||||
],
|
||||
rules: {
|
||||
...baseConfig.rules,
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: "detect",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["test/**/*"],
|
||||
parserOptions: {
|
||||
project: resolve(__dirname, "test/tsconfig.json"),
|
||||
},
|
||||
env: {
|
||||
jest: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["test/vscode-tests/**/*"],
|
||||
parserOptions: {
|
||||
project: resolve(__dirname, "test/tsconfig.json"),
|
||||
},
|
||||
env: {
|
||||
jest: true,
|
||||
},
|
||||
rules: {
|
||||
...baseConfig.rules,
|
||||
"@typescript-eslint/ban-types": [
|
||||
"error",
|
||||
{
|
||||
// For a full list of the default banned types, see:
|
||||
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-types.md
|
||||
extendDefaults: true,
|
||||
types: {
|
||||
// Don't complain about the `Function` type in test files. (Default is `true`.)
|
||||
Function: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: [
|
||||
".eslintrc.js",
|
||||
"test/**/jest-runner-vscode.config.js",
|
||||
"test/**/jest-runner-vscode.config.base.js",
|
||||
],
|
||||
parser: undefined,
|
||||
plugins: ["github"],
|
||||
extends: [
|
||||
"eslint:recommended",
|
||||
"plugin:github/recommended",
|
||||
"plugin:prettier/recommended",
|
||||
],
|
||||
rules: {
|
||||
"import/no-commonjs": "off",
|
||||
"prefer-template": "off",
|
||||
"filenames/match-regex": "off",
|
||||
"@typescript-eslint/no-var-requires": "off",
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1330,7 +1330,7 @@
|
||||
"cli-integration": "jest --projects test/vscode-tests/cli-integration",
|
||||
"update-vscode": "node ./node_modules/vscode/bin/install",
|
||||
"format": "prettier --write **/*.{ts,tsx} && eslint . --ext .ts,.tsx --fix",
|
||||
"lint": "eslint . --ext .ts,.tsx --max-warnings=0",
|
||||
"lint": "eslint . --ext .js,.ts,.tsx --max-warnings=0",
|
||||
"format-staged": "lint-staged",
|
||||
"storybook": "start-storybook -p 6006",
|
||||
"build-storybook": "build-storybook",
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
browser: true,
|
||||
},
|
||||
plugins: ["github"],
|
||||
extends: [
|
||||
"plugin:github/react",
|
||||
"plugin:github/recommended",
|
||||
"plugin:github/typescript",
|
||||
"plugin:react/recommended",
|
||||
"plugin:react-hooks/recommended",
|
||||
"plugin:storybook/recommended",
|
||||
],
|
||||
rules: {
|
||||
"filenames/match-regex": "off",
|
||||
"import/named": "off",
|
||||
"import/no-namespace": "off",
|
||||
"import/no-unresolved": "off",
|
||||
"no-unused-vars": "off",
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: "detect",
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -1,44 +0,0 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
browser: true
|
||||
},
|
||||
plugins: [
|
||||
"github",
|
||||
],
|
||||
extends: [
|
||||
"plugin:github/react",
|
||||
"plugin:github/recommended",
|
||||
"plugin:github/typescript",
|
||||
"plugin:react/recommended",
|
||||
"plugin:react-hooks/recommended",
|
||||
],
|
||||
rules: {
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-invalid-this": "off",
|
||||
"@typescript-eslint/no-shadow": "off",
|
||||
"camelcase": "off",
|
||||
"eqeqeq": "off",
|
||||
"filenames/match-regex": "off",
|
||||
"i18n-text/no-en": "off",
|
||||
"import/named": "off",
|
||||
"import/no-dynamic-require": "off",
|
||||
"import/no-dynamic-required": "off",
|
||||
"import/no-namespace": "off",
|
||||
"import/no-unresolved": "off",
|
||||
"jsx-a11y/anchor-is-valid": "off",
|
||||
"jsx-a11y/no-noninteractive-element-interactions": "off",
|
||||
"jsx-a11y/no-static-element-interactions": "off",
|
||||
"jsx-a11y/click-events-have-key-events": "off",
|
||||
"no-console": "off",
|
||||
"no-invalid-this": "off",
|
||||
"no-undef": "off",
|
||||
"no-unused-vars": "off",
|
||||
"no-shadow": "off",
|
||||
"github/array-foreach": "off",
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: 'detect'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
jest: true,
|
||||
},
|
||||
parserOptions: {
|
||||
project: "./test/tsconfig.json",
|
||||
},
|
||||
plugins: [
|
||||
"github",
|
||||
],
|
||||
extends: [
|
||||
"plugin:github/react",
|
||||
"plugin:github/recommended",
|
||||
"plugin:github/typescript",
|
||||
],
|
||||
rules: {
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-shadow": "off",
|
||||
"camelcase": "off",
|
||||
"filenames/match-regex": "off",
|
||||
"i18n-text/no-en": "off",
|
||||
"import/no-namespace": "off",
|
||||
"import/no-unresolved": "off",
|
||||
"no-console": "off",
|
||||
"no-shadow": "off",
|
||||
"no-undef": "off",
|
||||
"github/array-foreach": "off",
|
||||
}
|
||||
};
|
||||
@@ -2,7 +2,6 @@ import { expect } from "@jest/globals";
|
||||
import type { MatcherFunction } from "expect";
|
||||
import { pathsEqual } from "../../src/pure/files";
|
||||
|
||||
// eslint-disable-next-line func-style -- We need to have access to this and specify the type of the function
|
||||
const toEqualPath: MatcherFunction<[expectedPath: unknown]> = function (
|
||||
actual,
|
||||
expectedPath,
|
||||
@@ -15,20 +14,16 @@ const toEqualPath: MatcherFunction<[expectedPath: unknown]> = function (
|
||||
if (pass) {
|
||||
return {
|
||||
message: () =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-invalid-this
|
||||
`expected ${this.utils.printReceived(
|
||||
actual,
|
||||
// eslint-disable-next-line @typescript-eslint/no-invalid-this
|
||||
)} to equal path ${this.utils.printExpected(expectedPath)}`,
|
||||
pass: true,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
message: () =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-invalid-this
|
||||
`expected ${this.utils.printReceived(
|
||||
actual,
|
||||
// eslint-disable-next-line @typescript-eslint/no-invalid-this
|
||||
)} to equal path ${this.utils.printExpected(expectedPath)}`,
|
||||
pass: false,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"include": ["**/*.ts", "../src/**/*.ts"],
|
||||
"include": ["**/*.ts", "../src/**/*.ts", "**/.eslintrc.js", "**/*.config.js"],
|
||||
"exclude": [],
|
||||
"compilerOptions": {
|
||||
"noEmit": true,
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
module.exports = {
|
||||
parserOptions: {
|
||||
project: ["../../tsconfig.json"],
|
||||
},
|
||||
env: {
|
||||
jest: true,
|
||||
},
|
||||
plugins: [
|
||||
"github",
|
||||
],
|
||||
extends: [
|
||||
"plugin:github/react",
|
||||
"plugin:github/recommended",
|
||||
"plugin:github/typescript",
|
||||
],
|
||||
rules: {
|
||||
"@typescript-eslint/ban-types": [
|
||||
"error",
|
||||
{
|
||||
// For a full list of the default banned types, see:
|
||||
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-types.md
|
||||
extendDefaults: true,
|
||||
types: {
|
||||
// Don't complain about the `Function` type in test files. (Default is `true`.)
|
||||
Function: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-shadow": "off",
|
||||
"@typescript-eslint/no-invalid-this": "off",
|
||||
"eqeqeq": "off",
|
||||
"filenames/match-regex": "off",
|
||||
"filenames/match-regexp": "off",
|
||||
"i18n-text/no-en": "off",
|
||||
"import/no-anonymous-default-export": "off",
|
||||
"import/no-dynamic-require": "off",
|
||||
"import/no-mutable-exports": "off",
|
||||
"import/no-namespace": "off",
|
||||
"import/no-unresolved": "off",
|
||||
"no-console": "off",
|
||||
"github/array-foreach": "off",
|
||||
"github/no-then": "off"
|
||||
}
|
||||
}
|
||||
4
extensions/ql-vscode/tsconfig.lint.json
Normal file
4
extensions/ql-vscode/tsconfig.lint.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["src/**/*.ts", "**/.eslintrc.js", "jest.config.js"]
|
||||
}
|
||||
Reference in New Issue
Block a user