typescript-eslint: [2.4.0][Watch][Windows] ESLint doesn't exit after completing a cli lint

Simply upgrading eslint-pluginand parser from 2.3.3 to 2.4.0 causes eslint to hang at the end of the processing.

npx eslint --cache --report-unused-disable-directives "./**/*.{js,jsx,ts,tsx}"

I’ve enabled basic debugging DEBUG=eslint:cli-engine and the last message is eslint:cli-engine Linting complete in: 110453ms +219ms and then the eslint command does not seem to return (within several minutes) and I can only kill the process. I have tried this without any change to the sources to be parsed or the configuration and simply upgrading to 2.4.0 makes eslint hang and after moving back to 2.3.3 it does no longer hang.

(I’m aware that I should upload a reproducible test case but given the nature of this problem this seems not possible right now)

Versions

package version
@typescript-eslint/eslint-plugin 2.4.0
@typescript-eslint/parser 2.4.0
TypeScript 3.6.4
ESLint 6.5.1
node 12.12.0
npm 6.12.0

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 36 (30 by maintainers)

Commits related to this issue

Most upvoted comments

Running into this as well. macOS. Running with --debug produces eslint:cli-engine Linting complete in: 2301ms +6ms but it never exits.

For reference:

.eslintrc.json

{
	"plugins": ["@typescript-eslint"],
	"parser": "@typescript-eslint/parser",
	"parserOptions": {
		"project": "./tsconfig.eslint.json"
	},
	"extends": [
		"eslint:recommended",
		"plugin:@typescript-eslint/eslint-recommended",
		"plugin:@typescript-eslint/recommended",
		"plugin:@typescript-eslint/recommended-requiring-type-checking"
	],
	"env": {
		"amd": true,
		"browser": true,
		"node": true
	},
	"rules": {
		"prefer-const": ["warn", {
			"destructuring": "all"
		}],
		"require-await": "off",
		"@typescript-eslint/ban-ts-ignore": "warn",
		"@typescript-eslint/explicit-function-return-type": "off",
		"@typescript-eslint/interface-name-prefix": [
			"error",
			{
				"prefixWithI": "always",
				"allowUnderscorePrefix": false
			}
		],
		"@typescript-eslint/member-delimiter-style": [
			"error",
			{
				"multiline": {
					"delimiter": "comma",
					"requireLast": true
				},
				"singleline": {
					"delimiter": "comma",
					"requireLast": false
				}
			}
		],
		"@typescript-eslint/no-inferrable-types": "off",
		"@typescript-eslint/require-await": "warn"
	}
}

tsconfig.eslint.json

{
	"extends": "./tsconfig",
	"compilerOptions": {
		"allowJs": true
	},
	"include": [
		"src/**/*",
		"tests/**/*",
		"./*.js",
		"./*.ts"
	]
}

tsconfig.json

{
	"compilerOptions": {
		"target": "es5",
		"module": "commonjs",
		"lib": [
			"dom",
			"dom.iterable",
			"es2015"
		],
		"skipLibCheck": true,
		"sourceMap": true,
		"downlevelIteration": true,
		"strict": true,
		"allowSyntheticDefaultImports": true,
		"esModuleInterop": true,
		"inlineSources": true,
		"rootDir": "src"
	},
	"include": [
		"src/**/*"
	],
	"exclude": [
		"dist",
		"out"
	]
}

eslint 6.5.1 the 2.4.0 version of the eslint typescript packages. It’s in an archetype project so there’s only 1 or 2 files to lint. Reverting to 2.3.3 fixed the issue for me.

If you’re looking for a more robust way to disable watching, there is also a config you can add to your eslintrc - parserOptions: {noWatch: true}. You need not rollback to 2.3.3.

Should be pretty straightforward to add a Windows agent to the Azure Pipelines build, hopefully we can figure out a minimal repro to turn into a test

Thank you for the in-depth explanation all the good work! Sorry that I quite often (I know) report problem on the Windows platform but this is simply because our CI always runs on multiple MacOS AND Windows versions.

Windows 7 x64

gah. windows. the one platform we don’t have any coverage on. This is more than likely the culprit. cc @JamesHenry - is it possible to add windows to the CI?

I’ll have to dust off my windows laptop and do some investigation.

Could you elaborate on what this settings does or rather prevents from doing?

When you run eslint, typescript will tell us which folders it wants us to watch. In <2.4.0, we just no-oped that CB, because we thought we didn’t care about setting up watchers because eslint would provide us with the most up-to-date file contents. However this had a drawback with the 2.0.0 change we added to parse a stricter set of files - it meant that when you were in a long-running lint session (i.e. via an IDE), then typescript wouldn’t know that a new file should be included in the parse, and we would thus throw errors on valid files.

2.4.0 adds support for weak file watching - it attaches watchers to the folders typescript cares about, as well as the tsconfig file(s). These watchers are set to be non-persistent - i.e. they are lightweight and will not hold the process open. But it looks like there’s something wrong on Windows specifically. chokidar was supposed to handle the platform differences for me automatically, but I might have missed something in the docs.

The environment variable does what it says on the tin - it turns off file watching within the parser (or more accurately typescript-estree). I put it in because on some large, complex setups (like those with symlinks and such), file watching can have a pretty significant overhead, so you might want to turn it off for a single run.

https://github.com/typescript-eslint/typescript-eslint/blob/1918024e86acdf315dbbe659af6fea5d7244b336/packages/typescript-estree/src/tsconfig-parser.ts#L99-L119

The problem we have is that eslint has no specific concept of a long running session, because it’s intended to be pretty stateless. This is why the watchers are setup always, because eslint has no mechanism to tell us that it’s being used in a long running use case.

Should I use “extendedDiagnostics”: true with or without the PARSER_NO_WATCH=true environment variable?

Without, please.

This is the output of eslint when running with “extendedDiagnostics”: true but without PARSER_NO_WATCH=true

Thank you! I’ll investigate this as soon as I can.

This is the output of eslint when running with "extendedDiagnostics": true but without PARSER_NO_WATCH=true: eslint.zip