@nice-move/eslint-config-base 0.11.35 → 0.12.1

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/lib/node.mjs ADDED
@@ -0,0 +1,67 @@
1
+ import nodePlugin from 'eslint-plugin-n';
2
+
3
+ function pick({ rules, plugins }) {
4
+ return { rules, plugins };
5
+ }
6
+
7
+ export default [
8
+ {
9
+ files: ['**/*.{js,jsx,ts,tsx,mjs,mts,cts,vue}'],
10
+ ...pick(nodePlugin.configs['flat/recommended-module']),
11
+ },
12
+ {
13
+ files: ['**/*.{cjs,qs,wxs}'],
14
+ ...pick(nodePlugin.configs['flat/recommended-script']),
15
+ },
16
+ {
17
+ files: ['**/*.{js,jsx,ts,tsx,vue,qs,wxs}'],
18
+ rules: {
19
+ 'n/hashbang': 'error',
20
+ 'n/no-process-env': 'error',
21
+ },
22
+ },
23
+ {
24
+ files: ['**/*.{js,jsx,ts,tsx,mjs,mts,cjs,cts,vue,qs,wxs}'],
25
+ rules: {
26
+ 'n/no-path-concat': 'error',
27
+ },
28
+ },
29
+ {
30
+ files: ['**/*.{js,jsx,ts,tsx,mjs,mts,vue}'],
31
+ rules: {
32
+ 'import/no-commonjs': 'error',
33
+ },
34
+ },
35
+ {
36
+ files: ['**/*.{m,c}{t,j}s'],
37
+ rules: {
38
+ 'n/no-deprecated-api': 'error',
39
+ 'n/no-process-env': 'off',
40
+ 'n/no-process-exit': 'warn',
41
+ 'n/no-unsupported-features/es-builtins': 'error',
42
+ 'n/no-unsupported-features/es-syntax': 'error',
43
+ 'n/no-unsupported-features/node-builtins': 'error',
44
+ 'n/prefer-global/buffer': 'warn',
45
+ 'n/prefer-global/console': 'warn',
46
+ 'n/prefer-global/process': 'warn',
47
+ 'n/prefer-global/url-search-params': 'warn',
48
+ 'n/prefer-global/url': 'warn',
49
+ 'n/process-exit-as-throw': 'error',
50
+ },
51
+ },
52
+ {
53
+ files: ['**/*.{js,jsx,ts,tsx,cts,mjs,mts,vue}'],
54
+ ignores: ['**/*.md/*'],
55
+ rules: {
56
+ 'n/file-extension-in-import': 'error',
57
+ },
58
+ },
59
+ {
60
+ files: ['**/*.{cjs,cts}'],
61
+ rules: {
62
+ 'n/no-exports-assign': 'error',
63
+ 'n/no-new-require': 'error',
64
+ 'unicorn/prefer-module': 'off',
65
+ },
66
+ },
67
+ ];
@@ -0,0 +1,12 @@
1
+ import pluginPromise from 'eslint-plugin-promise';
2
+
3
+ export default [
4
+ pluginPromise.configs['flat/recommended'],
5
+ {
6
+ rules: {
7
+ 'promise/always-return': 'off',
8
+ 'promise/catch-or-return': ['warn', { allowFinally: true }],
9
+ 'promise/no-callback-in-promise': 'off',
10
+ },
11
+ },
12
+ ];
@@ -0,0 +1,55 @@
1
+ import tseslint from 'typescript-eslint';
2
+
3
+ const match = ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'];
4
+
5
+ export default [
6
+ ...tseslint.configs.strict.map((config) => ({
7
+ ...config,
8
+ files: match,
9
+ })),
10
+ {
11
+ files: match,
12
+ // extends: [
13
+ // 'airbnb-typescript',
14
+ // ],
15
+ rules: {
16
+ '@typescript-eslint/no-array-constructor': 'error',
17
+ '@typescript-eslint/no-duplicate-enum-values': 'error',
18
+ '@typescript-eslint/no-dynamic-delete': 'error',
19
+ '@typescript-eslint/no-extra-non-null-assertion': 'error',
20
+ '@typescript-eslint/no-extraneous-class': 'error',
21
+ '@typescript-eslint/no-invalid-void-type': 'error',
22
+ '@typescript-eslint/no-misused-new': 'error',
23
+ '@typescript-eslint/no-namespace': 'error',
24
+ '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
25
+ '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
26
+ '@typescript-eslint/no-non-null-assertion': 'error',
27
+ '@typescript-eslint/no-this-alias': 'error',
28
+ '@typescript-eslint/no-unnecessary-type-constraint': 'error',
29
+ '@typescript-eslint/no-unsafe-declaration-merging': 'error',
30
+ '@typescript-eslint/no-useless-constructor': 'error',
31
+ '@typescript-eslint/prefer-as-const': 'error',
32
+ '@typescript-eslint/prefer-literal-enum-member': 'error',
33
+ '@typescript-eslint/triple-slash-reference': 'error',
34
+ '@typescript-eslint/unified-signatures': 'error',
35
+
36
+ '@typescript-eslint/no-explicit-any': 'warn',
37
+ '@typescript-eslint/no-empty-function': 0,
38
+ '@typescript-eslint/no-unused-vars': [
39
+ 'warn',
40
+ {
41
+ argsIgnorePattern: '^_+$',
42
+ ignoreRestSiblings: true,
43
+ reportUsedIgnorePattern: true,
44
+ varsIgnorePattern: '^_+$',
45
+ },
46
+ ],
47
+ },
48
+ },
49
+ {
50
+ files: ['**/*.cts'],
51
+ rules: {
52
+ '@typescript-eslint/no-require-imports': 0,
53
+ },
54
+ },
55
+ ];
@@ -0,0 +1,29 @@
1
+ import eslintPluginUnicorn from 'eslint-plugin-unicorn';
2
+
3
+ export default [
4
+ eslintPluginUnicorn.configs['flat/recommended'],
5
+ {
6
+ rules: {
7
+ 'unicorn/consistent-destructuring': 'off',
8
+ 'unicorn/custom-error-definition': 'warn',
9
+ 'unicorn/expiring-todo-comments': 'off',
10
+ 'unicorn/import-style': 'off',
11
+ 'unicorn/no-array-for-each': 'off',
12
+ 'unicorn/no-array-reduce': 'off',
13
+ 'unicorn/no-null': 'off',
14
+ 'unicorn/numeric-separators-style': [
15
+ 'warn',
16
+ { onlyIfContainsSeparator: true },
17
+ ],
18
+ 'unicorn/prefer-export-from': ['error', { ignoreUsedVariables: true }],
19
+ 'unicorn/prefer-global-this': 0,
20
+ 'unicorn/prefer-prototype-methods': 'off',
21
+ 'unicorn/prefer-set-has': 'off',
22
+ 'unicorn/prefer-top-level-await': 'off',
23
+ 'unicorn/prevent-abbreviations': 'off',
24
+ 'unicorn/relative-url-style': ['error', 'always'],
25
+ 'unicorn/require-post-message-target-origin': 'off',
26
+ 'unicorn/template-indent': 'off',
27
+ },
28
+ },
29
+ ];
@@ -1,10 +1,7 @@
1
- 'use strict';
1
+ import globals from 'globals';
2
+ import { getPkg } from 'settingz';
2
3
 
