@fullstacksjs/eslint-config 9.0.13 → 9.0.15
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 +48 -60
- package/cypress.js +1 -1
- package/esm.js +2 -2
- package/index.js +2 -3
- package/init.d.ts +15 -12
- package/init.js +20 -13
- package/jest.js +1 -1
- package/package.json +1 -1
- package/registerOpts.js +1 -1
- package/storybook.js +1 -1
package/README.md
CHANGED
|
@@ -40,93 +40,81 @@ $ npm install --save-dev @fullstacksjs/eslint-config eslint prettier
|
|
|
40
40
|
$ yarn add --dev @fullstacksjs/eslint-config eslint prettier
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
optional dependencies (if you need):
|
|
44
|
-
|
|
45
|
-
* react
|
|
46
|
-
* jest
|
|
47
|
-
* cypress
|
|
48
|
-
|
|
49
43
|
## Usage
|
|
50
44
|
|
|
51
|
-
|
|
45
|
+
## Method 1 (recommended)
|
|
52
46
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
```
|
|
47
|
+
Create `.eslintrc.js` file and init the configuration.
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
const { init } = require('@fullstacksjs/eslint-config/init');
|
|
58
51
|
|
|
59
|
-
|
|
52
|
+
module.exports = init({
|
|
53
|
+
modules: {
|
|
54
|
+
auto: true, // If you need auto module detection.
|
|
55
|
+
// Modules configuration. (optional)
|
|
56
|
+
},
|
|
57
|
+
// Your configurations
|
|
58
|
+
});
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
```
|
|
62
61
|
|
|
63
|
-
|
|
62
|
+
## Method 2
|
|
63
|
+
extend from `@fullstacksjs`:
|
|
64
64
|
|
|
65
65
|
```json
|
|
66
66
|
{
|
|
67
|
-
"extends": ["
|
|
67
|
+
"extends": ["@fullstacksjs"]
|
|
68
68
|
}
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
##
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
71
|
+
## 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.
|
|
73
|
+
|
|
74
|
+
## Modules API
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
interface Modules {
|
|
78
|
+
auto?: boolean; // Auto module detection
|
|
79
|
+
react?: 'next' | 'raw'; // controls react, react-hooks, jsx/a11y plugins
|
|
80
|
+
typescript?: { parserProject: string[] | string; resolverProject: string[] | string }; // controls typescript plugin
|
|
81
|
+
node?: boolean; // controls node plugin
|
|
82
|
+
strict?: boolean; // controls strict plugin
|
|
83
|
+
import?: boolean; // controls import plugin
|
|
84
|
+
esm?: boolean; // controls esm plugin
|
|
85
|
+
graphql?: boolean; // controls graphql plugin
|
|
86
|
+
test?: boolean; // controls jest/vitest plugin
|
|
87
|
+
cypress?: boolean; // controls cypress plugin
|
|
88
|
+
storybook?: boolean; // controls storybook plugin
|
|
87
89
|
}
|
|
88
90
|
```
|
|
89
91
|
|
|
90
|
-
##
|
|
92
|
+
## Typescript configuration
|
|
91
93
|
|
|
92
|
-
If you need more advanced
|
|
94
|
+
If you need more advanced typescript-eslint rule you need to specify `modules.typescript.resolverProject`.
|
|
93
95
|
|
|
94
96
|
```json
|
|
95
|
-
{
|
|
96
|
-
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
"parserOptions": {
|
|
101
|
-
"project": "<PATH_TO_TSCONFIG>"
|
|
102
|
-
}
|
|
103
|
-
}
|
|
97
|
+
module.exports = init({
|
|
98
|
+
modules: {
|
|
99
|
+
typescript: { resolverProject: "<PATH_TO_TSCONFIG>" }
|
|
100
|
+
},
|
|
101
|
+
});
|
|
104
102
|
```
|
|
105
103
|
|
|
106
104
|
## Graphql
|
|
107
105
|
|
|
108
|
-
To enable graphql module you need to
|
|
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).
|
|
109
107
|
|
|
110
108
|
Here is an example:
|
|
111
109
|
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
"@fullstacksjs/eslint-config/graphql"
|
|
119
|
-
],
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
```yaml
|
|
124
|
-
# .graphqlrc.yml
|
|
125
|
-
|
|
126
|
-
schema: 'path/to/schema'
|
|
110
|
+
```js
|
|
111
|
+
module.exports = init({
|
|
112
|
+
modules: {
|
|
113
|
+
graphql: true
|
|
114
|
+
},
|
|
115
|
+
});
|
|
127
116
|
```
|
|
128
117
|
|
|
129
|
-
|
|
130
118
|
## What's included?
|
|
131
119
|
|
|
132
120
|
* @typescript-eslint/eslint-plugin
|
package/cypress.js
CHANGED
|
@@ -6,7 +6,7 @@ const { exts } = require('./utils');
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
overrides: [
|
|
8
8
|
{
|
|
9
|
-
files: [`**/cypress/**/*.${exts}`, `**/*.cy
|
|
9
|
+
files: [`**/cypress/**/*.${exts}`, `**/*.cy.${exts}`],
|
|
10
10
|
plugins: ['jest', 'jest-formatting', 'cypress'],
|
|
11
11
|
env: {
|
|
12
12
|
'cypress/globals': true,
|
package/esm.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/** @type { import('eslint').Linter.Config } */
|
|
2
2
|
module.exports = {
|
|
3
3
|
rules: {
|
|
4
|
-
'import/extensions': ['error', { mjs: 'ignorePackages' }],
|
|
4
|
+
...(global.fullstacksjs?.import && { 'import/extensions': ['error', { mjs: 'ignorePackages' }] }),
|
|
5
5
|
},
|
|
6
6
|
overrides: [
|
|
7
7
|
{
|
|
8
8
|
files: ['*.ts', '*.tsx'],
|
|
9
9
|
rules: {
|
|
10
|
-
'import/no-unresolved': ['error', { ignore: ['.js$'], caseSensitiveStrict: true }],
|
|
10
|
+
...(global.fullstacksjs?.import && { 'import/no-unresolved': ['error', { ignore: ['.js$'], caseSensitiveStrict: true }] }),
|
|
11
11
|
},
|
|
12
12
|
},
|
|
13
13
|
],
|
package/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
require('./registerOpts');
|
|
2
|
-
const { compact } = require('@fullstacksjs/toolbox');
|
|
3
2
|
|
|
4
3
|
/** @type { import('eslint').Linter.Config } */
|
|
5
4
|
module.exports = {
|
|
6
|
-
extends:
|
|
5
|
+
extends: [
|
|
7
6
|
require.resolve('./base'),
|
|
8
7
|
require.resolve('./fp'),
|
|
9
8
|
require.resolve('./import'),
|
|
@@ -15,5 +14,5 @@ module.exports = {
|
|
|
15
14
|
global.fullstacksjs?.typescript && require.resolve('./typescript'),
|
|
16
15
|
global.fullstacksjs?.cypress && require.resolve('./cypress'),
|
|
17
16
|
require.resolve('./prettier'),
|
|
18
|
-
]),
|
|
17
|
+
].filter(Boolean),
|
|
19
18
|
};
|
package/init.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
type Config = import('eslint').Linter.Config;
|
|
2
|
+
export interface Options extends Config {
|
|
3
|
+
modules: {
|
|
4
|
+
auto?: boolean;
|
|
5
|
+
react?: 'next' | 'raw';
|
|
6
|
+
typescript?: { parserProject: string[] | string; resolverProject: string[] | string };
|
|
7
|
+
node?: boolean;
|
|
8
|
+
strict?: boolean;
|
|
9
|
+
import?: boolean;
|
|
10
|
+
esm?: boolean;
|
|
11
|
+
graphql?: boolean;
|
|
12
|
+
test?: boolean;
|
|
13
|
+
cypress?: boolean;
|
|
14
|
+
storybook?: boolean;
|
|
15
|
+
};
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
export declare const init: (opts: Options) => import('eslint').Linter.Config;
|
package/init.js
CHANGED
|
@@ -1,37 +1,44 @@
|
|
|
1
|
-
require('./registerOpts');
|
|
2
|
-
const { compact } = require('@fullstacksjs/toolbox');
|
|
3
1
|
const merge = require('deepmerge');
|
|
4
2
|
|
|
5
3
|
/** @param { import('./init.d').Options } opts */
|
|
4
|
+
// eslint-disable-next-line complexity
|
|
6
5
|
function init(opts = {}) {
|
|
7
|
-
const { extends:
|
|
8
|
-
|
|
6
|
+
const { modules = {}, extends: extraExtends = [], ...eslintConfig } = opts;
|
|
7
|
+
if (modules.auto) {
|
|
8
|
+
require('./registerOpts');
|
|
9
|
+
global.fullstacksjs = merge(global.fullstacksjs, modules);
|
|
10
|
+
} else {
|
|
11
|
+
global.fullstacksjs = modules;
|
|
12
|
+
}
|
|
13
|
+
opts = global.fullstacksjs;
|
|
9
14
|
|
|
10
15
|
/** @type { import('eslint').Linter.Config } */
|
|
11
16
|
const config = {
|
|
12
|
-
extends:
|
|
17
|
+
extends: [
|
|
13
18
|
require.resolve('./base'),
|
|
14
19
|
require.resolve('./promise'),
|
|
15
20
|
require.resolve('./fp'),
|
|
16
21
|
opts.node && require.resolve('./node'),
|
|
17
|
-
opts.cypress && require.resolve('./cypress'),
|
|
18
|
-
opts.test && require.resolve('./jest'),
|
|
19
22
|
opts.graphql && require.resolve('./graphql'),
|
|
20
|
-
opts.
|
|
21
|
-
opts.importModule && require.resolve('./import'),
|
|
23
|
+
opts.import && require.resolve('./import'),
|
|
22
24
|
opts.typescript && require.resolve('./typescript'),
|
|
25
|
+
opts.storybook && require.resolve('./storybook'),
|
|
26
|
+
opts.cypress && require.resolve('./cypress'),
|
|
27
|
+
opts.test && require.resolve('./jest'),
|
|
23
28
|
opts.esm && require.resolve('./esm'),
|
|
24
29
|
opts.strict && require.resolve('./strict'),
|
|
25
30
|
require.resolve('./prettier'),
|
|
26
|
-
...
|
|
27
|
-
]),
|
|
28
|
-
|
|
31
|
+
...extraExtends,
|
|
32
|
+
].filter(Boolean),
|
|
33
|
+
parserOptions: {},
|
|
34
|
+
settings: {},
|
|
35
|
+
...eslintConfig,
|
|
29
36
|
};
|
|
30
37
|
|
|
31
38
|
if (opts.react === 'raw') config.extends.push(require.resolve('./react.js'));
|
|
32
39
|
|
|
33
40
|
if (opts.typescript?.parserProject) {
|
|
34
|
-
config.parserOptions = merge({
|
|
41
|
+
config.parserOptions = merge(config.parserOptions, {
|
|
35
42
|
project: opts.typescript.parserProject,
|
|
36
43
|
});
|
|
37
44
|
}
|
package/jest.js
CHANGED
|
@@ -68,7 +68,7 @@ module.exports = {
|
|
|
68
68
|
'jest/no-deprecated-functions': 'error',
|
|
69
69
|
}),
|
|
70
70
|
|
|
71
|
-
...(global.fullstacksjs?.typescript && {
|
|
71
|
+
...(global.fullstacksjs?.typescript?.resolverProject && {
|
|
72
72
|
'@typescript-eslint/unbound-method': 'off',
|
|
73
73
|
'jest/unbound-method': 'error',
|
|
74
74
|
'jest/no-untyped-mock-factory': 'warn',
|
package/package.json
CHANGED
package/registerOpts.js
CHANGED
|
@@ -6,7 +6,7 @@ const defaultOptions = {
|
|
|
6
6
|
cypress: hasDep('cypress'),
|
|
7
7
|
graphql: hasDep('graphql'),
|
|
8
8
|
react: hasDep('react') && !hasDep('next'),
|
|
9
|
-
storybook: hasDep('storybook'),
|
|
9
|
+
storybook: hasDep('@storybook/react'),
|
|
10
10
|
test: hasDep('jest') || hasDep('vitest'),
|
|
11
11
|
typescript: hasDep('typescript'),
|
|
12
12
|
import: true,
|
package/storybook.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
module.exports = {
|
|
3
3
|
overrides: [
|
|
4
4
|
{
|
|
5
|
+
files: ['**/*.stories.+(ts|tsx|js|jsx|mjs|cjs|mdx)', '**/*.story.+(ts|tsx|js|jsx|mjs|cjs|mdx)'],
|
|
5
6
|
plugins: ['storybook'],
|
|
6
|
-
files: ['*.stories.+(ts|tsx|js|jsx|mjs|cjs|mdx)', '*.story.+(ts|tsx|js|jsx|mjs|cjs|mdx)'],
|
|
7
7
|
rules: {
|
|
8
8
|
'storybook/await-interactions': 'error',
|
|
9
9
|
'storybook/context-in-play-function': 'error',
|