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
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
1 change: 1 addition & 0 deletions lib/config-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 👍

if (this.answers.eslintVersion === "9.x") {
this.result.devDependencies.push("eslint-plugin-react", "@eslint/compat");
if (!this.result.installFlags.includes("--force")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import pluginReactConfig from "eslint-plugin-react/configs/recommended.js";
export default [
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
{ files: ["**/*.jsx"], languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } } },
pluginReactConfig,
];",
"configFilename": "eslint.config.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default [
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
{ files: ["**/*.jsx"], languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } } },
pluginReactConfig,
];",
"configFilename": "eslint.config.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { fixupConfigRules } from "@eslint/compat";
export default [
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
{ files: ["**/*.jsx"], languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } } },
...fixupConfigRules(pluginReactConfig),
];",
"configFilename": "eslint.config.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default [
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
{ files: ["**/*.jsx"], languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } } },
...fixupConfigRules(pluginReactConfig),
];",
"configFilename": "eslint.config.js",
Expand Down
1 change: 1 addition & 0 deletions tests/__snapshots__/syntax-esm-react-eslint8.x-javascript
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import pluginReactConfig from "eslint-plugin-react/configs/recommended.js";

export default [
{languageOptions: { globals: globals.browser }},
{ files: ["**/*.jsx"], languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } } },
pluginReactConfig,
];",
"configFilename": "eslint.config.js",
Expand Down
1 change: 1 addition & 0 deletions tests/__snapshots__/syntax-esm-react-eslint8.x-typescript
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import pluginReactConfig from "eslint-plugin-react/configs/recommended.js";
export default [
{languageOptions: { globals: globals.browser }},
...tseslint.configs.recommended,
{ files: ["**/*.jsx"], languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } } },
pluginReactConfig,
];",
"configFilename": "eslint.config.js",
Expand Down
1 change: 1 addition & 0 deletions tests/__snapshots__/syntax-esm-react-eslint9.x-javascript
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { fixupConfigRules } from "@eslint/compat";

export default [
{languageOptions: { globals: globals.browser }},
{ files: ["**/*.jsx"], languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } } },
...fixupConfigRules(pluginReactConfig),
];",
"configFilename": "eslint.config.js",
Expand Down
1 change: 1 addition & 0 deletions tests/__snapshots__/syntax-esm-react-eslint9.x-typescript
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { fixupConfigRules } from "@eslint/compat";
export default [
{languageOptions: { globals: globals.browser }},
...tseslint.configs.recommended,
{ files: ["**/*.jsx"], languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } } },
...fixupConfigRules(pluginReactConfig),
];",
"configFilename": "eslint.config.js",
Expand Down