Skip to content

Commit

Permalink
fix: enable linting .jsx files when React is selected (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic authored Jun 10, 2024
1 parent a40d038 commit 6736f3d
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 0 deletions.
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";
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

0 comments on commit 6736f3d

Please sign in to comment.