@fullstacksjs/eslint-config 9.0.15 → 9.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,37 +12,13 @@
12
12
 
13
13
  ## Installation
14
14
 
15
- If you use [ESLint](https://eslint.org/) alongside [TypeScript](https://typescriptlang.org/)
16
-
17
- ### npm :
18
-
19
- ```sh
20
- $ npm install --save-dev @fullstacksjs/eslint-config eslint prettier typescript
21
- ```
22
-
23
- ### yarn :
24
-
25
- ```sh
26
- $ yarn add --dev @fullstacksjs/eslint-config eslint prettier typescript
27
- ```
28
-
29
- for JavaScript development
30
-
31
- ### npm :
32
-
33
15
  ```sh
34
16
  $ npm install --save-dev @fullstacksjs/eslint-config eslint prettier
35
17
  ```
36
18
 
37
- ### yarn :
38
-
39
- ```sh
40
- $ yarn add --dev @fullstacksjs/eslint-config eslint prettier
41
- ```
42
-
43
19
  ## Usage
44
20
 
45
- ## Method 1 (recommended)
21
+ ### Method 1: Init API
46
22
 
47
23
  Create `.eslintrc.js` file and init the configuration.
48
24
 
@@ -51,16 +27,16 @@ const { init } = require('@fullstacksjs/eslint-config/init');
51
27
 
52
28
  module.exports = init({
53
29
  modules: {
54
- auto: true, // If you need auto module detection.
55
- // Modules configuration. (optional)
30
+ auto: true, // If you need auto module detection (refer to Auto Module Detection).
31
+ // Modules configuration check (optional). (refer to Module API)
56
32
  },
57
33
  // Your configurations
58
34
  });
59
35
 
60
36
  ```
61
37
 
62
- ## Method 2
63
- extend from `@fullstacksjs`:
38
+ ### Method 2: Extends API
39
+ You can also use the configuration within a `json` or `yaml` files by extending from `@fullstacksjs`, the Auto Module Detection is enabled on this method
64
40
 
65
41
  ```json
66
42
  {
@@ -69,7 +45,8 @@ extend from `@fullstacksjs`:
69
45
  ```
70
46
 
71
47
  ## Auto Module Detection
72
- When you extend from `@fullstakcjs` or use `modules.auto: true`, it reads your root `package.json` dependencies and includes necessary rules and plugins.
48
+
49
+ When auto module detection is turned on, the configuration reads the metadata from your root "package.json" file and automatically adds the rules and plugins that are needed. It's enabled for the `extends` API, and you should set `modules.auto` to `true` when you use the `init` API.
73
50
 
74
51
  ## Modules API
75
52
 
@@ -77,7 +54,10 @@ When you extend from `@fullstakcjs` or use `modules.auto: true`, it reads your r
77
54
  interface Modules {
78
55
  auto?: boolean; // Auto module detection
79
56
  react?: 'next' | 'raw'; // controls react, react-hooks, jsx/a11y plugins
80
- typescript?: { parserProject: string[] | string; resolverProject: string[] | string }; // controls typescript plugin
57
+ typescript?: { // controls typescript plugin
58
+ parserProject?: string[] | string; // controls parserOptions.project
59
+ resolverProject?: string[] | string // controls settings['import/resolver'].typescript.project
60
+ };
81
61
  node?: boolean; // controls node plugin
82
62
  strict?: boolean; // controls strict plugin
83
63
  import?: boolean; // controls import plugin
@@ -93,7 +73,7 @@ interface Modules {
93
73
 
94
74
  If you need more advanced typescript-eslint rule you need to specify `modules.typescript.resolverProject`.
95
75
 
96
- ```json
76
+ ```js
97
77
  module.exports = init({
98
78
  modules: {
99
79
  typescript: { resolverProject: "<PATH_TO_TSCONFIG>" }
@@ -101,37 +81,89 @@ module.exports = init({
101
81
  });
102
82
  ```
103
83
 
104
- ## Graphql
84
+ ## React/NextJS configuration
105
85
 
106
- To enable graphql module you need to set either have `graphql` dependency installed with auto module detection option, or manually enable it yourself by `modules.graphql` option. for more information checkout [here](https://github.com/B2o5T/graphql-eslint#configuration).
86
+ React/NextJS configuration should automatically work with Auto Module Detection, but if you need to have more control over the rules you can configure it through `modules.react`.
107
87
 
108
- Here is an example:
88
+ ```js
89
+ module.exports = init({
90
+ modules: {
91
+ react: 'raw' // for React/CRA/Vite
92
+ },
93
+ });
94
+ ```
95
+
96
+ and
109
97
 
110
98
  ```js
111
99
  module.exports = init({
112
100
  modules: {
113
- graphql: true
101
+ react: 'next' // for NextJS
114
102
  },
115
103
  });
116
104
  ```
117
105
 
106
+ ## Migration Guid
107
+
108
+ ### to v9
109
+
110
+ v9 does not have any breaking change, which means the current configuration you have should work without any problem, but in order to migrate to new Module API:
111
+
112
+ 1. Move your configs to `.eslintrc.js` file.
113
+ 2. Use init API.
114
+ ```diff
115
+ -module.exports = {
116
+ - extends: [
117
+ - "@fullstacksjs",
118
+ - "@fullstacksjs/eslint-config/esm",
119
+ - "@fullstacksjs/eslint-config/typecheck",
120
+ - "@fullstacksjs/eslint-config/graphql"
121
+ - ],
122
+ - "parserOptions": {
123
+ - "project": ["./tsconfig.eslint.json"]
124
+ - },
125
+ - "settings": {
126
+ - "import/resolver": {
127
+ - "typescript": {
128
+ - "project": ["./tsconfig.json"]
129
+ - },
130
+ - },
131
+ - },
132
+ - // your configuration
133
+ -};
134
+ +const { init } = require('@fullstacksjs/eslint-config/init');
135
+ +
136
+ +module.exports = init({
137
+ + modules: {
138
+ + auto: true,
139
+ + esm: true,
140
+ + graphql: true,
141
+ + typescript: {
142
+ + parserProject: ['./tsconfig.eslint.json'],
143
+ + resolverProject: ['./tsconfig.json'],
144
+ + },
145
+ + },
146
+ + // your configuration
147
+ +});
148
+ ```
149
+
118
150
  ## What's included?
119
151
 
120
- * @typescript-eslint/eslint-plugin
121
- * eslint-plugin-import
122
- * eslint-plugin-jest
123
- * eslint-plugin-jest-formatting
124
- * eslint-plugin-cypress
125
- * eslint-plugin-jsx-a11y
126
- * eslint-plugin-prettier
127
- * eslint-plugin-react
128
- * eslint-plugin-react-hooks
129
- * eslint-plugin-simple-import-sort
130
- * eslint-plugin-fp
131
- * eslint-plugin-node
132
- * eslint-plugin-promise
133
- * eslint-plugin-storybook
134
- * eslint-plugin-graphql
152
+ * [@typescript-eslint/eslint-plugin](https://typescript-eslint.io/)
153
+ * [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import)
154
+ * [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest)
155
+ * [eslint-plugin-jest-formatting](https://github.com/dangreenisrael/eslint-plugin-jest-formatting)
156
+ * [eslint-plugin-cypress](https://github.com/cypress-io/eslint-plugin-cypress)
157
+ * [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y)
158
+ * [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier)
159
+ * [eslint-plugin-react](https://www.npmjs.com/package/eslint-plugin-react)
160
+ * [eslint-plugin-react-hooks](https://www.npmjs.com/package/eslint-plugin-react-hooks)
161
+ * [eslint-plugin-simple-import-sort](https://github.com/lydell/eslint-plugin-simple-import-sort)
162
+ * [eslint-plugin-fp](https://github.com/jfmengels/eslint-plugin-fp)
163
+ * [eslint-plugin-node](https://github.com/mysticatea/eslint-plugin-node)
164
+ * [eslint-plugin-promise](https://github.com/eslint-community/eslint-plugin-promise)
165
+ * [eslint-plugin-storybook](https://github.com/storybookjs/eslint-plugin-storybook#readme)
166
+ * [eslint-plugin-graphql](https://github.com/apollographql/eslint-plugin-graphql)
135
167
 
136
168
  That's all. Feel free to use 💛
137
169
 
package/init.js CHANGED
@@ -22,6 +22,7 @@ function init(opts = {}) {
22
22
  opts.graphql && require.resolve('./graphql'),
23
23
  opts.import && require.resolve('./import'),
24
24
  opts.typescript && require.resolve('./typescript'),
25
+ opts.react && require.resolve('./react.js'),
25
26
  opts.storybook && require.resolve('./storybook'),
26
27
  opts.cypress && require.resolve('./cypress'),
27
28
  opts.test && require.resolve('./jest'),
@@ -35,8 +36,6 @@ function init(opts = {}) {
35
36
  ...eslintConfig,
36
37
  };
37
38
 
38
- if (opts.react === 'raw') config.extends.push(require.resolve('./react.js'));
39
-
40
39
  if (opts.typescript?.parserProject) {
41
40
  config.parserOptions = merge(config.parserOptions, {
42
41
  project: opts.typescript.parserProject,
@@ -2,6 +2,10 @@ module.exports = [
2
2
  {
3
3
  selector: 'default',
4
4
  format: ['camelCase'],
5
+ filter: {
6
+ regex: '^_+$',
7
+ match: false,
8
+ },
5
9
  },
6
10
  {
7
11
  selector: 'function',
@@ -11,11 +15,19 @@ module.exports = [
11
15
  {
12
16
  selector: 'variable',
13
17
  format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
18
+ filter: {
19
+ regex: '^_+$',
20
+ match: false,
21
+ },
14
22
  },
15
23
  {
16
24
  selector: 'parameter',
17
25
  format: ['camelCase', 'PascalCase'],
18
- leadingUnderscore: 'allowSingleOrDouble',
26
+ leadingUnderscore: 'allow',
27
+ filter: {
28
+ regex: '^_+$',
29
+ match: false,
30
+ },
19
31
  },
20
32
  {
21
33
  selector: 'memberLike',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fullstacksjs/eslint-config",
3
- "version": "9.0.15",
3
+ "version": "9.0.17",
4
4
  "license": "MIT",
5
5
  "author": "fullstacks <fullstacksjs@gmail.com>",
6
6
  "description": "fullstacks eslint config",
package/registerOpts.js CHANGED
@@ -5,7 +5,7 @@ const defaultOptions = {
5
5
  esm: isEsm(),
6
6
  cypress: hasDep('cypress'),
7
7
  graphql: hasDep('graphql'),
8
- react: hasDep('react') && !hasDep('next'),
8
+ react: hasDep('react'),
9
9
  storybook: hasDep('@storybook/react'),
10
10
  test: hasDep('jest') || hasDep('vitest'),
11
11
  typescript: hasDep('typescript'),
package/typescript.js CHANGED
@@ -89,7 +89,7 @@ module.exports = {
89
89
  '@typescript-eslint/no-unused-vars-experimental': 'off', // Why two rules?
90
90
  '@typescript-eslint/no-unused-vars': [
91
91
  'warn',
92
- { argsIgnorePattern: '^_', varsIgnorePattern: '^[iI]gnore(d)?', args: 'after-used', ignoreRestSiblings: true },
92
+ { argsIgnorePattern: '^_', varsIgnorePattern: '^([iI]gnore(d)?)|(_+)', args: 'after-used', ignoreRestSiblings: true },
93
93
  ],
94
94
  '@typescript-eslint/no-use-before-define': ['error', { functions: false, classes: true }],
95
95
  '@typescript-eslint/no-useless-constructor': 'error',