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 all 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
134 changes: 92 additions & 42 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,50 +74,100 @@ 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-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
Original file line number Diff line number Diff line change
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
3 changes: 3 additions & 0 deletions packages/babel-plugin-transform-runtime/src/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import type { PluginAPI, PluginObject } from "@babel/core";
import _pluginCorejs2 from "babel-plugin-polyfill-corejs2";
import _pluginCorejs3 from "babel-plugin-polyfill-corejs3";
import _pluginRegenerator from "babel-plugin-polyfill-regenerator";
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
const pluginCorejs2 = (_pluginCorejs2.default ||
_pluginCorejs2) as typeof _pluginCorejs2.default;
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
const pluginCorejs3 = (_pluginCorejs3.default ||
_pluginCorejs3) as typeof _pluginCorejs3.default;
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
const pluginRegenerator = (_pluginRegenerator.default ||
_pluginRegenerator) as typeof _pluginRegenerator.default;

Expand Down
2 changes: 1 addition & 1 deletion packages/babel-traverse/src/path/lib/hoister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export default class PathHoister<T extends t.Node = t.Node> {
return false;
}

run() {
run(): NodePath<t.Expression> | undefined {
this.path.traverse(referenceVisitor, this);

if (this.mutableBinding) return;
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-types/src/converters/toStatement.ts
Original file line number Diff line number Diff line change
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
6 changes: 6 additions & 0 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"strict": true
}
}