3
- const { getPkg } = require('settingz');
4
- const globals = require('globals');
5
-
6
- // eslint-disable-next-line consistent-return
7
- exports.pkgHas = function pkgHas(checker, getResult) {
4
+ export function pkgHas(checker, getResult) {
8
5
  const pkg = getPkg();
9
6
 
10
7
  const io = checker(pkg);
@@ -14,10 +11,10 @@ exports.pkgHas = function pkgHas(checker, getResult) {
14
11
  }
15
12
 
16
13
  return [];
17
- };
14
+ }
18
15
 
19
16
  // eslint-disable-next-line consistent-return
20
- exports.configHas = function configHas(checker, getResult) {
17
+ export function configHas(checker, getResult) {
21
18
  const pkg = getPkg('nice-move');
22
19
 
23
20
  const io = checker(pkg);
@@ -25,9 +22,9 @@ exports.configHas = function configHas(checker, getResult) {
25
22
  if (io) {
26
23
  return getResult(io, pkg);
27
24
  }
28
- };
25
+ }
29
26
 
30
- exports.getGlobals = function getGlobals(env = {}) {
27
+ export function getGlobals(env = {}) {
31
28
  return Object.fromEntries([
32
29
  ...Object.keys({
33
30
  ...globals.browser,
@@ -43,4 +40,4 @@ exports.getGlobals = function getGlobals(env = {}) {
43
40
  : Object.keys(globals[key] || {}).map((k) => [k, 'off']),
44
41
  ),
45
42
  ]);
46
- };
43
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-move/eslint-config-base",
3
- "version": "0.11.35",
3
+ "version": "0.12.1",
4
4
  "description": "A `eslint` config for best practice",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -32,12 +32,13 @@
32
32
  "bugs": {
33
33
  "url": "https://github.com/nice-move/nice-move/issues"
34
34
  },
35
- "main": "index.cjs",
35
+ "main": "index.mjs",
36
+ "type": "module",
36
37
  "dependencies": {
37
38
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
39
+ "@eslint/eslintrc": "^3.2.0",
40
+ "@eslint/js": "^10.0.0",
38
41
  "@nice-move/eslint-plugin-html": "^0.1.1",
39
- "@typescript-eslint/eslint-plugin": "^8.19.0",
40
- "@typescript-eslint/parser": "^8.19.0",
41
42
  "eslint-config-airbnb-base": "^15.0.0",
42
43
  "eslint-config-prettier": "^9.1.0",
43
44
  "eslint-plugin-import": "^2.31.0",
@@ -46,15 +47,17 @@
46
47
  "eslint-plugin-promise": "^7.2.1",
47
48
  "eslint-plugin-regexp": "^2.7.0",
48
49
  "eslint-plugin-unicorn": "^56.0.1",
49
- "espree": "^9.6.1",
50
+ "espree": "^10.3.0",
51
+ "globals": "^15.14.0",
50
52
  "resolve.exports": "^2.0.3",
51
- "settingz": "^0.2.0"
53
+ "settingz": "^0.2.0",
54
+ "typescript-eslint": "^8.19.1"
52
55
  },
53
56
  "peerDependencies": {
54
- "eslint": "^8.57.1"
57
+ "eslint": "^9.17.0"
55
58
  },
56
59
  "engines": {
57
- "node": "^22.11.0"
60
+ "node": "^20.18.1 || ^22.11.0"
58
61
  },
59
62
  "publishConfig": {
60
63
  "access": "public",
package/index.cjs DELETED
@@ -1,54 +0,0 @@
1
- 'use strict';
2
-
3
- const { readJson, getPkg } = require('settingz');
4
-
5
- function ignoreList() {
6
- const { ignore: { all = [], eslint = [] } = {} } = getPkg('nice-move');
7
-
8
- return [...all, ...eslint];
9
- }
10
-
11
- function BestShot() {
12
- const { git = [], eslint = git } = readJson(
13
- '@best-shot/cli/config/ignore.json',
14
- );
15
-
16
- return eslint;
17
- }
18
-
19
- module.exports = {
20
- noInlineConfig: false,
21
- reportUnusedDisableDirectives: true,
22
- plugins: ['regexp'],
23
- extends: [
24
- 'eslint:recommended',
25
- 'airbnb-base',
26
- require.resolve('./lib/unicorn.cjs'),
27
- require.resolve('./lib/promise.cjs'),
28
- require.resolve('./lib/import.cjs'),
29
- require.resolve('./lib/base.cjs'),
30
- require.resolve('./lib/node.cjs'),
31
- require.resolve('./lib/bundler.cjs'),
32
- require.resolve('./lib/typescript.cjs'),
33
- require.resolve('./lib/markdown.cjs'),
34
- require.resolve('./lib/test.cjs'),
35
- require.resolve('./lib/mini.cjs'),
36
- 'plugin:@nice-move/html/recommended',
37
- 'plugin:regexp/recommended',
38
- 'prettier',
39
- ],
40
- ignorePatterns: [
41
- '!.*',
42
- '.cache/',
43
- '.git/',
44
- '.svn/',
45
- '*.min.*',
46
- '**/.docusaurus/**',
47
- '**/.obsidian/**',
48
- '**/dist/**',
49
- '**/miniprogram_npm/**',
50
- '**/node_modules/**',
51
- ...BestShot(),
52
- ...ignoreList(),
53
- ],
54
- };
package/lib/base.cjs DELETED
@@ -1,150 +0,0 @@
1
- 'use strict';
2
-
3
- const { getGlobals } = require('../lib/utils.cjs');
4
-
5
- module.exports = {
6
- env: {
7
- es2025: true,
8
- browser: false,
9
- node: false,
10
- commonjs: false,
11
- },
12
- globals: getGlobals({ es2025: true }),
13
- parserOptions: {
14
- ecmaFeatures: {
15
- globalReturn: false,
16
- impliedStrict: true,
17
- jsx: false,
18
- },
19
- ecmaVersion: 'latest',
20
- sourceType: 'module',
21
- },
22
- extends: ['plugin:@eslint-community/eslint-comments/recommended'],
23
- overrides: [
24
- {
25
- files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
26
- env: {
27
- es2025: true,
28
- browser: true,
29
- node: false,
30
- commonjs: false,
31
- },
32
- globals: getGlobals({ es2025: true, browser: true }),
33
- },
34
- {
35
- files: ['**/*.jsx', '**/*.tsx'],
36
- parserOptions: {
37
- ecmaFeatures: {
38
- jsx: true,
39
- },
40
- },
41
- },
42
- {
43
- files: ['**/*.cjs'],
44
- parserOptions: {
45
- sourceType: 'script',
46
- ecmaFeatures: {
47
- impliedStrict: false,
48
- },
49
- },
50
- },
51
- {
52
- files: ['**/*.cts'],
53
- parserOptions: {
54
- sourceType: 'module',
55
- ecmaFeatures: {
56
- impliedStrict: true,
57
- },
58
- },
59
- },
60
- ],
61
- rules: {
62
- 'lines-around-directive': 0,
63
- 'array-callback-return': [
64
- 'error',
65
- {
66
- allowImplicit: true,
67
- checkForEach: true,
68
- },
69
- ],
70
- 'arrow-body-style': 0,
71
- camelcase: 0,
72
- 'class-methods-use-this': 'warn',
73
- 'consistent-return': 'warn',
74
- 'global-require': 0,
75
- 'grouped-accessor-pairs': 0,
76
- 'lines-between-class-members': 0,
77
- 'max-classes-per-file': 0,
78
- 'no-await-in-loop': 0,
79
- 'no-console': 0,
80
- 'no-constant-binary-expression': 'error',
81
- 'no-constructor-return': 0,
82
- 'no-empty': [
83
- 'error',
84
- {
85
- allowEmptyCatch: true,
86
- },
87
- ],
88
- 'no-implicit-coercion': [
89
- 'warn',
90
- {
91
- disallowTemplateShorthand: true,
92
- },
93
- ],
94
- 'no-nested-ternary': 0,
95
- 'no-restricted-exports': [
96
- 'error',
97
- {
98
- restrictedNamedExports: ['then', 'await'],
99
- },
100
- ],
101
- 'no-param-reassign': [
102
- 'warn',
103
- {
104
- ignorePropertyModificationsFor: [],
105
- props: true,
106
- },
107
- ],
108
- 'no-restricted-syntax': [
109
- 'error',
110
- {
111
- message:
112
- '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.',
113
- selector: 'ForInStatement',
114
- },
115
- {
116
- message:
117
- 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
118
- selector: 'LabeledStatement',
119
- },
120
- ],
121
- 'no-plusplus': 0,
122
- 'no-template-curly-in-string': 0,
123
- 'no-undef-init': 0,
124
- 'no-underscore-dangle': 0,
125
- 'no-unreachable-loop': 0,
126
- 'no-unused-expressions': [
127
- 'error',
128
- {
129
- allowTaggedTemplates: true,
130
- },
131
- ],
132
- 'no-unused-vars': [
133
- 'error',
134
- {
135
- argsIgnorePattern: '^_+$',
136
- ignoreRestSiblings: true,
137
- reportUsedIgnorePattern: true,
138
- varsIgnorePattern: '^_+$',
139
- },
140
- ],
141
- 'no-useless-rename': 0,
142
- 'object-shorthand': 0,
143
- 'prefer-arrow-callback': 'warn',
144
- 'prefer-exponentiation-operator': 0,
145
- 'prefer-template': 'warn',
146
- 'spaced-comment': 0,
147
- '@eslint-community/eslint-comments/no-unused-enable': 'warn',
148
- '@eslint-community/eslint-comments/disable-enable-pair': 0,
149
- },
150
- };
package/lib/bundler.cjs DELETED
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- const { isReachable } = require('settingz');
4
-
5
- function webpack() {
6
- return isReachable('webpack/package.json') ||
7
- isReachable('best-shot/package.json')
8
- ? [
9
- {
10
- files: ['src/**'],
11
- excludedFiles: ['*.html', '*.htm'],
12
- globals: {
13
- __webpack_public_path__: true,
14
- __webpack_base_uri__: true,
15
- },
16
- },
17
- ]
18
- : [];
19
- }
20
-
21
- module.exports = {
22
- overrides: webpack(),
23
- };
package/lib/import.cjs DELETED
@@ -1,101 +0,0 @@
1
- 'use strict';
2
-
3
- const { pkgHas, configHas } = require('./utils.cjs');
4
-
5
- const Vscode = pkgHas(
6
- ({ engines: { vscode } = {} }) => vscode,
7
- () => ({ 'import/core-modules': ['vscode'] }),
8
- );
9
-
10
- module.exports = {
11
- extends: ['plugin:import/recommended'],
12
- rules: {
13
- 'import/extensions': [
14
- 'error',
15
- 'always',
16
- {
17
- ignorePackages: true,
18
- },
19
- ],
20
- 'import/no-extraneous-dependencies': [
21
- 'error',
22
- {
23
- devDependencies: [
24
- '**/*.{test,spec}.{m,c,}{t,j}s',
25
- '{test,tests,try}.{m,c,}{t,j}s',
26
- '{test,tests,config}/**/*.{m,c,}{t,j}s',
27
- '**/.*rc.{m,c,}{t,j}s',
28
- '**/*.config.{m,c,}{t,j}s',
29
- '**/config.{m,c,}{t,j}s',
30
- '.*/config.{m,c,}{t,j}s',
31
- '**/.best-shot/**',
32
- ...(configHas(
33
- ({ bundle = [] }) => bundle,
34
- (bundle) => bundle,
35
- ) || []),
36
- ],
37
- },
38
- ],
39
- 'import/newline-after-import': 0,
40
- 'import/no-dynamic-require': 0,
41
- 'import/no-empty-named-blocks': 'error',
42
- 'import/no-relative-packages': 0,
43
- 'import/order': 0,
44
- 'import/prefer-default-export': 0,
45
- 'import/no-cycle': 0,
46
- },
47
- settings: {
48
- ...Vscode,
49
- 'import/extensions': [
50
- '.tsx',
51
- '.ts',
52
- '.cts',
53
- '.mts',
54
- '.vue',
55
- '.jsx',
56
- '.js',
57
- '.mjs',
58
- '.cjs',
59
- ],
60
- 'import/parsers': {
61
- '@typescript-eslint/parser': ['.ts', '.cts', '.mts', '.tsx'],
62
- 'vue-eslint-parser': ['.vue'],
63
- [require.resolve('./jsx-parser.cjs')]: ['.jsx'],
64
- },
65
- 'import/ignore': false,
66
- ...configHas(
67
- ({ 'internal-regex': internalRegex }) => internalRegex,
68
- (internalRegex) => ({ 'import/internal-regex': internalRegex }),
69
- ),
70
- 'import/resolver': {
71
- node: false,
72
- [require.resolve('./node-next-resolver.cjs')]:
73
- configHas(
74
- ({ 'import-http': importHttp }) => importHttp,
75
- (importHttp) => ({ importHttp }),
76
- ) || {},
77
- },
78
- },
79
- overrides: [
80
- {
81
- files: '**/*.*',
82
- excludedFiles: '*.{m,c}{j,t}s',
83
- rules: {
84
- 'import/no-nodejs-modules': 'error',
85
- },
86
- },
87
- {
88
- files: '**/*.*',
89
- excludedFiles: [
90
- '*.config.{m,c}{j,t}s',
91
- '.config/**/.{m,c}{j,t}s',
92
- 'config/**/.{m,c}{j,t}s',
93
- '**/*.md/*',
94
- '**/*.{wxs,qs}',
95
- ],
96
- rules: {
97
- 'import/no-default-export': 'warn',
98
- },
99
- },
100
- ],
101
- };
package/lib/markdown.cjs DELETED
@@ -1,31 +0,0 @@
1
- 'use strict';
2
-
3
- const {
4
- configs: {
5
- 'recommended-legacy': {
6
- overrides: [_, { rules }],
7
- },
8
- },
9
- } = require('eslint-plugin-markdown/lib/index');
10
-
11
- module.exports = {
12
- overrides: [
13
- {
14
- files: '*.md',
15
- plugins: ['markdown'],
16
- processor: 'markdown/markdown',
17
- },
18
- {
19
- files: '**/*.md/*',
20
- rules: {
21
- ...rules,
22
- 'import/no-extraneous-dependencies': 'off',
23
- 'import/no-unresolved': 'off',
24
- 'unicorn/filename-case': 'off',
25
- 'unicorn/custom-error-definition': 'off',
26
- '@typescript-eslint/no-unused-vars': 'off',
27
- '@typescript-eslint/no-extraneous-class': 'off',
28
- },
29
- },
30
- ],
31
- };