-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Poor performance on some projects #389
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
Comments
q: did you used prettier + tslint in your test? |
@armano2 - Yes, we also use prettier with tslint. |
We also have the same issue. Setting parserOptions.project to undefined and setting these rules to 'off' resolves the issue, but we would like those rules to be enabled.
We are using the CLI. Not using prettier still results in the same long linting time.
Using |
Circle CI can't complete my linting, fails by 10 minutes timeout :) With babel-eslint it was 2-3 mins. P.S. With |
I am having this issue as well, and our lint is only 126 files. We do not use prettier or any of the other Without
Relevant // .eslintrc.js
"parser": "vue-eslint-parser",
"parserOptions": {
"parser": "@typescript-eslint/parser",
"project": "./tsconfig.json",
"extraFileExtensions": [".vue"]
}, // tsconfig.json
{
"compilerOptions": {
"declaration": false,
"downlevelIteration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom", "es2017", "es2017.object"],
"module": "esnext",
"moduleResolution": "node",
"baseUrl": ".",
"paths": {
"@/*": ["app/javascript/*"],
"#/*": ["app/javascript/modules/*"]
},
"sourceMap": true,
"strict": true,
"target": "esnext"
},
"include": ["app/javascript/**/*.ts"],
"exclude": [
"**/*.spec.ts",
"node_modules",
"vendor",
"public"
],
"compileOnSave": false,
"resolve": {
"extensions": [ ".ts", ".tsx", ".js", ".json"]
}
} |
@bbugh How are you running eslint? For example, I am also able to replicate the massive increase in time when adding eslintrc.json
tsconfig.json
For me it's a 1.5 minutes vs 15 minutes difference |
Questions for @kamok, @bbugh, @deser, @andrewisaburden
A small perf impact is expected, and unavoidable, because typescript has to parse and analyse your entire project. These times are looking longer than that expected perf impact though - hard to say exactly without more info / testing. Question for all users in this thread:
It might be worth us looking into the |
Thanks for taking a look at this! I'm not actually sure what happened... in the midst of running experiments to reply to this message, it's now running significantly faster than before. Now it's about 30-45 seconds (with I've tried to reproduce the earlier issue, and I can't now... Sorry, I know intermittent failures are the worst. Now I've tried it with and without I'll go ahead and answer your questions anyway, since I did have the issue earlier.
We have 126 files (js, vue, ts). 32 of those are
TypeScript - 591 (Much of the vue code is html/css, so those numbers are inflated for these measurements, but I couldn't find an easy way to extract just the line count for the script tags)
I have a
Yes, as I'm sure is clear from the line item counts, this is a mostly javascript application that is incrementally adopting TypeScript.
Unfortunately, it's a private repo. Happy to offer anything else I can. If anything changes on my end I'll report again. |
Rules which require type information are too slow. Dislable them with removing parserOptions > project until the performance issue is fixed. Also @see typescript-eslint/typescript-eslint#389
Can confirm exponentially poor performance with project references in a mixed JS + TS environments in comparison to https://github.com/fimbullinter/wotan which supports project refs natively. |
Running eslint with
Yes we have 3 tsconfigs
Yes, but I think we're not linting |
@karthikiyengar (and really, anyone new who is going to comment in this thread) please leave some more information in regards to your project. If you want to let us know that you too are experiencing slowness, then either:
Just a heads up for people:
Temporary workaround for those with mixed codebases where TS is the minority: consider creating a separate config, and use package.json scripts to run the type information requiring rules only on typescript files (i.e. like We're looking into the slowness, and will post back when we have more information. |
I decided to work around this by just having two
Took total Totally new to TS so maybe this is a "bad idea". |
I just started typing to switch from tslint to eslint for vega-lite and performance is incredibly bad. Just linting a single file takes 10 seconds and I have not been able to lint my whole project yet. I am using eslint and prettier together. You can follow my progress at vega/vega-lite#4901. |
@domoritz Please could you try separating your JS and TS linting into separate steps and let us know how you get on? |
But I don't have any JavaScript in my project. |
Eslint times out after 10 minutes ("No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.") in https://travis-ci.org/vega/vega-lite/jobs/522604028. |
@domoritz your codebase pretty big. running A wild guess of mine would be, that your travis is not running on SSDs, resulting in hugely increased io-time, but your problem is definitely with the |
@heikomat Thank you for looking into this! My macbook is 5 years old so I guess it's a bit slower ;-). I will probably turn off the indentation checks since prettier takes care of them already so that should reduce the number of errors. Now as you point out the issue is using |
@domoritz i too would prefer to be able to use rules that require type information. In my opinion however, the performance tradeoff is not worth the one or two rules that require type information. So my suggestion is indeed to disable these rules until handling type information becomes fast enough. i think some performance impact is definitely understandable considering that gathering type information does take some time, but ~1000% is just way to much |
Thanks @domoritz I have forked your repo to this org in order to capture at this moment in time. We have been hoping to have a large real-world project to use for testing, so this is super useful. I have opened a PR to do some basic initial infrastructure to bring down the commit and run the commands: #458 |
@JamesHenry I'm glad I can help. We have used tslint until now without any performance issues. That means, it is possible to do linting with type checking in a reasonable time (not saying it's easy but it is possible). Let me know if you have any questions. |
Hello, I'm having the exact same issue here 😭 Command I use to lint the codebase: ⏳ Time linting the codebase
110 Total, 105 JS(x), 5 TS(x)
Approximately 13388 loc
No
Yes, We're migrating from JS to TS and transforming files one at a time
Sure, this is the time it takes to run
It's private, but let me know if I can provide you with any more help.
I've taken a look at the without
(on a side note I don't get why the log say with
the second line takes as much as 37 times the duration (821ms vs 22ms), and this for every file linted.
.eslintrc {
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json" // >> this is the line I removed for my tests.
},
"plugins": [
"@typescript-eslint",
"react",
"react-hooks",
"jsx-a11y",
"cypress"
],
"env": {
"browser": true,
"node": true,
"es6": true,
"cypress/globals": true
},
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:jsx-a11y/recommended",
"prettier",
"prettier/@typescript-eslint",
"prettier/react",
"plugin:cypress/recommended"
],
"rules": {
"react/prop-types": "off",
"react/jsx-uses-vars": "warn",
"react-hooks/rules-of-hooks": "error",
"jsx-a11y/no-autofocus": 0,
"no-console": ["error", { "allow": ["info", "warn", "error"] }],
"jsx-a11y/no-noninteractive-element-interactions": "warn",
"jsx-a11y/click-events-have-key-events": "warn",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/explicit-function-return-type": [
"error",
{ "allowExpressions": true, "allowTypedFunctionExpressions": true }
],
"@typescript-eslint/no-explicit-any": "off"
}
} tsconfig.json {
"compilerOptions": {
"baseUrl": "src",
"strict": true,
"jsx": "preserve",
"module": "esnext",
"moduleResolution": "node",
"lib": ["dom", "dom.iterable", "esnext", "scripthost"],
"allowSyntheticDefaultImports": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"pretty": true,
"noEmit": true
}
} Thanks for your time 🙏 . Btw, we should rename the issue because it does not reflect what we're seing. There is a perf problem even though some projects aren't considered large UPDATE: since the issue has been closed, the issue has been resolved for my case. Thanks 🎉 |
Btw, I have mixed project (js\ts). Does it mean that I need to add |
🎉 🎉 🎉
I believe so. Which is why I suggested creating a brand new tsconfig for eslint - so that you can include all of your files without messing with your build / ide experience. |
Many thanks. Is there feeling when #389 (comment) is going to be fixed? :) |
It'll be worked on soon™ (this week or next week potentially). |
It's my test:
typescript: v3.5.3 PC: amd 2700X, SSD import * as ts from 'typescript'
export default function() {
const transformer = <T extends ts.Node>(context: ts.TransformationContext) => (rootNode: T) => {
function visit(node: ts.Node): ts.Node {
console.log('Visiting ' + ts.SyntaxKind[node.kind])
node = ts.visitEachChild(node, visit, context)
if (node.kind === ts.SyntaxKind.BinaryExpression) {
void 0
}
return node
}
return ts.visitNode(rootNode, visit)
}
return transformer
} eslint.conf: module.exports = {
env: {
browser: true,
commonjs: true,
es6: true,
node: true,
},
extends: [
'./plugins/import.yml',
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended'
],
globals: {
Atomics: 'readonly',
document: 'readonly',
globalThis: 'readonly',
navigator: 'readonly',
SharedArrayBuffer: 'readonly',
window: 'readonly',
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
globalReturn: false,
impliedStrict: true,
},
ecmaVersion: 2019,
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'unicorn'],
root: true,
}
Run
Disable the following rules of
cost !:
36.691s decreases to 2.741s ! And then remove entry
wish helpful for someone having bad performance . |
In our project, the average eslint time is around 27s, which is ok. But we also use husky with lint-staged to run eslint and others on every commit. Even if we just commit one single file, it will always take around 12s just for the eslint part, which is too much for committing. (Worse, imagine rebases where this is executed for every single rebased commit). I found out that the culprit are not single rules, but all rules that depend on type information. As a quick hack for resolving our commit times, I created a separate
lint-staged is configured to use this configuration:
For automatic PR builds, I continue to use the full eslint rule set, so violations will still break my builds, same as compile errors. The same applies for the VSCode eslint plugin, it will also use the full rule set and show me violations in the editor. While this works, it would be awesome if typescript-eslint could somehow cache the type information between runs, similar to typescript's new |
jest 25 (npm i jest@next) is much faster than 24.x don't specify parserOptions.project (typescript-eslint/typescript-eslint#389) eslint_d eliminates eslint startup time
jest 25 (npm i jest@next) is much faster than 24.x don't specify parserOptions.project (typescript-eslint/typescript-eslint#389) eslint_d eliminates eslint startup time
jest 25 (npm i jest@next) is much faster than 24.x don't specify parserOptions.project (typescript-eslint/typescript-eslint#389) eslint_d eliminates eslint startup time
jest 25 (npm i jest@next) is much faster than 24.x don't specify parserOptions.project (typescript-eslint/typescript-eslint#389) eslint_d eliminates eslint startup time
if you came here because your tslint/typescript setup is slow, I recommend you to try the following:
|
jest 25 (npm i jest@next) is much faster than 24.x don't specify parserOptions.project (typescript-eslint/typescript-eslint#389) eslint_d eliminates eslint startup time
@khaledosman Thanks for the tips! I'm wondering, does typescript-eslint run through webpack? Setting up webpack module loader exclude rules, and using I'm thinking that |
@duncanleung right, fork-ts-checker has an argument to run eslint that is documented in their README. In my personal setup I even commented out fork-ts-checker and left type-checking disabled for more performance, since I didn't really need it or linting because I was able to see the issues in my VSCode editor right away via their extensions. I also added a git commit hook via husky to lint the project before commits and make sure I don't commit something unlinted. I just wrote this article which includes more details about my setup, if you're interested. |
Hey @duncanleung, I work on fork-ts-checker-webpack-plugin and ts-loader.
If you turn on ESLint with fork-ts-checker-webpack-plugin it's an entirely plug and play experience. Behind the scenes ESLint is being invoked and it is powered by the same mechanisms as ESLint in VS Code etc. I blogged about this and this may be helpful to you: https://blog.johnnyreilly.com/2019/07/typescript-and-eslint-meet-fork-ts-checker-webpack-plugin.html |
@khaledosman @johnnyreilly thank you for your replies - my apologies; I didn't word my question correctly 🙈. You are right - the fork-ts-checker-webpack-plugin README is very clearly written that it works with ESLint. Cheers for the awesome docs on that library 👍. What I was originally intending to ask:Is there was a way for a TL;DR:After a bit more reading, I realize I can use fork-ts-checker-webpack-plugin and have webpack run ESLint in the background at all times through eslint-loader. This can replace our gated git Original Problem - Trying to improve typescript-eslint speed during husky pre-push hookTo give some context: The However, lint speed is slow, and I was trying to find ways to optimize the speed. I thought somehow I could run fork-ts-checker-webpack-plugin on this I realize now that since webpack can continually run eslint in the background through eslint-loader, this can achieve the same code quality goal. I do like the explicit gated push if lint fails, but the improved lint speed might be a better developer experience overall. Thanks again for everyone's feedback. |
Hey @duncanleung Happy to help! One thing that's worth clarifying:
If you're looking for ways to speed up ESLint performance I suggest using the This will generate cached ESLint checks locally which your precommit hook can take advantage of as well I believe. new ForkTsCheckerWebpackPlugin({
eslint: true,
eslintOptions: {
cache: true,
}
} |
jest 25 (npm i jest@next) is much faster than 24.x don't specify parserOptions.project (typescript-eslint/typescript-eslint#389) eslint_d eliminates eslint startup time
jest 25 (npm i jest@next) is much faster than 24.x don't specify parserOptions.project (typescript-eslint/typescript-eslint#389) eslint_d eliminates eslint startup time
I'm opening a new issue since the other (#243) is closed and might not have visibility, but please close if not appropriate.
We are trying to use typescript-eslint on a pretty large project with 1000+ files. The CLI is very slow (see stats below), which I am able to live with, but since starting to use this plugin all our developers have been experiencing system lockups when running VSCode with the eslint plugin.
Additional info from my comment on the closed issue (#243 (comment)) -
CLI stats:
How many files are there?
1000+
Are you linting a multi tsconfig repo?
No
What rules are you using?
recommended + airbnb + prettier
Are you running eslint in watch mode? Via your ide? Via CLI on your entire repo?
Versions
@typescript-eslint/eslint-plugin
1.5.0
@typescript-eslint/parser
1.5.0
TypeScript
3.3.4000
ESLint
5.15.1
node
10.15.0
The text was updated successfully, but these errors were encountered: