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.

New Typescript linting overriding user config and causing build failure

See original GitHub issue

The introduction of #6513 stops my application from compiling as it uses it’s own Typescript linting rules instead of the rules I have in .eslintrc.js

Previous to CRA adding Typescript linting I created my own typescript lint config for eslint using @typescript-eslint/eslint-plugin and @typescript-eslint/parser along with airbnb and prettier rules.

Within the project there is typescript file generated by graphql-code-generator that breaks various linting rules, so has been added to a .eslintignore file. When I run eslint the project passes with no errors.

However, when I build the project or run it in dev mode 2 lint errors are raised, relating to the fact that import statements appear half way through the file. Using the .eslintignore file doesn’t fix this problem, nor does updating my .eslintrc.js file to exclude the rule.

As a result I cannot build my project with CRA 3 and have had to revert to 2.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:49
  • Comments:63 (11 by maintainers)

github_iconTop GitHub Comments

31reactions
ianschmitzcommented, Apr 24, 2019

Our ESLint configuration is not currently configurable (as has always been the case) and is documented here: https://facebook.github.io/create-react-app/docs/setting-up-your-editor#displaying-lint-output-in-the-editor. Any changes you make to your configuration file will only affect your editor integration but not the Dev server or prod builds.

We haven’t ever supported TSLint so I’m not sure how the other comments are related.

18reactions
jadboxcommented, Apr 24, 2019

@ianschmitz I think the confusion was that Typescript folks where using TSLint since the react-scripts had no TS linting support. We have entire projects built using custom rules, but now since TS linting is supported in v3, we are all stuck with pages of warnings and/or broken builds. While the JS community had somewhat the ease of greenfield development using react-scripts’ blessed linting rules, the TS community is now coming onboard with custom opinionated rulesets for large existing projects.

Proposals:

  1. provide a way to completely disable linting in production and live server (maybe this already exists?)
  2. provide a way for custom eslint overriding rules (both JS/TS)

On a community aside, I didn’t realize the react-scripts didn’t allow JS projects to customize the linting rules. As someone that disagrees with the defaults of most linters (as well as my team), it feels very heavy-handed to including linting by-default without a way to customize. (obviously there’s ejection, but it’s far from an easy path to own)

Read more comments on GitHub >

github_iconTop Results From Across the Web

New Typescript linting overriding user config and causing build failure
The introduction of #6513 stops my application from compiling as it uses it's own Typescript linting rules instead of the rules I have...
Read more >
Linting in TypeScript using ESLint and Prettier - LogRocket Blog
Integrate Prettier with ESLint to automate type-checking in your TypeScript code and ensure that the code has no bugs.
Read more >
Advanced linting with Create React App, Typescript, and ESLint
This article explores setting up advanced linting in a Create React App using Typescript and ESLint.
Read more >
create react app - without typescript , got Error: Failed to load ...
with the current overrides that handle TypeScript mean that node_modules are also being linted for .ts/.tsx files. This PR was raised to work ......
Read more >
lint-staged - npm
npm install --save-dev lint-staged # requires further setup ... Use this flag to allow creating empty git commits.
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