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

feat(typescript-estree): add option to ignore certain folders from glob resolution #1802

Merged
merged 2 commits into from Mar 27, 2020

Conversation

bradzacher
Copy link
Member

Resolves #1771

I didn't realise, but there's a lot of packages that are published to npm with tsconfigs, and even .ts source files.

If you provide a wide glob like ./**/tsconfig.json, then it'll match those node modules, which means our parser will parse them, leading to wasted memory, and wasted parse time.

This PR adds an option for users to configure ignored folders. By default it just ignores node_modules.

I ran a test against our repo by changing the glob in our config to ./packages/**/tsconfig.json (added an extra *), and the following logs were output, doubly showing it's working

  typescript-eslint:typescript-estree:parser parserOptions.project matched projects: [
  './tsconfig.eslint.json',
  './packages/eslint-plugin-internal/node_modules/@typescript-eslint/experimental-utils/tsconfig.json',
  './packages/eslint-plugin-internal/tsconfig.json',
  './packages/eslint-plugin-tslint/node_modules/@typescript-eslint/experimental-utils/tsconfig.json',
  './packages/eslint-plugin-tslint/node_modules/@typescript-eslint/parser/tsconfig.json',
  './packages/eslint-plugin-tslint/tests/fixture-project/tsconfig.json',
  './packages/eslint-plugin-tslint/tests/test-project/tsconfig.json',
  './packages/eslint-plugin-tslint/tests/tsconfig.json',
  './packages/eslint-plugin-tslint/tsconfig.json',
  './packages/eslint-plugin/node_modules/@typescript-eslint/experimental-utils/tsconfig.json',
  './packages/eslint-plugin/tests/fixtures/tsconfig.json',
  './packages/eslint-plugin/tsconfig.json',
  './packages/experimental-utils/node_modules/@typescript-eslint/typescript-estree/tsconfig.json',
  './packages/experimental-utils/tsconfig.json',
  './packages/parser/node_modules/@typescript-eslint/experimental-utils/tsconfig.json',
  './packages/parser/node_modules/@typescript-eslint/shared-fixtures/tsconfig.json',
  './packages/parser/node_modules/@typescript-eslint/typescript-estree/tsconfig.json',
  './packages/parser/tests/fixtures/services/tsconfig.json',
  './packages/parser/tsconfig.json',
  './packages/shared-fixtures/tsconfig.json',
  './packages/typescript-estree/node_modules/@typescript-eslint/shared-fixtures/tsconfig.json',
  './packages/typescript-estree/tests/fixtures/invalidFileErrors/tsconfig.json',
  './packages/typescript-estree/tests/fixtures/projectFolderIgnoreList/ignoreme/tsconfig.json',
  './packages/typescript-estree/tests/fixtures/projectFolderIgnoreList/includeme/tsconfig.json',
  './packages/typescript-estree/tests/fixtures/semanticInfo/badTSConfig/tsconfig.json',
  './packages/typescript-estree/tests/fixtures/semanticInfo/tsconfig.json',
  './packages/typescript-estree/tests/fixtures/simpleProject/tsconfig.json',
  './packages/typescript-estree/tsconfig.json'
] +0ms
  typescript-eslint:typescript-estree:parser ignore list applied to parserOptions.project: [
  './tsconfig.eslint.json',
  './packages/eslint-plugin-internal/tsconfig.json',
  './packages/eslint-plugin-tslint/tests/fixture-project/tsconfig.json',
  './packages/eslint-plugin-tslint/tests/test-project/tsconfig.json',
  './packages/eslint-plugin-tslint/tests/tsconfig.json',
  './packages/eslint-plugin-tslint/tsconfig.json',
  './packages/eslint-plugin/tests/fixtures/tsconfig.json',
  './packages/eslint-plugin/tsconfig.json',
  './packages/experimental-utils/tsconfig.json',
  './packages/parser/tests/fixtures/services/tsconfig.json',
  './packages/parser/tsconfig.json',
  './packages/shared-fixtures/tsconfig.json',
  './packages/typescript-estree/tests/fixtures/invalidFileErrors/tsconfig.json',
  './packages/typescript-estree/tests/fixtures/projectFolderIgnoreList/ignoreme/tsconfig.json',
  './packages/typescript-estree/tests/fixtures/projectFolderIgnoreList/includeme/tsconfig.json',
  './packages/typescript-estree/tests/fixtures/semanticInfo/badTSConfig/tsconfig.json',
  './packages/typescript-estree/tests/fixtures/semanticInfo/tsconfig.json',
  './packages/typescript-estree/tests/fixtures/simpleProject/tsconfig.json',
  './packages/typescript-estree/tsconfig.json'
] +3ms

@bradzacher bradzacher added the enhancement New feature or request label Mar 26, 2020
@typescript-eslint
Copy link
Contributor

Thanks for the PR, @bradzacher!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@codecov
Copy link

codecov bot commented Mar 26, 2020

Codecov Report

Merging #1802 into master will not change coverage by %.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #1802   +/-   ##
=======================================
  Coverage   95.02%   95.02%           
=======================================
  Files         159      159           
  Lines        7112     7112           
  Branches     2033     2033           
=======================================
  Hits         6758     6758           
  Misses        154      154           
  Partials      200      200           
Flag Coverage Δ
#unittest 95.02% <ø> (ø)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to exclude project specs in parserOptions (e.g. node_modules)
1 participant