Skip to content

On Windows eslint overrides with tslint rules do not match depending on existence of other files #1692

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

Closed
pelepelin opened this issue Mar 6, 2020 · 7 comments · Fixed by #1719
Labels
bug Something isn't working package: eslint-plugin-tslint Issues related to @typescript-eslint/eslint-plugin-tslint

Comments

@pelepelin
Copy link
Contributor

pelepelin commented Mar 6, 2020

What code were you trying to parse?

https://github.com/pelepelin/ts-eslint-bug

This is a stripped copy of a real project. There are only 2 files in src. And there are 2 override blocks in .eslintrc.js.

What did you expect to happen?

When running npm run lint, the file https://github.com/pelepelin/ts-eslint-bug/blob/master/src/__tests__/e2e/utilities/helpers/BuggyClass.ts matches second override https://github.com/pelepelin/ts-eslint-bug/blob/f534c589d55ba09945c8b72609b2f22aaab98788/.eslintrc.js#L32 which has 'completed-docs': false and so it should pass lint.

What actually happened?

When running npm run lint on Linux, the file passes lint, but on Windows it prints

ts-eslint-bug\src\__tests__\e2e\utilities\helpers\BuggyClass.ts
  1:1  error  Documentation must exist for exported classes. (tslint:completed-docs)  @typescript-eslint/tslint/config

✖ 1 problem (1 error, 0 warnings)

When running npm run lint:ref which applies lint on another level of directories, lint passes both on Linux and Windows.

If the file src/index.ts is removed, npm run lint passes both on Linux and Windows.

Versions

package version
@typescript-eslint/eslint-plugin-tslint 2.22.0
@typescript-eslint/parser 2.22.0
TypeScript 3.7.4
ESLint 6.6.0
node Windows 12.13.1, Linux 12.14.0
npm Windows 6.12.1, Linux 6.13.7
@pelepelin pelepelin added package: eslint-plugin-tslint Issues related to @typescript-eslint/eslint-plugin-tslint triage Waiting for team members to take a look labels Mar 6, 2020
@bradzacher bradzacher added external This issue is with another package, not typescript-eslint itself and removed triage Waiting for team members to take a look labels Mar 6, 2020
@bradzacher
Copy link
Member

Thanks for filing this. This looks like a bug in ESLint itself, as our tooling doesn't have anything to do with the eslint config resolution process.

Could you please file this as a bug in the ESLint repo?
https://github.com/eslint/eslint

Thanks!

@pelepelin
Copy link
Contributor Author

ok.
suspicious thing is that the only rules which misbehave so far are tslint rules (under @typescript-eslint/tslint/config). I've put only several rules in the bug demo, but our project of course uses many rules

@bradzacher
Copy link
Member

hmm interesting, if it's only eslint-plugin-tslint rules, it might be a problem with our plugin.
I don't have a windows machine to look into this, would you be able to take a look?

@bradzacher bradzacher reopened this Mar 7, 2020
@bradzacher bradzacher added bug Something isn't working and removed external This issue is with another package, not typescript-eslint itself labels Mar 7, 2020
@pelepelin
Copy link
Contributor Author

I did some parallel debugging and so far I've found that in node_modules\@typescript-eslint\eslint-plugin-tslint\src\rules\config.ts a call const configuration = tslintConfig( receives tslintRules = { "encoding": true, "completed-docs": false } in either case, however, configuration.rules in buggy case is

{
  "encoding": {
    "ruleArguments": [],
    "ruleSeverity": "error"
  },
  "completed-docs": {
    "ruleArguments": [],
    "ruleSeverity": "error"
  }
}

while in normal case it's

{
  "encoding": {
    "ruleArguments": [],
    "ruleSeverity": "error"
  },
  "completed-docs": {
    "ruleArguments": [],
    "ruleSeverity": "off"
  }
}

@pelepelin
Copy link
Contributor Author

pelepelin commented Mar 8, 2020

So it seems the call const tslintConfig = memoize( incorrectly uses only the rule keys for a memoization cache key ${lintFile}_${Object.keys(tslintRules).join(',')}...

UP: yes, that should be it, checked on my case using JSON.stringify instead.

@pelepelin
Copy link
Contributor Author

Probably, the result is different on Windows just because of different traversing order

@bradzacher
Copy link
Member

I'd be happy to accept a PR if you've got a fix for it.

pelepelin added a commit to pelepelin/typescript-eslint that referenced this issue Mar 11, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: eslint-plugin-tslint Issues related to @typescript-eslint/eslint-plugin-tslint
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants