@fullstacksjs/eslint-config 11.8.1 → 11.9.0

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
@@ -18,27 +18,27 @@ $ npm install --save-dev @fullstacksjs/eslint-config eslint prettier
18
18
 
19
19
  ## Usage
20
20
 
21
- To use the configuration, all you need is to export the generated config by the `init` function. The configuration reads the metadata from your root `package.json` file and automatically adds the rules and plugins that are needed.
21
+ To use the configuration, all you need is to export the generated config by the `defineConfig` function. The configuration reads the metadata from your root `package.json` file and automatically adds the rules and plugins that are needed.
22
22
 
23
23
  ### ESM
24
24
 
25
25
  ```js
26
- import { init } from '@fullstacksjs/eslint-config';
26
+ import { defineConfig } from '@fullstacksjs/eslint-config';
27
27
 
28
- export default init();
28
+ export default defineConfig();
29
29
  ```
30
30
 
31
31
  ### CJS
32
32
 
33
33
  ```js
34
- const { init } = require('@fullstacksjs/eslint-config');
34
+ const { defineConfig } = require('@fullstacksjs/eslint-config');
35
35
 
36
- module.exports = init();
36
+ module.exports = defineConfig();
37
37
  ```
38
38
 
39
39
  ## Modules API
40
40
 
41
- You can fine-tune module detection by overriding it, the `init` function accepts options as its first argument to control enabled modules.
41
+ You can fine-tune module detection by overriding it, the `defineConfig` function accepts options as its first argument to control enabled modules.
42
42
 
43
43
  ```typescript
44
44
  interface Options {
@@ -71,12 +71,12 @@ interface Options {
71
71
 
72
72
  ## Extra configuration
73
73
 
74
- You can pass any number of arbitrary custom config overrides to `init` function:
74
+ You can pass any number of arbitrary custom config overrides to `defineConfig` function:
75
75
 
76
76
  ```js
77
- import { init } from '@fullstacksjs/eslint-config';
77
+ import { defineConfig } from '@fullstacksjs/eslint-config';
78
78
 
