@nice-move/eslint-config-base 0.11.34 → 0.12.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 +5 -14
- package/index.mjs +107 -0
- package/lib/base.mjs +191 -0
- package/lib/import.mjs +102 -0
- package/lib/markdown.mjs +44 -0
- package/lib/{mini.cjs → mini.mjs} +80 -70
- package/lib/node.mjs +67 -0
- package/lib/promise.mjs +12 -0
- package/lib/typescript.mjs +55 -0
- package/lib/unicorn.mjs +29 -0
- package/lib/utils.mjs +43 -0
- package/package.json +13 -13
- package/index.cjs +0 -71
- package/lib/base.cjs +0 -126
- package/lib/bundler.cjs +0 -26
- package/lib/electron.cjs +0 -31
- package/lib/import.cjs +0 -100
- package/lib/markdown.cjs +0 -36
- package/lib/node.cjs +0 -146
- package/lib/playwright.cjs +0 -19
- package/lib/promise.cjs +0 -10
- package/lib/test.cjs +0 -24
- package/lib/typescript.cjs +0 -51
- package/lib/unicorn.cjs +0 -27
- package/lib/utils.cjs +0 -34
package/README.md
CHANGED
|
@@ -21,15 +21,11 @@ npm install eslint @nice-move/eslint-config-base --save-dev
|
|
|
21
21
|
|
|
22
22
|
## Usage
|
|
23
23
|
|
|
24
|
-
Add to
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
// example:
|
|
28
|
-
{
|
|
29
|
-
"eslintConfig": {
|
|
30
|
-
"extends": "@nice-move/eslint-config-base"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
24
|
+
Add to eslint.config.mjs
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
// example: eslint.config.mjs
|
|
28
|
+
export { default } from '@nice-move/eslint-config-base';
|
|
33
29
|
```
|
|
34
30
|
|
|
35
31
|
Then run
|
|
@@ -40,17 +36,12 @@ eslint --fix .
|
|
|
40
36
|
|
|
41
37
|
## Specification
|
|
42
38
|
|
|
43
|
-
[ava]: https://github.com/avajs/ava
|
|
44
|
-
[webpack]: https://webpack.js.org/
|
|
45
|
-
|
|
46
39
|
| Environment | pattern |
|
|
47
40
|
| :---------- | :------------------------------------------------------------------------------------------- |
|
|
48
41
|
| browser | `.js`, `.html` |
|
|
49
42
|
| node.js | `.mjs`, `.mts`, `.cjs`, `.cts` |
|
|
50
43
|
| es modules | `.mjs`, `.mts`, `.js`, `.html` |
|
|
51
44
|
| commonjs | `.cjs`, source code in webpack project |
|
|
52
|
-
| [webpack] | `src/**`, `packages/*/**` |
|
|
53
|
-
| [ava] | `{test,tests,spec,specs}/**`, `**/*.{test,spec}.*` <br /> when `eslint-plugin-ava` installed |
|
|
54
45
|
|
|
55
46
|
## Tips
|
|
56
47
|
|
package/index.mjs
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { dirname } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
|
|
4
|
+
import { FlatCompat } from '@eslint/eslintrc';
|
|
5
|
+
import js from '@eslint/js';
|
|
6
|
+
import { recommended as html } from '@nice-move/eslint-plugin-html/lib/configs-next.mjs';
|
|
7
|
+
import airbnb from 'eslint-config-airbnb-base';
|
|
8
|
+
import prettier from 'eslint-config-prettier';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
import { getPkg, readJson } from 'settingz';
|
|
12
|
+
|
|
13
|
+
import base from './lib/base.mjs';
|
|
14
|
+
import imports from './lib/import.mjs';
|
|
15
|
+
import markdown from './lib/markdown.mjs';
|
|
16
|
+
import mini from './lib/mini.mjs';
|
|
17
|
+
import node from './lib/node.mjs';
|
|
18
|
+
import promise from './lib/promise.mjs';
|
|
19
|
+
import typescript from './lib/typescript.mjs';
|
|
20
|
+
import unicorn from './lib/unicorn.mjs';
|
|
21
|
+
import { pkgHas } from './lib/utils.mjs';
|
|
22
|
+
|
|
23
|
+
function ignoreList() {
|
|
24
|
+
const { ignore: { all = [], eslint = [] } = {} } = getPkg('nice-move');
|
|
25
|
+
|
|
26
|
+
return [...all, ...eslint];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function BestShot() {
|
|
30
|
+
const { git = [], eslint = git } = readJson(
|
|
31
|
+
'@best-shot/cli/config/ignore.json',
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return eslint;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
38
|
+
const __dirname = dirname(__filename);
|
|
39
|
+
|
|
40
|
+
const compat = new FlatCompat({
|
|
41
|
+
baseDirectory: __dirname,
|
|
42
|
+
resolvePluginsRelativeTo: __dirname,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const old = compat.config(airbnb).map((item) => {
|
|
46
|
+
delete item.plugins;
|
|
47
|
+
return item;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export default [
|
|
51
|
+
js.configs.recommended,
|
|
52
|
+
...old,
|
|
53
|
+
...unicorn,
|
|
54
|
+
...promise,
|
|
55
|
+
...imports,
|
|
56
|
+
...base,
|
|
57
|
+
...pkgHas(
|
|
58
|
+
({ devDependencies: { electron } = {} }) => electron,
|
|
59
|
+
() => [
|
|
60
|
+
{
|
|
61
|
+
files: ['src/**'],
|
|
62
|
+
settings: {
|
|
63
|
+
'import/core-modules': ['electron'],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
),
|
|
68
|
+
...pkgHas(
|
|
69
|
+
({ peerDependencies: { '@playwright/test': playwright } = {} }) =>
|
|
70
|
+
playwright,
|
|
71
|
+
() => [
|
|
72
|
+
{
|
|
73
|
+
files: ['test/**'],
|
|
74
|
+
settings: {
|
|
75
|
+
'import/core-modules': ['@playwright/test'],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
),
|
|
80
|
+
...node,
|
|
81
|
+
...typescript,
|
|
82
|
+
...markdown,
|
|
83
|
+
...mini,
|
|
84
|
+
...html,
|
|
85
|
+
...compat.config(prettier),
|
|
86
|
+
{
|
|
87
|
+
linterOptions: {
|
|
88
|
+
noInlineConfig: false,
|
|
89
|
+
reportUnusedDisableDirectives: true,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
ignores: [
|
|
94
|
+
'.cache/',
|
|
95
|
+
'.git/',
|
|
96
|
+
'.svn/',
|
|
97
|
+
'*.min.*',
|
|
98
|
+
'**/.docusaurus/**',
|
|
99
|
+
'**/.obsidian/**',
|
|
100
|
+
'**/dist/**',
|
|
101
|
+
'**/miniprogram_npm/**',
|
|
102
|
+
'**/node_modules/**',
|
|
103
|
+
...BestShot(),
|
|
104
|
+
...ignoreList(),
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
];
|
package/lib/base.mjs
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import comments from '@eslint-community/eslint-plugin-eslint-comments/configs';
|
|
2
|
+
import * as regexpPlugin from 'eslint-plugin-regexp';
|
|
3
|
+
|
|
4
|
+
import { getGlobals } from './utils.mjs';
|
|
5
|
+
|
|
6
|
+
const all = ['**/*.{js,jsx,ts,tsx,mjs,mts,cjs,cts,qs,wxs,vue}'];
|
|
7
|
+
|
|
8
|
+
export default [
|
|
9
|
+
{
|
|
10
|
+
files: all,
|
|
11
|
+
...comments.recommended,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
files: all,
|
|
15
|
+
...regexpPlugin.configs['flat/recommended'],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
files: all,
|
|
19
|
+
rules: {
|
|
20
|
+
'lines-around-directive': 0,
|
|
21
|
+
'array-callback-return': [
|
|
22
|
+
'error',
|
|
23
|
+
{
|
|
24
|
+
allowImplicit: true,
|
|
25
|
+
checkForEach: true,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
'arrow-body-style': 0,
|
|
29
|
+
camelcase: 0,
|
|
30
|
+
'global-require': 0,
|
|
31
|
+
'class-methods-use-this': 'warn',
|
|
32
|
+
'consistent-return': 'warn',
|
|
33
|
+
'grouped-accessor-pairs': 0,
|
|
34
|
+
'lines-between-class-members': 0,
|
|
35
|
+
'max-classes-per-file': 0,
|
|
36
|
+
'no-await-in-loop': 0,
|
|
37
|
+
'no-console': 0,
|
|
38
|
+
'no-constant-binary-expression': 'error',
|
|
39
|
+
'no-constructor-return': 0,
|
|
40
|
+
'no-empty': [
|
|
41
|
+
'error',
|
|
42
|
+
{
|
|
43
|
+
allowEmptyCatch: true,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
'no-implicit-coercion': [
|
|
47
|
+
'warn',
|
|
48
|
+
{
|
|
49
|
+
disallowTemplateShorthand: true,
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
'no-nested-ternary': 0,
|
|
53
|
+
'no-restricted-exports': [
|
|
54
|
+
'error',
|
|
55
|
+
{
|
|
56
|
+
restrictedNamedExports: ['then', 'await'],
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
'no-param-reassign': [
|
|
60
|
+
'warn',
|
|
61
|
+
{
|
|
62
|
+
ignorePropertyModificationsFor: [],
|
|
63
|
+
props: true,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
'no-restricted-syntax': [
|
|
67
|
+
'error',
|
|
68
|
+
{
|
|
69
|
+
message:
|
|
70
|
+
'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
|
|
71
|
+
selector: 'ForInStatement',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
message:
|
|
75
|
+
'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
|
|
76
|
+
selector: 'LabeledStatement',
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
'no-plusplus': 0,
|
|
80
|
+
'no-template-curly-in-string': 0,
|
|
81
|
+
'no-undef-init': 0,
|
|
82
|
+
'no-underscore-dangle': 0,
|
|
83
|
+
'no-unreachable-loop': 0,
|
|
84
|
+
'no-unused-expressions': [
|
|
85
|
+
'error',
|
|
86
|
+
{
|
|
87
|
+
allowTaggedTemplates: true,
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
'no-unused-vars': [
|
|
91
|
+
'error',
|
|
92
|
+
{
|
|
93
|
+
argsIgnorePattern: '^_+$',
|
|
94
|
+
varsIgnorePattern: '^_+$',
|
|
95
|
+
ignoreRestSiblings: true,
|
|
96
|
+
reportUsedIgnorePattern: true,
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
'no-useless-rename': 0,
|
|
100
|
+
'object-shorthand': 0,
|
|
101
|
+
'prefer-arrow-callback': 'warn',
|
|
102
|
+
'prefer-exponentiation-operator': 0,
|
|
103
|
+
'prefer-template': 'warn',
|
|
104
|
+
'spaced-comment': 0,
|
|
105
|
+
'@eslint-community/eslint-comments/no-unused-enable': 'warn',
|
|
106
|
+
'@eslint-community/eslint-comments/disable-enable-pair': 0,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
files: ['**/*.{js,jsx,ts,tsx,mjs,mts,cjs,cts,vue}'],
|
|
111
|
+
languageOptions: {
|
|
112
|
+
ecmaVersion: 'latest',
|
|
113
|
+
globals: {
|
|
114
|
+
...getGlobals({ es2025: true }),
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
files: ['**/*.js', '**/*.ts', '**/*.jsx', '**/*.tsx'],
|
|
120
|
+
languageOptions: {
|
|
121
|
+
sourceType: 'module',
|
|
122
|
+
globals: {
|
|
123
|
+
...getGlobals({ es2025: true, browser: true }),
|
|
124
|
+
},
|
|
125
|
+
parserOptions: {
|
|
126
|
+
ecmaFeatures: {
|
|
127
|
+
impliedStrict: true,
|
|
128
|
+
globalReturn: false,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
files: ['**/*.js', '**/*.ts'],
|
|
135
|
+
languageOptions: {
|
|
136
|
+
parserOptions: {
|
|
137
|
+
ecmaFeatures: {
|
|
138
|
+
jsx: false,
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
files: ['**/*.jsx', '**/*.tsx'],
|
|
145
|
+
languageOptions: {
|
|
146
|
+
parserOptions: {
|
|
147
|
+
ecmaFeatures: {
|
|
148
|
+
jsx: true,
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
files: ['**/*.mjs', '**/*.mts', '**/*.cts'],
|
|
155
|
+
languageOptions: {
|
|
156
|
+
globals: {
|
|
157
|
+
...getGlobals({ es2025: true, node: true }),
|
|
158
|
+
},
|
|
159
|
+
sourceType: 'module',
|
|
160
|
+
parserOptions: {
|
|
161
|
+
ecmaFeatures: {
|
|
162
|
+
impliedStrict: true,
|
|
163
|
+
jsx: false,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
files: ['**/*.{cjs,cts}'],
|
|
170
|
+
languageOptions: {
|
|
171
|
+
globals: {
|
|
172
|
+
...getGlobals({ es2025: true, commonjs: true, node: true }),
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
rules: {
|
|
176
|
+
strict: ['error', 'global'],
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
files: ['**/*.cjs'],
|
|
181
|
+
languageOptions: {
|
|
182
|
+
sourceType: 'commonjs',
|
|
183
|
+
parserOptions: {
|
|
184
|
+
ecmaFeatures: {
|
|
185
|
+
jsx: false,
|
|
186
|
+
impliedStrict: false,
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
];
|
package/lib/import.mjs
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
|
|
3
|
+
import imports from 'eslint-plugin-import';
|
|
4
|
+
|
|
5
|
+
import { configHas, pkgHas } from './utils.mjs';
|
|
6
|
+
|
|
7
|
+
const Vscode = pkgHas(
|
|
8
|
+
({ engines: { vscode } = {} }) => vscode,
|
|
9
|
+
() => ({ 'import/core-modules': ['vscode'] }),
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export default [
|
|
13
|
+
imports.flatConfigs.recommended,
|
|
14
|
+
{
|
|
15
|
+
files: ['**/*.{js,jsx,ts,tsx,cjs,mjs,cts,mts}'],
|
|
16
|
+
ignores: [
|
|
17
|
+
'*.config.{m,c}{j,t}s',
|
|
18
|
+
'.config/**/.{m,c}{j,t}s',
|
|
19
|
+
'config/**/.{m,c}{j,t}s',
|
|
20
|
+
'**/*.md/*',
|
|
21
|
+
],
|
|
22
|
+
rules: {
|
|
23
|
+
'import/no-default-export': 'warn',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
files: ['**/*.{js,jsx,ts,tsx,cjs,mjs,cts,mts,qs,wxs,vue}'],
|
|
28
|
+
rules: {
|
|
29
|
+
'import/extensions': [
|
|
30
|
+
'error',
|
|
31
|
+
'always',
|
|
32
|
+
{
|
|
33
|
+
ignorePackages: true,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
'import/no-extraneous-dependencies': [
|
|
37
|
+
'error',
|
|
38
|
+
{
|
|
39
|
+
devDependencies: [
|
|
40
|
+
'**/*.{test,spec}.{m,c,}{t,j}s',
|
|
41
|
+
'{test,tests,try}.{m,c,}{t,j}s',
|
|
42
|
+
'{test,tests,config}/**/*.{m,c,}{t,j}s',
|
|
43
|
+
'**/.*rc.{m,c,}{t,j}s',
|
|
44
|
+
'**/*.config.{m,c,}{t,j}s',
|
|
45
|
+
'**/config.{m,c,}{t,j}s',
|
|
46
|
+
'.*/config.{m,c,}{t,j}s',
|
|
47
|
+
'**/.best-shot/**',
|
|
48
|
+
...(configHas(
|
|
49
|
+
({ bundle = [] }) => bundle,
|
|
50
|
+
(bundle) => bundle,
|
|
51
|
+
) || []),
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
'import/newline-after-import': 0,
|
|
56
|
+
'import/no-dynamic-require': 0,
|
|
57
|
+
'import/no-empty-named-blocks': 'error',
|
|
58
|
+
'import/no-relative-packages': 0,
|
|
59
|
+
'import/order': 0,
|
|
60
|
+
'import/prefer-default-export': 0,
|
|
61
|
+
'import/no-cycle': 0,
|
|
62
|
+
},
|
|
63
|
+
settings: {
|
|
64
|
+
...Vscode,
|
|
65
|
+
'import/extensions': [
|
|
66
|
+
'.tsx',
|
|
67
|
+
'.ts',
|
|
68
|
+
'.cts',
|
|
69
|
+
'.mts',
|
|
70
|
+
'.vue',
|
|
71
|
+
'.jsx',
|
|
72
|
+
'.js',
|
|
73
|
+
'.mjs',
|
|
74
|
+
'.cjs',
|
|
75
|
+
],
|
|
76
|
+
'import/parsers': {
|
|
77
|
+
'@typescript-eslint/parser': ['.ts', '.cts', '.mts', '.tsx'],
|
|
78
|
+
'vue-eslint-parser': ['.vue'],
|
|
79
|
+
[fileURLToPath(import.meta.resolve('./jsx-parser.cjs'))]: ['.jsx'],
|
|
80
|
+
},
|
|
81
|
+
'import/ignore': false,
|
|
82
|
+
...configHas(
|
|
83
|
+
({ 'internal-regex': internalRegex }) => internalRegex,
|
|
84
|
+
(internalRegex) => ({ 'import/internal-regex': internalRegex }),
|
|
85
|
+
),
|
|
86
|
+
'import/resolver': {
|
|
87
|
+
node: false,
|
|
88
|
+
[fileURLToPath(import.meta.resolve('./node-next-resolver.cjs'))]:
|
|
89
|
+
configHas(
|
|
90
|
+
({ 'import-http': importHttp }) => importHttp,
|
|
91
|
+
(importHttp) => ({ importHttp }),
|
|
92
|
+
) || {},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
files: ['**/*.{js,jsx,ts,tsx,vue,qs,wxs}'],
|
|
98
|
+
rules: {
|
|
99
|
+
'import/no-nodejs-modules': 'error',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
];
|
package/lib/markdown.mjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import markdown from 'eslint-plugin-markdown';
|
|
2
|
+
|
|
3
|
+
import { getGlobals } from './utils.mjs';
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
{
|
|
7
|
+
files: ['**/*.md'],
|
|
8
|
+
name: 'markdown/recommended/plugin',
|
|
9
|
+
plugins: {
|
|
10
|
+
markdown,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'markdown/recommended/processor',
|
|
15
|
+
files: ['**/*.md'],
|
|
16
|
+
processor: 'markdown/markdown',
|
|
17
|
+
languageOptions: {
|
|
18
|
+
ecmaVersion: 'latest',
|
|
19
|
+
globals: {
|
|
20
|
+
...getGlobals(),
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
files: ['**/*.md/**'],
|
|
26
|
+
// plugins: {
|
|
27
|
+
// markdown,
|
|
28
|
+
// },
|
|
29
|
+
rules: {
|
|
30
|
+
strict: 'off',
|
|
31
|
+
'eol-last': 'off',
|
|
32
|
+
'no-undef': 'off',
|
|
33
|
+
'no-unused-expressions': 'off',
|
|
34
|
+
'no-unused-vars': 'off',
|
|
35
|
+
'unicode-bom': 'off',
|
|
36
|
+
'import/no-extraneous-dependencies': 'off',
|
|
37
|
+
'import/no-unresolved': 'off',
|
|
38
|
+
'unicorn/filename-case': 'off',
|
|
39
|
+
'unicorn/custom-error-definition': 'off',
|
|
40
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
41
|
+
'@typescript-eslint/no-extraneous-class': 'off',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const { reaching } = require('settingz');
|
|
1
|
+
import { relative } from 'node:path';
|
|
2
|
+
import { reaching } from 'settingz';
|
|
3
|
+
import { getGlobals } from './utils.mjs';
|
|
5
4
|
|
|
6
5
|
const cwd = process.cwd();
|
|
7
6
|
|
|
@@ -28,69 +27,71 @@ function generate({
|
|
|
28
27
|
.filter(Boolean)
|
|
29
28
|
.map((item) => relativeToCWD(item));
|
|
30
29
|
|
|
31
|
-
const
|
|
30
|
+
const ignores = ['**/*.wxs', '**/*.qs'];
|
|
32
31
|
|
|
33
32
|
const cloudMatcher = cloudfunctionRoot
|
|
34
33
|
? matcher([relativeToCWD(cloudfunctionRoot)], '**')
|
|
35
34
|
: undefined;
|
|
36
35
|
|
|
37
|
-
const globals = {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
36
|
+
// const globals = {
|
|
37
|
+
// clearInterval: 'readonly',
|
|
38
|
+
// clearTimeout: 'readonly',
|
|
39
|
+
// console: 'readonly',
|
|
40
|
+
// setInterval: 'readonly',
|
|
41
|
+
// setTimeout: 'readonly',
|
|
42
|
+
// };
|
|
44
43
|
|
|
45
44
|
return [
|
|
46
45
|
{
|
|
47
|
-
files: matcher(paths, '**'),
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
requirePlugin: 'readonly',
|
|
58
|
-
requireMiniProgram: 'readonly',
|
|
46
|
+
files: [matcher(paths, '**')],
|
|
47
|
+
ignores,
|
|
48
|
+
languageOptions: {
|
|
49
|
+
globals: {
|
|
50
|
+
wx: 'readonly',
|
|
51
|
+
getApp: 'readonly',
|
|
52
|
+
getCurrentPages: 'readonly',
|
|
53
|
+
requirePlugin: 'readonly',
|
|
54
|
+
requireMiniProgram: 'readonly',
|
|
55
|
+
},
|
|
59
56
|
},
|
|
60
57
|
},
|
|
61
58
|
{
|
|
62
|
-
files: matcher(paths, 'component{,s}/**'),
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
files: [matcher(paths, 'component{,s}/**')],
|
|
60
|
+
ignores,
|
|
61
|
+
languageOptions: {
|
|
62
|
+
globals: {
|
|
63
|
+
Component: 'readonly',
|
|
64
|
+
Behavior: 'readonly',
|
|
65
|
+
},
|
|
67
66
|
},
|
|
68
67
|
},
|
|
69
68
|
{
|
|
70
|
-
files: matcher(paths, 'page{,s}/**'),
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
files: [matcher(paths, 'page{,s}/**')],
|
|
70
|
+
ignores,
|
|
71
|
+
languageOptions: {
|
|
72
|
+
globals: {
|
|
73
|
+
Behavior: 'readonly',
|
|
74
|
+
Component: 'readonly',
|
|
75
|
+
Page: 'readonly',
|
|
76
|
+
},
|
|
76
77
|
},
|
|
77
78
|
},
|
|
78
79
|
{
|
|
79
|
-
files: matcher(paths, 'app.js'),
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
files: [matcher(paths, 'app.js')],
|
|
81
|
+
languageOptions: {
|
|
82
|
+
globals: {
|
|
83
|
+
App: 'readonly',
|
|
84
|
+
},
|
|
82
85
|
},
|
|
83
86
|
},
|
|
84
87
|
cloudMatcher
|
|
85
88
|
? {
|
|
86
89
|
files: [cloudMatcher],
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
require: 'readonly',
|
|
93
|
-
exports: 'readonly',
|
|
90
|
+
languageOptions: {
|
|
91
|
+
globals: {
|
|
92
|
+
require: 'readonly',
|
|
93
|
+
exports: 'readonly',
|
|
94
|
+
},
|
|
94
95
|
},
|
|
95
96
|
rules: {
|
|
96
97
|
'import/no-commonjs': 'off',
|
|
@@ -99,29 +100,40 @@ function generate({
|
|
|
99
100
|
}
|
|
100
101
|
: undefined,
|
|
101
102
|
{
|
|
102
|
-
files:
|
|
103
|
-
|
|
104
|
-
browser: false,
|
|
105
|
-
es2023: false,
|
|
106
|
-
es2022: false,
|
|
107
|
-
es2021: false,
|
|
108
|
-
es2020: false,
|
|
109
|
-
es2019: false,
|
|
110
|
-
es2018: false,
|
|
111
|
-
es2017: false,
|
|
112
|
-
es2016: false,
|
|
113
|
-
es6: false,
|
|
114
|
-
node: false,
|
|
115
|
-
},
|
|
116
|
-
parserOptions: {
|
|
103
|
+
files: ignores,
|
|
104
|
+
languageOptions: {
|
|
117
105
|
ecmaVersion: 5,
|
|
118
|
-
sourceType: '
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
106
|
+
sourceType: 'commonjs',
|
|
107
|
+
globals: {
|
|
108
|
+
...getGlobals(),
|
|
109
|
+
Date: false,
|
|
110
|
+
decodeURI: false,
|
|
111
|
+
decodeURIComponent: false,
|
|
112
|
+
encodeURI: false,
|
|
113
|
+
encodeURIComponent: false,
|
|
114
|
+
getDate: false,
|
|
115
|
+
getRegExp: false,
|
|
116
|
+
Infinity: false,
|
|
117
|
+
isFinite: false,
|
|
118
|
+
isNaN: false,
|
|
119
|
+
JSON: false,
|
|
120
|
+
Math: false,
|
|
121
|
+
module: false,
|
|
122
|
+
NaN: false,
|
|
123
|
+
Number: false,
|
|
124
|
+
parseFloat: false,
|
|
125
|
+
parseInt: false,
|
|
126
|
+
require: false,
|
|
127
|
+
undefined: false,
|
|
128
|
+
},
|
|
129
|
+
parserOptions: {
|
|
130
|
+
ecmaFeatures: {
|
|
131
|
+
globalReturn: false,
|
|
132
|
+
impliedStrict: false,
|
|
133
|
+
jsx: false,
|
|
134
|
+
objectLiteralDuplicateProperties: false,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
125
137
|
},
|
|
126
138
|
rules: {
|
|
127
139
|
'import/no-commonjs': 0,
|
|
@@ -189,6 +201,4 @@ function generate({
|
|
|
189
201
|
].filter(Boolean);
|
|
190
202
|
}
|
|
191
203
|
|
|
192
|
-
|
|
193
|
-
overrides: config.appid ? generate(config) : [],
|
|
194
|
-
};
|
|
204
|
+
export default config.appid ? generate(config) : [];
|