question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

eslint executor performance improvement

See original GitHub issue

Description

The ability to specify which tsconfig files to use when using eslint.

Motivation

Currently, linting a small (few lines), 0 dependency project within a large monorepo can be very slow.

Looking at the behavior, it seems that eslint is going through a lot of files unrelated to the project itself, likely from using the root tsconfig.

Being able to use the project’s tsconfig files (e.g. tsconfig.lib.json and tsconfig.spec.json) greatly reduces the linting time:

# 27 seconds with Nx
nx lint projectname --no-cache 
# 1 second with eslint
eslint --parser-options project:./packages/projectname/tsconfig.*.json ./packages/projectname/src/**/*.ts

Suggested Implementation

Add a new property to the @nrwl/linter:eslint executor schema, either:

  • tsConfig (to match @nrwl/node:package) or
  • project (to match eslint’s argument)
{
  "executor": "@nrwl/linter:eslint",
  "options": {
    "lintFilePatterns": ["packages/projectname/src/**/*.ts"],
    "tsConfig": "./packages/projectname/tsconfig.*.json"
  }
}

The string value would be passed as --parser-options project:<string-value-here>.

eslint --parser-options project:./packages/projectname/tsconfig.*.json ./packages/projectname/src/**/*.ts

A migration would update any existing targets that use the executor to include the new parameter for all projects.

Alternate Implementations

A more global parserOptions property that acts as a dictionary could also work, being more flexible but likely less user-friendly:

{
  "executor": "@nrwl/linter:eslint",
  "options": {
    "lintFilePatterns": ["packages/projectname/src/**/*.ts"],
    "parserOptions": {
      "project": "./packages/projectname/tsconfig.*.json"
    }
  }
}

Command-line:

eslint --parser-options project:./packages/projectname/tsconfig.*.json ./packages/projectname/src/**/*.ts

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
meeroslavcommented, May 5, 2022

Ok, I see what you mean. I just tried on a repo with ~60 projects and nx lint run went to 4s, while eslint remained around 1s. I will look into this deeper. Thank you for your clarification!

1reaction
meeroslavcommented, Nov 3, 2022

In practice, our background daemon should remove most of the Nx overhead so as you said two runs should be very comparable.

Thank you for the clarification and sorry it took us so long to get to the bottom of this. I will close this issue. If we stumble upon this again we can open a new one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

14 Linting Rules To Help You Write Asynchronous Code in ...
ESLint rules for asynchronous code · 1. no-async-promise-executor · 2. no-await-in-loop · 3. no-promise-executor-return · 4. require-atomic-updates · 5. max-nested- ...
Read more >
@nrwl/linter:eslint | Nx
Read more about how to configure targets and executors here: https://nx.dev/reference/project-configuration#targets. Linter can be configured in multiple ways.
Read more >
Why typescript-eslint Performance is Slow - Duncan Leung
While setting up our team's ESLint config with TypeScript, I noticed that running ESLint with typescript-eslint was quite slow.
Read more >
How to Set Up ESLint Autofix and Prettier on Save in WebStorm
These instructions will work for other JetBrains IDEs like IntelliJ IDEA, PhpStorm, and PyCharm, too. Please make sure you have the Prettier ...
Read more >
Nx v14 is out — Here is all you need to know!
There's more · Core Performance Improvements, Webpack 5, React Native, and more in Nx 13! · Redesigned Starter page, Storybook 6.4, ESLint 8,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found