Skip to content

Commit f89db48

Browse files
committed
docs: improve eslint plugins imports
1 parent 17108cd commit f89db48

File tree

9 files changed

+69
-34
lines changed

9 files changed

+69
-34
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,16 @@ npm install --save-dev typescript-eslint @eslint-react/eslint-plugin
3838
// eslint.config.js
3939

4040
// @ts-check
41-
import react from "@eslint-react/eslint-plugin";
41+
import eslintJs from "@eslint/js";
42+
import eslintReact from "@eslint-react/eslint-plugin";
4243
import tseslint from "typescript-eslint";
4344

4445
export default tseslint.config({
4546
files: ["**/*.ts", "**/*.tsx"],
4647
extends: [
47-
react.configs["recommended"],
48+
eslintJs.configs.recommended,
49+
tseslint.configs.recommended,
50+
eslintReact.configs.recommended,
4851
],
4952
languageOptions: {
5053
parser: tseslint.parser,
@@ -54,6 +57,7 @@ export default tseslint.config({
5457
},
5558
rules: {
5659
// Put rules you want to override here
60+
"@eslint-react/prefer-shorthand-boolean": "warn",
5761
},
5862
});
5963
```

packages/plugins/eslint-plugin/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,16 @@ npm install --save-dev typescript-eslint @eslint-react/eslint-plugin
3838
// eslint.config.js
3939

4040
// @ts-check
41-
import react from "@eslint-react/eslint-plugin";
41+
import eslintJs from "@eslint/js";
42+
import eslintReact from "@eslint-react/eslint-plugin";
4243
import tseslint from "typescript-eslint";
4344

4445
export default tseslint.config({
4546
files: ["**/*.ts", "**/*.tsx"],
4647
extends: [
47-
react.configs["recommended"],
48+
eslintJs.configs.recommended,
49+
tseslint.configs.recommended,
50+
eslintReact.configs.recommended,
4851
],
4952
languageOptions: {
5053
parser: tseslint.parser,
@@ -54,6 +57,7 @@ export default tseslint.config({
5457
},
5558
rules: {
5659
// Put rules you want to override here
60+
"@eslint-react/prefer-shorthand-boolean": "warn",
5761
},
5862
});
5963
```

website/eslint.config.mjs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import js from "@eslint/js";
2-
import * as mdx from "eslint-plugin-mdx";
1+
// ts-check
2+
3+
import eslintJs from "@eslint/js";
4+
import eslintReact from "@eslint-react/eslint-plugin";
5+
import eslintPluginMdx from "eslint-plugin-mdx";
6+
import eslintPluginNext from "@next/eslint-plugin-next";
7+
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
8+
import eslintPluginSimpleImportSort from "eslint-plugin-simple-import-sort";
39
import tseslint from "typescript-eslint";
4-
import next from "@next/eslint-plugin-next";
5-
import react from "@eslint-react/eslint-plugin";
6-
import reactHooks from "eslint-plugin-react-hooks";
710
import gitignore from "eslint-config-flat-gitignore";
8-
import simpleImportSort from "eslint-plugin-simple-import-sort";
911

1012
const GLOB_TS = ["**/*.{ts,tsx}"];
1113
const GLOB_JS = ["**/*.{js,cjs,mjs}"];
@@ -14,11 +16,11 @@ const GLOB_APP = ["app/**/*.{js,ts,jsx,tsx}"];
1416
const GLOB_CONFIG = ["**/*.config.{js,mjs,cjs,ts,tsx}"];
1517

1618
export default tseslint.config(
17-
js.configs.recommended,
19+
eslintJs.configs.recommended,
1820
{
19-
...mdx.flat,
21+
...eslintPluginMdx.flat,
2022
files: GLOB_MDX,
21-
processor: mdx.createRemarkProcessor({
23+
processor: eslintPluginMdx.createRemarkProcessor({
2224
lintCodeBlocks: false,
2325
}),
2426
},
@@ -37,29 +39,29 @@ export default tseslint.config(
3739
},
3840
{
3941
files: [...GLOB_TS, ...GLOB_MDX],
40-
...react.configs.recommended,
42+
...eslintReact.configs.recommended,
4143
},
4244
{
4345
files: GLOB_TS,
4446
plugins: {
45-
"react-hooks": reactHooks,
47+
"react-hooks": eslintPluginReactHooks,
4648
},
47-
rules: reactHooks.configs.recommended.rules,
49+
rules: eslintPluginReactHooks.configs.recommended.rules,
4850
},
4951
{
5052
files: GLOB_TS,
5153
plugins: {
52-
"@next/next": next,
54+
"@next/next": eslintPluginNext,
5355
},
5456
rules: {
55-
...next.configs.recommended.rules,
56-
...next.configs["core-web-vitals"].rules,
57+
...eslintPluginNext.configs.recommended.rules,
58+
...eslintPluginNext.configs["core-web-vitals"].rules,
5759
},
5860
},
5961
{
6062
files: [...GLOB_TS, ...GLOB_MDX],
6163
plugins: {
62-
"simple-import-sort": simpleImportSort,
64+
"simple-import-sort": eslintPluginSimpleImportSort,
6365
},
6466
rules: {
6567
"simple-import-sort/exports": "warn",

website/pages/docs/advanced-configuration.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import { ConfigTab, ESLintConfigTabs } from "#/widgets/eslint-config-tabs";
1313
<ConfigTab>
1414

1515
```ts filename="eslint.config.js"
16-
import react from "@eslint-react/eslint-plugin";
16+
import eslintReact from "@eslint-react/eslint-plugin";
1717

1818
export default [
1919
// ...
2020
{
2121
files: ["**/*.{ts,tsx}"],
22-
...react.configs.recommended,
22+
...eslintReact.configs.recommended,
2323
settings: {
2424
"react-x": {
2525
importSource: "react",

website/pages/docs/configurations.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ This can be incredibly helpful for rules to understand the semantics of user-def
7777
<ConfigTab>
7878

7979
```ts filename="eslint.config.js"
80-
import react from "@eslint-react/eslint-plugin";
80+
import eslintReact from "@eslint-react/eslint-plugin";
8181

8282
export default [
8383
// ...
8484
{
8585
files: ["**/*.{ts,tsx}"],
86-
...react.configs.recommended,
86+
...eslintReact.configs.recommended,
8787
settings: {
8888
"react-x": {
8989
importSource: "react",

website/pages/docs/getting-started.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Getting Started
1+
# Getting Started with TypeScript
22

33
## Install
44

@@ -11,13 +11,16 @@ npm install --save-dev typescript-eslint @eslint-react/eslint-plugin
1111
```js filename="eslint.config.js"
1212

1313
// @ts-check
14-
import react from "@eslint-react/eslint-plugin";
14+
import eslintJs from "@eslint/js";
15+
import eslintReact from "@eslint-react/eslint-plugin";
1516
import tseslint from "typescript-eslint";
1617

1718
export default tseslint.config({
1819
files: ["**/*.ts", "**/*.tsx"],
1920
extends: [
20-
react.configs["recommended"],
21+
eslintJs.configs.recommended,
22+
tseslint.configs.recommended,
23+
eslintReact.configs.recommended,
2124
],
2225
languageOptions: {
2326
parser: tseslint.parser,
@@ -27,6 +30,7 @@ export default tseslint.config({
2730
},
2831
rules: {
2932
// Put rules you want to override here
33+
"@eslint-react/prefer-shorthand-boolean": "warn",
3034
},
3135
});
3236
```

website/pages/docs/getting-started/javascript-with-babel.mdx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,20 @@ npm install --save-dev @babel/core @babel/eslint-parser @babel/preset-env @babel
99
## Setup
1010

1111
```js filename="eslint.config.js"
12-
import parser from "@babel/eslint-parser";
13-
import react from "@eslint-react/eslint-plugin";
12+
import eslintJs from "@eslint/js";
13+
import eslintReact from "@eslint-react/eslint-plugin";
14+
import babelEslintParser from "@babel/eslint-parser";
15+
import globals from "globals";
1416

1517
export default [
1618
{
1719
files: ["**/*.js", "**/*.jsx"],
20+
...eslintJs.configs.recommended,
1821
languageOptions: {
19-
parser,
22+
globals: {
23+
...globals.browser,
24+
},
25+
parser: babelEslintParser,
2026
parserOptions: {
2127
requireConfigFile: false,
2228
babelOptions: {
@@ -31,6 +37,7 @@ export default [
3137
files: ["**/*.js", "**/*.jsx"],
3238
rules: {
3339
// Put rules you want to override here
40+
"@eslint-react/prefer-shorthand-boolean": "warn",
3441
},
3542
},
3643
];

website/pages/docs/getting-started/javascript.mdx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,34 @@ npm install --save-dev @eslint-react/eslint-plugin
99
## Setup
1010

1111
```js filename="eslint.config.js"
12-
import react from "@eslint-react/eslint-plugin";
12+
import eslintJs from "@eslint/js";
13+
import eslintReact from "@eslint-react/eslint-plugin";
14+
import globals from "globals";
1315

1416
export default [
1517
{
1618
files: ["**/*.js", "**/*.jsx"],
17-
...react.configs["recommended"],
19+
...eslintJs.configs.recommended,
1820
languageOptions: {
21+
globals: {
22+
...globals.browser,
23+
},
1924
parserOptions: {
2025
ecmaFeatures: {
2126
jsx: true,
2227
},
2328
},
2429
},
2530
},
31+
{
32+
files: ["**/*.js", "**/*.jsx"],
33+
...eslintReact.configs.recommended,
34+
},
2635
{
2736
files: ["**/*.js", "**/*.jsx"],
2837
rules: {
2938
// Put rules you want to override here
39+
"@eslint-react/prefer-shorthand-boolean": "warn",
3040
},
3141
},
3242
];

website/pages/docs/getting-started/typescript.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ npm install --save-dev typescript-eslint @eslint-react/eslint-plugin
1111
```js filename="eslint.config.js"
1212

1313
// @ts-check
14-
import react from "@eslint-react/eslint-plugin";
14+
import eslintJs from "@eslint/js";
15+
import eslintReact from "@eslint-react/eslint-plugin";
1516
import tseslint from "typescript-eslint";
1617

1718
export default tseslint.config({
1819
files: ["**/*.ts", "**/*.tsx"],
1920
extends: [
20-
react.configs["recommended"],
21+
eslintJs.configs.recommended,
22+
tseslint.configs.recommended,
23+
eslintReact.configs.recommended,
2124
],
2225
languageOptions: {
2326
parser: tseslint.parser,
@@ -27,6 +30,7 @@ export default tseslint.config({
2730
},
2831
rules: {
2932
// Put rules you want to override here
33+
"@eslint-react/prefer-shorthand-boolean": "warn",
3034
},
3135
});
3236
```

0 commit comments

Comments
 (0)