eslint / eslint

Find and fix problems in your JavaScript code.
https://eslint.org
MIT License
24.39k stars 4.4k forks source link

Prasing file is taking over a min #18410

Closed awebdeveloper closed 2 weeks ago

awebdeveloper commented 2 weeks ago

Environment

Node version: 14 npm version: 6 Local ESLint version: 8:23 Global ESLint version: 8:23 Operating System: windows 10

What parser are you using?

@typescript-eslint/parser

What did you do?

Configuration ``` // Refer to the doc for any TSLint - ESLint rule name changes - https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/TSLINT_RULE_ALTERNATIVES.md // Tool used for ESLint and Prettier redudant rules - https://github.com/prettier/eslint-config-prettier#cli-helper-tool module.exports = { root: true, settings: { react: { version: '16.14.0', }, }, env: { browser: true, node: true, 'jest/globals': true, }, globals: { TestObjectDefineProperty: 'readonly', // Added this for the custom Jest variable we define. }, extends: ['eslint:recommended', 'plugin:react/recommended', 'prettier'], ignorePatterns: [ '**/src/third-party/', '**/src/**/*.d.ts', '**/src/fabric/', '**/packages/copilot/', '**/local-packages/', '**/webpack/', '**/dist/', '.eslintrc.js', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', sourceType: 'module', }, plugins: [ 'eslint-plugin-react', 'eslint-plugin-import', 'library-import', '@typescript-eslint', 'jest', ], rules: { curly: 'off', quotes: 'off', semi: 'off', eqeqeq: ['warn', 'always'], radix: 'warn', 'no-undef': 'off', 'no-template-curly-in-string': 'warn', 'no-undef-init': 'warn', 'no-throw-literal': 'warn', 'no-sparse-arrays': 'warn', 'import/order': 'off', // Disabling this as its pretty slow. 'constructor-super': 'warn', 'no-duplicate-imports': 'warn', 'no-debugger': 'error', 'no-cond-assign': 'warn', 'guard-for-in': 'warn', 'no-bitwise': 'warn', 'no-duplicate-case': 'warn', 'no-unsafe-finally': 'warn', 'no-unused-labels': 'error', 'no-extra-bind': 'warn', 'no-case-declarations': 'warn', 'object-shorthand': 'warn', 'no-var': 'error', 'prefer-const': 'warn', 'use-isnan': 'warn', 'no-return-await': 'off', 'dot-notation': 'off', 'max-classes-per-file': 'off', 'no-caller': 'warn', 'no-new-wrappers': 'warn', 'no-redeclare': 'warn', 'no-empty': ['error', { allowEmptyCatch: true }], 'no-eval': 'error', 'no-new-func': 'warn', 'no-sequences': 'warn', 'no-unused-expressions': [ 'warn', { allowTernary: true, }, ], 'no-unused-vars': [ 'warn', { argsIgnorePattern: '^_', }, ], 'no-constant-condition': 'warn', 'no-use-before-define': 'off', 'prefer-object-spread': 'off', 'no-console': [ 'error', { allow: [ 'warn', 'dir', 'time', 'timeEnd', 'timeLog', 'trace', 'assert', 'clear', 'count', 'countReset', 'group', 'groupEnd', 'table', 'debug', 'info', 'dirxml', 'groupCollapsed', 'Console', 'profile', 'profileEnd', 'timeStamp', 'context', ], }, ], 'no-extra-boolean-cast': 'warn', 'no-dupe-class-members': 'warn', 'no-useless-escape': 'warn', 'no-useless-catch': 'error', 'no-fallthrough': 'warn', 'no-self-assign': 'warn', 'getter-return': 'warn', 'no-prototype-builtins': 'warn', 'no-empty-pattern': 'warn', 'prefer-const': 'warn', 'no-dupe-else-if': 'warn', 'valid-typeof': 'warn', 'no-control-regex': 'warn', 'no-import-assign': 'warn', 'no-irregular-whitespace': 'warn', 'spaced-comment': [ 'warn', 'always', { markers: ['/'], }, ], 'library-import/lodash': 'error', 'react/jsx-key': 'warn', 'react/jsx-no-bind': 'warn', 'react/self-closing-comp': 'warn', 'react/no-deprecated': 'warn', 'react/jsx-no-target-blank': 'warn', 'react/no-direct-mutation-state': 'warn', 'react/prop-types': 'warn', 'react/no-string-refs': 'warn', 'react/no-find-dom-node': 'warn', 'react/no-unknown-property': 'warn', 'react/display-name': 'warn', 'react/no-unescaped-entities': 'warn', 'react/no-children-prop': 'warn', 'react/jsx-no-comment-textnodes': 'warn', 'no-unsafe-optional-chaining': 'warn', 'import/no-default-export': 'warn', 'import/no-extraneous-dependencies': 'off', 'import/no-internal-modules': 'off', '@typescript-eslint/no-empty-function': 'warn', '@typescript-eslint/no-empty-interface': 'warn', '@typescript-eslint/prefer-for-of': 'warn', '@typescript-eslint/no-misused-new': 'warn', '@typescript-eslint/prefer-function-type': 'warn', '@typescript-eslint/no-namespace': 'warn', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/consistent-type-assertions': 'off', '@typescript-eslint/consistent-type-definitions': 'warn', '@typescript-eslint/member-ordering': [ 'warn', // To avoid a lot of errors using the same rules as TSLint memberordering - statics-first from v5.2 - https://github.com/palantir/tslint/blob/release/5.20.x/src/rules/memberOrderingRule.ts { classes: [ 'public-static-field', 'public-static-method', 'protected-static-field', 'protected-static-method', 'private-static-field', 'private-static-method', 'public-instance-field', 'protected-instance-field', 'private-instance-field', 'constructor', 'public-instance-method', 'protected-instance-method', 'private-instance-method', ], }, ], '@typescript-eslint/no-unused-expressions': [ 'warn', { allowTernary: true }, ], '@typescript-eslint/no-this-alias': 'warn', '@typescript-eslint/quotes': ['warn', 'single'], '@typescript-eslint/adjacent-overload-signatures': 'warn', '@typescript-eslint/array-type': 'off', '@typescript-eslint/dot-notation': 'off', '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/unified-signatures': 'off', '@typescript-eslint/triple-slash-reference': [ 'warn', { path: 'always', types: 'prefer-import', lib: 'always', }, ], '@typescript-eslint/explicit-member-accessibility': [ 'warn', { accessibility: 'explicit', }, ], '@typescript-eslint/naming-convention': [ 'warn', { selector: 'class', format: ['PascalCase'], leadingUnderscore: 'forbid', trailingUnderscore: 'forbid', }, { selector: 'variable', format: ['camelCase', 'UPPER_CASE', 'PascalCase'], }, ], '@typescript-eslint/ban-types': [ 'warn', { types: { Object: { message: 'Avoid using the `Object` type. Did you mean `object`?', }, Function: { message: 'Avoid using the `Function` type. Prefer a specific function type, like `() => void`.', }, Boolean: { message: 'Avoid using the `Boolean` type. Did you mean `boolean`?', }, Number: { message: 'Avoid using the `Number` type. Did you mean `number`?', }, String: { message: 'Avoid using the `String` type. Did you mean `string`?', }, Symbol: { message: 'Avoid using the `Symbol` type. Did you mean `symbol`?', }, }, }, ], }, }; /* Below are the rules that were genereated by the tslint - eslint migration package. The ones that seem appropriate have been added above and removed from below. Keeping it for reference for a faster resolution if we notice any diff betwen Tslint and Eslint rules: { '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/indent': [ 'error', 2, { ObjectExpression: 'first', FunctionDeclaration: { parameters: 'first', }, FunctionExpression: { parameters: 'first', }, }, ], '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-parameter-properties': 'off', '@typescript-eslint/no-shadow': [ 'error', { hoist: 'all', }, ], '@typescript-eslint/prefer-namespace-keyword': 'error', '@typescript-eslint/typedef': 'off', complexity: 'off', 'id-denylist': 'off', 'id-match': 'off', indent: 'off', 'jsdoc/check-alignment': 'error', 'jsdoc/check-indentation': 'error', 'jsdoc/newline-after-description': 'error', 'max-len': [ 'error', { code: 140, }, ], 'no-empty-function': 'off', 'no-fallthrough': 'off', 'no-invalid-this': 'off', 'no-shadow': 'off', 'no-underscore-dangle': 'off', 'one-var': ['error', 'never'], 'prefer-arrow/prefer-arrow-functions': 'error', 'react/jsx-boolean-value': 'off', 'unicorn/prefer-ternary': 'off', 'valid-typeof': 'off', '@typescript-eslint/tslint/config': [ 'error', { rules: { 'import-spacing': true, 'jsx-no-string-ref': true, whitespace: [ true, 'check-branch', 'check-decl', 'check-operator', 'check-separator', 'check-type', 'check-typecast', 'check-type-operator', 'check-rest-spread', ], }, }, ], }, }; */ ```
<!-- Paste your code here -->

What did you expect to happen?

Eslint is taking too much time parsing any file. Just the parsing step took 1 min. How do I debug this and speed up the step.

What actually happened?

eslint:linter Parsing: C:\Workspace\popup.test.tsx +3ms eslint:linter Parsing successful: C:\Workspace\popup.test.tsx +1m

Link to Minimal Reproducible Example

na

Participation

Additional comments

No response

mdjermanovic commented 2 weeks ago

What parser are you using?

@typescript-eslint/parser

What actually happened?

eslint:linter Parsing: C:\Workspace\popup.test.tsx +3ms eslint:linter Parsing successful: C:\Workspace\popup.test.tsx +1m

As all that happens in ESLint between these two logs is just a call to the parser, I think this is a question for typescript-eslint.

https://github.com/eslint/eslint/blob/dcf178e3c41e7777ee76ae9582387be85118118b/lib/linter/linter.js#L803-L808

Can you please submit an issue to the typescript-eslint repo:

https://github.com/typescript-eslint/typescript-eslint