Skip to content
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

(ESLint) Enforce filename extensions for jsx #2101

Merged
merged 2 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module.exports = {
'react-app',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this adds tsx and jsx to the resolved imports so their filenames don't need to be specified in imports

],
parser: '@typescript-eslint/parser',
parserOptions: { project: [path.join(__dirname, './tsconfig.json')] },
Expand All @@ -63,6 +64,10 @@ module.exports = {
require('confusing-browser-globals').filter(g => g !== 'self'),
),

'react/jsx-filename-extension': [
'warn',
{ extensions: ['.jsx', '.tsx'], allow: 'as-needed' },
],
'react/jsx-no-useless-fragment': 'warn',
'react/self-closing-comp': 'warn',
'react/no-unstable-nested-components': [
Expand Down Expand Up @@ -282,9 +287,6 @@ module.exports = {
},
],
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is included already with the import/typescript extends: https://github.com/import-js/eslint-plugin-import/blob/main/config/typescript.js

},
'import/resolver': {
typescript: {
alwaysTryTypes: true,
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2101.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [twk3]
---

Apply eslint filename extensions for jsx.
Loading