79
- export default init(
79
+ export default defineConfig(
80
80
  {
81
81
  typescript: true,
82
82
  // You can pass extends here
@@ -93,6 +93,12 @@ export default init(
93
93
  })
94
94
  ```
95
95
 
96
+ ## Next.JS Warning
97
+
98
+ **Question**: I'm getting "The Next.js plugin was not detected in your ESLint" warning.
99
+
100
+ **Answer**: This plugin has built-in support for Next.js. The warning from Next.js is misleading—Next.js simply checks `package.json` to see if the plugin is listed. You can safely ignore the warning or update your lint script from `next lint` to `eslint`.
101
+
96
102
  ## Speed Optimization!
97
103
 
98
104
  Balancing the benefits of linting rules against their performance impact is crucial. Below is a table highlighting the most resource-intensive linting rules encountered in a real-world React project:
@@ -110,20 +116,20 @@ To conditionally disable expensive linting rules, you can modify your configurat
110
116
 
111
117
  List of `expensiveRules` to be affected:
112
118
 
113
- ```
119
+ ```sh
114
120
  @typescript-eslint/no-floating-promises
115
121
  @typescript-eslint/no-misused-promises
116
- import/default
117
- import/export
118
- import/named
122
+ import/default # (disabled in TS env)
123
+ import/export # (disabled in TS env)
124
+ import/named # (disabled in TS env)
125
+ import/no-named-as-default-member # (disabled in TS env)
119
126
  import/namespace
120
127
  import/no-cycle
121
128
  import/no-deprecated
122
- import/no-named-as-default-member
123
129
  ```
124
130
 
125
131
  ```js
126
- export default init({
132
+ export default defineConfig({
127
133
  disableExpensiveRules: !process.env.CI || !process.env.HUSKY // Or anywhere you want
128
134
  prettier: false // So you should run the formatter explicitly.
129
135
  });
@@ -131,49 +137,22 @@ export default init({
131
137
 
132
138
  ## Migration Guide
133
139
 
134
- ### To v11
135
-
136
- v11 drops support for ESLint v8 configuration and only ESLint v9 is supported, which means you should migrate to [ESlint Flat Config](https://eslint.org/docs/latest/extend/plugin-migration-flat-config):
137
-
138
- 1. Move your configs to `eslint.config.js` file.
139
- 2. Use init API.
140
- ```diff
141
- -const { init } = require('@fullstacksjs/eslint-config/init');
142
- +import { init } from '@fullstacksjs/eslint-config';
143
-
144
- -module.exports = init({
145
- - modules: {
146
- - auto: true,
147
- - esm: true,
148
- - typescript: {
149
- - parserProject: ['./tsconfig.eslint.json'],
150
- - resolverProject: ['./tsconfig.json'],
151
- - },
152
- - },
153
- - // your configuration
154
- -});
155
- +export default init({
156
- + esm: true,
157
- + typescript: true,
158
- + },
159
- + // your configuration
160
- +);
161
- ```
140
+ [See Migration Guide](./MIGRATION.md)
162
141
 
163
142
  ## What's included?
164
143
 
165
144
  * [@eslint-react/eslint-plugin](https://eslint-react.xyz/)
166
- * [@next/eslint-config-next](https://nextjs.org/docs/basic-features/eslint#eslint-plugin)
145
+ * [@next/eslint-plugin-next](https://nextjs.org/docs/basic-features/eslint#eslint-plugin)
146
+ * [@stylistic/eslint-plugin](https://eslint.style/packages/default)
167
147
  * [eslint-plugin-cypress](https://github.com/cypress-io/eslint-plugin-cypress)
168
148
  * [eslint-plugin-import-x](https://github.com/un-ts/eslint-plugin-import-x)
169
149
  * [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest)
170
150
  * [eslint-plugin-jest-formatting](https://github.com/dangreenisrael/eslint-plugin-jest-formatting)
171
151
  * [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y)
172
- * [eslint-plugin-perfectionist](https://perfectionist.dev/)
173
152
  * [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n)
153
+ * [eslint-plugin-perfectionist](https://perfectionist.dev/)
174
154
  * [eslint-plugin-playwright](https://github.com/playwright-community/eslint-plugin-playwright)
175
155
  * [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier)
176
- * [eslint-plugin-perfectionist](https://perfectionist.dev/)
177
156
  * [eslint-plugin-promise](https://github.com/eslint-community/eslint-plugin-promise)
178
157
  * [eslint-plugin-react-hooks](https://www.npmjs.com/package/eslint-plugin-react-hooks)
179
158
  * [eslint-plugin-storybook](https://github.com/storybookjs/eslint-plugin-storybook#readme)
package/cjs/index.js CHANGED
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.init = init;
6
+ exports.defineConfig = defineConfig;
7
+ exports.init = void 0;
7
8
  var _deepmerge = _interopRequireDefault(require("deepmerge"));
8
9
  var _config = require("eslint/config");
9
10
  var _localPkg = require("local-pkg");
@@ -62,7 +63,7 @@ const defaultOptions = {
62
63
  * @param {...Config} extend
63
64
  * @returns {Config[]}
64
65
  */
65
- function init(initOptions = {}, ...extend) {
66
+ function defineConfig(initOptions = {}, ...extend) {
66
67
  const options = (0, _deepmerge.default)(defaultOptions, initOptions);
67
68
  if (options.tailwind === true) {
68
69
  options.tailwind = {};
@@ -113,3 +114,6 @@ function init(initOptions = {}, ...extend) {
113
114
  if (extend) Array.prototype.push.apply(rules, extend);
114
115
  return (0, _config.defineConfig)(rules);
115
116
  }
117
+
118
+ /** @deprecated Please use `defineConfig` from `@fullstacksjs/eslint-config` instead, this function will be removed in the next major release */
119
+ const init = exports.init = defineConfig;
@@ -17,20 +17,6 @@ const allExtensions = [...jsExtensions, ...tsExtensions];
17
17
  */
18
18
  function imports(options = {}) {
19
19
  const isObject = typeof options.import === 'object';
20
- const opt = options.esm ? 'always' : 'never';
21
- const extensionOptions = {
22
- ignorePackages: true,
23
- js: opt,
24
- jsx: opt,
25
- mjs: opt,
26
- cjs: opt,
27
- ...(options.typescript && {
28
- ts: opt,
29
- tsx: opt,
30
- mts: opt,
31
- cts: opt
32
- })
33
- };
34
20
  const config = {
35
21
  plugins: {
36
22
  import: _eslintPluginImportX.default
@@ -55,7 +41,7 @@ function imports(options = {}) {
55
41
  },
56
42
  rules: {
57
43
  'import/consistent-type-specifier-style': ['warn', 'prefer-top-level'],
58
- // 'import/extensions': ['error', 'ignorePackages', extensionOptions], FIXME: This rule is broken!
44
+ // 'import/extensions': ['error', 'ignorePackages', ignorePackages: true, js: opt, jsx: opt, mjs: opt, cjs: opt, ...(options.typescript && { ts: opt, tsx: opt, mts: opt, cts: opt, }), ], FIXME: This rule is broken!
59
45
  'import/first': 'error',
60
46
  'import/newline-after-import': 'warn',
61
47
  'import/no-absolute-path': 'error',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fullstacksjs/eslint-config",
3
- "version": "11.8.1",
3
+ "version": "11.9.0",
4
4
  "license": "MIT",
5
5
  "author": "fullstacks <fullstacksjs@gmail.com>",
6
6
  "description": "fullstacks eslint config",
package/src/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import merge from 'deepmerge';
2
- import { defineConfig } from 'eslint/config';
2
+ import { defineConfig as eslintConfig } from 'eslint/config';
3
3
  import { isPackageExists } from 'local-pkg';
4
4
 
5
5
  import base from './modules/base.mjs';
@@ -55,7 +55,7 @@ const defaultOptions = {
55
55
  * @param {...Config} extend
56
56
  * @returns {Config[]}
57
57
  */
58
- export function init(initOptions = {}, ...extend) {
58
+ export function defineConfig(initOptions = {}, ...extend) {
59
59
  const options = merge(defaultOptions, initOptions);
60
60
 
61
61
  if (options.tailwind === true) {
@@ -110,5 +110,8 @@ export function init(initOptions = {}, ...extend) {
110
110
  if (Object.keys(eslintOptions).length > 0) rules.push(eslintOptions);
111
111
  if (extend) Array.prototype.push.apply(rules, extend);
112
112
 
113
- return defineConfig(rules);
113
+ return eslintConfig(rules);
114
114
  }
115
+
116
+ /** @deprecated Please use `defineConfig` from `@fullstacksjs/eslint-config` instead, this function will be removed in the next major release */
117
+ export const init = defineConfig;
@@ -12,20 +12,6 @@ const allExtensions = [...jsExtensions, ...tsExtensions];
12
12
  */
13
13
  function imports(options = {}) {
14
14
  const isObject = typeof options.import === 'object';
15
- const opt = options.esm ? 'always' : 'never';
16
- const extensionOptions = {
17
- ignorePackages: true,
18
- js: opt,
19
- jsx: opt,
20
- mjs: opt,
21
- cjs: opt,
22
- ...(options.typescript && {
23
- ts: opt,
24
- tsx: opt,
25
- mts: opt,
26
- cts: opt,
27
- }),
28
- };
29
15
 
30
16
  const config = {
31
17
  plugins: { import: plugin },
@@ -46,7 +32,7 @@ function imports(options = {}) {
46
32
 
47
33
  rules: {
48
34
  'import/consistent-type-specifier-style': ['warn', 'prefer-top-level'],
49
- // 'import/extensions': ['error', 'ignorePackages', extensionOptions], FIXME: This rule is broken!
35
+ // 'import/extensions': ['error', 'ignorePackages', ignorePackages: true, js: opt, jsx: opt, mjs: opt, cjs: opt, ...(options.typescript && { ts: opt, tsx: opt, mts: opt, cts: opt, }), ], FIXME: This rule is broken!
50
36
  'import/first': 'error',
51
37
  'import/newline-after-import': 'warn',
52
38
  'import/no-absolute-path': 'error',