Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Use typescript-eslint@v6 with reworked configs #15716

Merged
merged 4 commits into from Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
135 changes: 93 additions & 42 deletions eslint.config.js
Expand Up @@ -74,50 +74,101 @@ module.exports = [
"import/no-extraneous-dependencies": "error",
},
},
{
files: ["**/*.ts"],
languageOptions: {
parser: parserTypeScriptESLint,
parserOptions: {
project: "./tsconfig.json",
},
},
plugins: {
"@typescript-eslint": pluginTypeScriptESLint,
},
rules: {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"no-dupe-class-members": "off",
"@typescript-eslint/no-dupe-class-members": "error",
"no-undef": "off",
"no-redeclare": "off",
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-ignore": { descriptionFormat: "^\\(Babel 7 vs Babel 8\\) .+$" },
...compat
.extends(
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked"
)
.map(config => {
return {
...config,
files: ["**/*.ts"],
languageOptions: {
parser: parserTypeScriptESLint,
parserOptions: {
project: "./tsconfig.eslint.json",
},
},
],
"@typescript-eslint/consistent-type-imports": [
"error",
{ disallowTypeAnnotations: false },
],
"@typescript-eslint/no-use-before-define": [
"error",
{
functions: false,
classes: false,
allowNamedExports: true,
plugins: {
"@typescript-eslint": pluginTypeScriptESLint,
},
],
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-confusing-void-expression": [
"error",
{ ignoreArrowShorthand: true },
],
"@typescript-eslint/no-import-type-side-effects": "error",
},
},
rules: {
...config.rules,
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"no-dupe-class-members": "off",
"@typescript-eslint/no-dupe-class-members": "error",
"no-undef": "off",
"no-redeclare": "off",
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-ignore": {
descriptionFormat: "^\\(Babel 7 vs Babel 8\\) .+$",
},
},
],
"@typescript-eslint/consistent-type-imports": [
"error",
{ disallowTypeAnnotations: false },
],
"@typescript-eslint/no-use-before-define": [
"error",
{
functions: false,
classes: false,
allowNamedExports: true,
},
],
"@typescript-eslint/no-confusing-void-expression": [
"error",
{ ignoreArrowShorthand: true },
],
"@typescript-eslint/no-import-type-side-effects": "error",

// Todo: Investigate, for each of these, whether we want them
"@typescript-eslint/array-type": "off",
"@typescript-eslint/await-thenable": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/consistent-generic-constructors": "off",
"@typescript-eslint/consistent-indexed-object-style": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/no-base-to-string": "off",
"@typescript-eslint/no-duplicate-type-constituents": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-declaration-merging": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/prefer-for-of": "off",
"@typescript-eslint/prefer-function-type": "off",
"@typescript-eslint/prefer-nullish-coalescing": "off",
"@typescript-eslint/prefer-optional-chain": "off",
"@typescript-eslint/prefer-string-starts-ends-with": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/sort-type-constituents": "off",
"@typescript-eslint/triple-slash-reference": "off",
"@typescript-eslint/unbound-method": "off",
"prefer-rest-params": "off",

// https://github.com/typescript-eslint/typescript-eslint/issues/5014
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-return": "off",
},
};
}),
{
files: sourceFiles("js,ts,cjs,mjs"),
languageOptions: {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -43,8 +43,8 @@
"@rollup/plugin-replace": "^5.0.2",
"@types/jest": "^29.5.2",
"@types/node": "^20.3.3",
"@typescript-eslint/eslint-plugin": "^5.61.0",
"@typescript-eslint/parser": "^5.61.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"babel-plugin-transform-charcodes": "^0.2.0",
"c8": "^7.12.0",
"chalk": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-types/src/converters/toStatement.ts
Expand Up @@ -43,7 +43,7 @@ function toStatement(node: t.Node, ignore?: boolean): t.Statement | false {

// @ts-expect-error todo(flow->ts): node.id might be missing
if (mustHaveId && !node.id) {
newType = false as false;
newType = false;
}

if (!newType) {
Expand Down
7 changes: 7 additions & 0 deletions tsconfig.eslint.json
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"allowJs": true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the allowJs option necessary? I don't see more linting errors when I disable this option. Plus Babel has migrated to TS only so it is rare that we will ever import a .js from our source file.

I would like to minimize this config and hopefully in the future we can merge tsconfig.eslint.json back to tsconfig.json so we have consistent tsconfig between type checking and linting.

"strict": true
}
}