@@ -4,113 +4,56 @@ This plugin contains extendable ESLint configs.
44
55## Installation
66
7- 1 . Install the plugin and TypeScript config
8-
9- ```
10- yarn add -DE eslint @eddeee888/eslint-plugin @typescript-eslint/eslint-plugin @typescript-eslint/parser
11- ```
12-
13- 2 . Install React plugins - only if you are planning to work with React files
14-
15- ```
16- yarn add -DE eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-jsx-a11y
7+ ``` bash
8+ yarn add -DE eslint @eddeee888/eslint-plugin
179```
1810
1911## Usage
2012
2113### Normal repo
2214
23- ``` json
24- // .eslintrc.json
25- {
26- "plugins" : [" @eddeee888" ],
27- "parserOptions" : {
28- "project" : [" tsconfig.json" ]
29- },
30- "overrides" : [
31- {
32- // 👇 Omit ".tsx" if you don't use React TypeScript
33- "files" : [" *.ts" , " *.tsx" ],
34- "extends" : [" plugin:@eddeee888/typescript" ],
35- "rules" : {}
15+ ``` js
16+ // eslint.config.mjs
17+ import { defineConfig } from ' eslint/config' ;
18+ import ed from ' @eddeee888/eslint-plugin' ;
19+
20+ export default defineConfig (
21+ ... ed .configs [' base-typescript' ],
22+ ... ed .configs .typescript ,
23+ ... ed .configs [' react-typescript' ], // 👈 Omit this line if you don't use React TypeScript
24+ {
25+ languageOptions: {
26+ parserOptions: {
27+ projectService: true ,
28+ },
3629 },
37- // 👇 Omit this block if you don't use React TypeScript
38- {
39- "files" : [" *.tsx" ],
40- "extends" : [" plugin:@eddeee888/react-typescript" ],
41- "rules" : {}
42- }
43- ]
44- }
30+ }
31+ );
4532```
4633
4734### Nx monorepo
4835
49- ``` json
50- // Root .eslintrc.json
51- {
52- // ... other options
53- "overrides" : [
54- {
55- "files" : [" *.ts" , " *.tsx" ],
56- "extends" : [
57- " plugin:@nx/typescript" ,
58- // 👇 Add this line for TypeScript files
59- " plugin:@eddeee888/typescript"
60- ],
61- "rules" : {}
62- },
63- {
64- "files" : [" *.tsx" ],
65- "extends" : [
66- " plugin:@nx/react-typescript" ,
67- // 👇 Add this line if you use React TypeScript
68- " plugin:@eddeee888/react-typescript"
69- ],
70- "rules" : {}
71- }
72- ]
73- }
74-
75- // Project .eslintrc.json
76- {
77- "extends" : [" ../../.eslintrc.json" ],
78- "ignorePatterns" : [" !**/*" ],
79- "overrides" : [
80- // ... other config
81- {
82- "files" : [" *.ts" , " *.tsx" ],
83- // 👇 Add parserOptions.project that points to your project tsconfig.json file
84- "parserOptions" : {
85- "project" : [" pathto/project/tsconfig(.*)?.json" ]
36+ ``` js
37+ // eslint.config.mjs
38+ import { defineConfig } from ' eslint/config' ;
39+ import nx from ' @nx/eslint-plugin' ;
40+ import ed from ' @eddeee888/eslint-plugin' ;
41+
42+ export default defineConfig (
43+ ... nx .configs [' flat/base' ],
44+ ... nx .configs [' flat/typescript' ],
45+ ... nx .configs [' flat/javascript' ],
46+ ... ed .configs .typescript ,
47+ {
48+ languageOptions: {
49+ parserOptions: {
50+ projectService: true ,
8651 },
87- "rules" : {}
88- },
89- {
90- "files" : [" *.js" , " *.jsx" ],
91- "rules" : {}
92- }
93- ],
94- "env" : {
95- "jest" : true
96- }
97- }
98-
99- // (Optional) Choose files to lint by using `project.json` 's `lintFilePatterns`
100- //
101- // Sometimes, the patterns set in a project's .eslintrc.json may not work correctly,
102- // especially when running Nx CLI: `nx lint <project>`
103- // In such case, try using `lintFilePatterns` in the project's `project.json`
104- {
105- // ... other configs
106- "targets" : {
107- "lint" : {
108- "executor" : " @nx/eslint:lint" ,
109- "outputs" : [" {options.outputFile}" ],
110- "options" : {
111- "lintFilePatterns" : [" {projectRoot}/app/**/*.tsx" , " {projectRoot}/app/**/*.ts" ]
112- }
11352 },
53+ },
54+ {
55+ ignores: [' **/dist' , ' eslint.config.mjs' ],
11456 }
115- }
57+ // Other configs below...
58+ );
11659```
0 commit comments