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

fix: enable linting .jsx files when React is selected #126

Merged
merged 1 commit into from
Jun 10, 2024

Conversation

mdjermanovic
Copy link
Member

I saw this problem mentioned several times in issues/discussions:

$ npx @eslint/create-config
√ How would you like to use ESLint? · problems    
√ What type of modules does your project use? · esm
√ Which framework does your project use? · react
√ The React plugin doesn't officially support ESLint v9 yet. What would you like to do? · 9.x
√ Does your project use TypeScript? · javascript
√ Where does your code run? · browser
The config that you've selected requires the following dependencies:

eslint@9.x, globals, @eslint/js, eslint-plugin-react, @eslint/compat
√ Would you like to install them now? · No / Yes
√ Which package manager do you want to use? · npm
☕️Installing...

...

Successfully created C:\projects\tmp\tmp\eslint.config.mjs file.

$ npx eslint a.jsx

C:\projects\tmp\tmp\a.jsx
  0:0  warning  File ignored because of a matching ignore pattern. Use "--no-ignore" to disable file ignore settings or use "--no-warn-ignored" to suppress this warning

✖ 1 problem (0 errors, 1 warning)

This PR adds a config for **/*.jsx files when React is selected so that they become lintable right away with the created config file.

@eslint-github-bot eslint-github-bot bot added the bug Something isn't working label Jun 10, 2024
Copy link
Member

@aladdin-add aladdin-add left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@aladdin-add aladdin-add merged commit 6736f3d into main Jun 10, 2024
11 checks passed
@aladdin-add aladdin-add deleted the react-languageoptions branch June 10, 2024 11:58
@github-actions github-actions bot mentioned this pull request Jun 10, 2024
@@ -181,6 +181,7 @@ const compat = new FlatCompat({baseDirectory: __dirname, recommendedConfig: plug
}

if (this.answers.framework === "react") {
exportContent += " { files: [\"**/*.jsx\"], languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } } },\n";
Copy link
Member

Choose a reason for hiding this comment

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

it should have been configured in the react plugin, but as the new config defaults, it was only applied to *.{js,mjs,cjs}. Or we can change it to *.{js,mjs,cjs,jsx}?

Copy link
Member Author

Choose a reason for hiding this comment

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

Or we can change it to *.{js,mjs,cjs,jsx}?

Makes sense to me 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants