create-react-app enforces @typescript-eslint/no-namespace, a style rule
See original GitHub issueDescribe the bug
create-react-app --typescript
- Add a
namespace
in a file - I get the error:
ES2015 module syntax is preferred over custom TypeScript modules and namespaces.eslint(@typescript-eslint/no-namespace)
. There seems to be no way to turn off this rule, according to #3886.
Why this is a bug:
From https://github.com/facebook/create-react-app/issues/2157#issuecomment-301452953:
Our rules are specifically picked to not enforce style, and to only find logical mistakes.
Whether or not a namespace is used is most definitely not a choice of style and not a logical mistake. Please remove this rule or give me an option to remove this rule.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:16 (15 by maintainers)
Top Results From Across the Web
Advanced linting with Create React App, Typescript, and ESLint
I made this GitHub repo to demonstrate a fresh Create React App (Typescript template) application with customized linting rules added.
Read more >no-namespace - TypeScript ESLint
Namespaces are an outdated way to organize TypeScript code. ES2015 module syntax is now preferred ( import / export ). This rule does...
Read more >Google JavaScript Style Guide
1 Introduction. This document serves as the complete definition of Google's coding standards for source code in the JavaScript programming language.
Read more >@typescript-eslint/eslint-plugin | Yarn - Package Manager
0 (2022-12-19). Features. eslint-plugin: [no-floating-promises] add suggestion fixer to add an 'await' (#5943 ( ...
Read more >Always be linting your TypeScript! - Develop 1 Limited Blog
For TypeScript, we can enforce rules using eslint - and automatically format our code using prettier. There are a whole raft of style...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @cordasfilip! I think that this could be an unrelated issue, and I’d recommend creating a new GitHub issue to discuss that. If you think that people reading that issue should read this issue too, you can link to this issue there.
Since I’m already here, here are some thoughts that come to mind:
I think VSCode doesn’t run eslint on ts files by default, so that’s why VSCode isn’t showing the errors. Here are some keywords that can help you fix that.
If you replace
location
withwindow.location
, does it work?If debugging is required, it might be helpful if you could list of specific reproduction steps. When you make a new Github issue, the template will prompt you to do so.
Btw, there’s one warning I have left. At this point I should probably explain my use case:
Basically, I don’t want to export/use props separately from the component.
For this example, the proposed fixes will make it work! But I’m still left with this warning:
Let me know what you think. Should
no-redeclare
also be removed? Is the props organization convention a bad one? Is there a way to achieve the same effect without namespaces? Also let me know if you think this is worthy of a separate issue.