ESLint: Workaround failure to parse files with template literals #15241
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes proposed in this Pull Request:
TypeError: Cannot read property 'range' of null
.This error has been reported several other times in the various ESLint repos:
babel/babel-eslint#530 (I think
babel-eslint
is the origin of the problem, but don't quote me on this)eslint/eslint#9872
jsx-eslint/eslint-plugin-react#2321
...and so on.
I've tried a few workarounds, but this is both the one that actually fixed the issue, and also the simplest one.
The
template-curly-spacing
rule enforces our traditional spacing inside template literal variables (e.g.${ foo }
).Not only it's just a styling rule, but it's also one that is automatically fixed by Prettier.
Note: I've intentionally left the original rule in the config file. The workaround overrides it, and this way it would be easier to just remove the workaround whenever
babel-eslint
fixes this issue.Testing instructions:
Cannot read property 'range' of null Occurred while linting /path/to/file.js:123
whenever the file is parsed (in my case, it parses on type, so it happens very often; if you have set ESLint to only parse on save, please save the file every each step 😄). Note that the reported line is where the first template literal is (in the example it would be line 42).E.g.
defaultAttributes
(at line 10 of the example) ->defa ultAttributes
.Proposed changelog entry for your changes: