@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/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
+ ];
package/lib/utils.mjs ADDED
@@ -0,0 +1,43 @@
1
+ import globals from 'globals';
2
+ import { getPkg } from 'settingz';
3
+
4
+ export function pkgHas(checker, getResult) {
5
+ const pkg = getPkg();
6
+
7
+ const io = checker(pkg);
8
+
9
+ if (io) {
10
+ return getResult(io, pkg) || [];
11
+ }
12
+
13
+ return [];
14
+ }
15
+
16
+ // eslint-disable-next-line consistent-return
17
+ export function configHas(checker, getResult) {
18
+ const pkg = getPkg('nice-move');
19
+
20
+ const io = checker(pkg);
21
+
22
+ if (io) {
23
+ return getResult(io, pkg);
24
+ }
25
+ }
26
+
27
+ export function getGlobals(env = {}) {
28
+ return Object.fromEntries([
29
+ ...Object.keys({
30
+ ...globals.browser,
31
+ ...globals.node,
32
+ ...globals.es2025,
33
+ }).map((key) => [key, 'off']),
34
+ ...Object.entries(env).flatMap(([key, on]) =>
35
+ on
36
+ ? Object.entries(globals[key] || {}).map(([k, v]) => [
37
+ k,
38
+ v ? 'writable' : 'readonly',
39
+ ])
40
+ : Object.keys(globals[key] || {}).map((k) => [k, 'off']),
41
+ ),
42
+ ]);
43
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-move/eslint-config-base",
3
- "version": "0.11.34",
3
+ "version": "0.12.0",
4
4
  "description": "A `eslint` config for best practice",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -32,32 +32,32 @@
32
32
  "bugs": {
33
33
  "url": "https://github.com/nice-move/nice-move/issues"
34
34
  },
35
- "main": "index.cjs",
35
+ "type": "module",
36
+ "main": "index.mjs",
36
37
  "dependencies": {
37
- "@babel/core": "^7.26.0",
38
- "@babel/eslint-parser": "^7.25.9",
39
- "@babel/plugin-syntax-import-attributes": "^7.26.0",
40
38
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
41
- "@nice-move/eslint-plugin-html": "0.0.0-beta.4",
42
- "@typescript-eslint/eslint-plugin": "^8.18.1",
43
- "@typescript-eslint/parser": "^8.18.1",
39
+ "@eslint/js": "^10.0.0",
40
+ "@eslint/eslintrc": "^3.2.0",
41
+ "@nice-move/eslint-plugin-html": "^0.1.1",
44
42
  "eslint-config-airbnb-base": "^15.0.0",
45
43
  "eslint-config-prettier": "^9.1.0",
46
44
  "eslint-plugin-import": "^2.31.0",
47
45
  "eslint-plugin-markdown": "^5.1.0",
48
- "eslint-plugin-n": "^17.15.0",
46
+ "eslint-plugin-n": "^17.15.1",
49
47
  "eslint-plugin-promise": "^7.2.1",
50
48
  "eslint-plugin-regexp": "^2.7.0",
51
49
  "eslint-plugin-unicorn": "^56.0.1",
52
- "espree": "^9.6.1",
50
+ "espree": "^10.3.0",
51
+ "globals": "^15.14.0",
53
52
  "resolve.exports": "^2.0.3",
54
- "settingz": "^0.2.0"
53
+ "settingz": "^0.2.0",
54
+ "typescript-eslint": "^8.19.0"
55
55
  },
56
56
  "peerDependencies": {
57
- "eslint": "^8.57.1"
57
+ "eslint": "^9.17.0"
58
58
  },
59
59
  "engines": {
60
- "node": "^18.20.5 || ^20.18.1 || ^22.11.0"
60
+ "node": "^20.18.1 || ^22.11.0"
61
61
  },
62
62
  "publishConfig": {
63
63
  "access": "public",
package/index.cjs DELETED
@@ -1,71 +0,0 @@
1
- 'use strict';
2
-
3
- const {
4
- configHas,
5
- matches: { sourceAndPackages },
6
- } = require('./lib/utils.cjs');
7
- const { readJson, getPkg } = require('settingz');
8
-
9
- function ignoreList() {
10
- const { ignore: { all = [], eslint = [] } = {} } = getPkg('nice-move');
11
-
12
- return [...all, ...eslint];
13
- }
14
-
15
- function BestShot() {
16
- const { git = [], eslint = git } = readJson(
17
- '@best-shot/cli/config/ignore.json',
18
- );
19
-
20
- return eslint;
21
- }
22
-
23
- module.exports = {
24
- noInlineConfig: false,
25
- reportUnusedDisableDirectives: true,
26
- plugins: ['regexp'],
27
- extends: [
28
- 'eslint:recommended',
29
- 'airbnb-base',
30
- require.resolve('./lib/unicorn.cjs'),
31
- require.resolve('./lib/promise.cjs'),
32
- require.resolve('./lib/import.cjs'),
33
- require.resolve('./lib/base.cjs'),
34
- require.resolve('./lib/electron.cjs'),
35
- require.resolve('./lib/playwright.cjs'),
36
- require.resolve('./lib/node.cjs'),
37
- require.resolve('./lib/bundler.cjs'),
38
- require.resolve('./lib/typescript.cjs'),
39
- require.resolve('./lib/markdown.cjs'),
40
- require.resolve('./lib/test.cjs'),
41
- require.resolve('./lib/mini.cjs'),
42
- 'plugin:@nice-move/html/recommended',
43
- 'plugin:regexp/recommended',
44
- 'prettier',
45
- ],
46
- ...configHas(
47
- ({ globals }) => globals,
48
- (globals) => ({
49
- overrides: [
50
- {
51
- files: sourceAndPackages,
52
- globals,
53
- },
54
- ],
55
- }),
56
- ),
57
- ignorePatterns: [
58
- '!.*',
59
- '.cache/',
60
- '.git/',
61
- '.svn/',
62
- '*.min.*',
63
- '**/.docusaurus/**',
64
- '**/.obsidian/**',
65
- '**/dist/**',
66
- '**/miniprogram_npm/**',
67
- '**/node_modules/**',
68
- ...BestShot(),
69
- ...ignoreList(),
70
- ],
71
- };
package/lib/base.cjs DELETED
@@ -1,126 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- env: {
5
- browser: true,
6
- commonjs: false,
7
- es2024: true,
8
- es2023: true,
9
- es2022: true,
10
- es2021: true,
11
- es2020: true,
12
- es2019: true,
13
- es2018: true,
14
- es2017: true,
15
- es2016: true,
16
- node: false,
17
- },
18
- extends: ['plugin:@eslint-community/eslint-comments/recommended'],
19
- overrides: [
20
- {
21
- files: ['*.jsx', '*.tsx'],
22
- parserOptions: {
23
- ecmaFeatures: {
24
- jsx: true,
25
- },
26
- },
27
- },
28
- ],
29
- parserOptions: {
30
- ecmaFeatures: {
31
- globalReturn: false,
32
- impliedStrict: true,
33
- jsx: false,
34
- },
35
- ecmaVersion: 'latest',
36
- sourceType: 'module',
37
- },
38
- rules: {
39
- 'lines-around-directive': 0,
40
- 'array-callback-return': [
41
- 'error',
42
- {
43
- allowImplicit: true,
44
- checkForEach: true,
45
- },
46
- ],
47
- 'arrow-body-style': 0,
48
- camelcase: 0,
49
- 'class-methods-use-this': 'warn',
50
- 'consistent-return': 'warn',
51
- 'global-require': 0,
52
- 'grouped-accessor-pairs': 0,
53
- 'lines-between-class-members': 0,
54
- 'max-classes-per-file': 0,
55
- 'no-await-in-loop': 0,
56
- 'no-console': 0,
57
- 'no-constant-binary-expression': 'error',
58
- 'no-constructor-return': 0,
59
- 'no-empty': [
60
- 'error',
61
- {
62
- allowEmptyCatch: true,
63
- },
64
- ],
65
- 'no-implicit-coercion': [
66
- 'warn',
67
- {
68
- disallowTemplateShorthand: true,
69
- },
70
- ],
71
- 'no-nested-ternary': 0,
72
- 'no-restricted-exports': [
73
- 'error',
74
- {
75
- restrictedNamedExports: ['then', 'await'],
76
- },
77
- ],
78
- 'no-param-reassign': [
79
- 'warn',
80
- {
81
- ignorePropertyModificationsFor: [],
82
- props: true,
83
- },
84
- ],
85
- 'no-restricted-syntax': [
86
- 'error',
87
- {
88
- message:
89
- '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.',
90
- selector: 'ForInStatement',
91
- },
92
- {
93
- message:
94
- 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
95
- selector: 'LabeledStatement',
96
- },
97
- ],
98
- 'no-plusplus': 0,
99
- 'no-template-curly-in-string': 0,
100
- 'no-undef-init': 0,
101
- 'no-underscore-dangle': 0,
102
- 'no-unreachable-loop': 0,
103
- 'no-unused-expressions': [
104
- 'error',
105
- {
106
- allowTaggedTemplates: true,
107
- },
108
- ],
109
- 'no-unused-vars': [
110
- 'error',
111
- {
112
- argsIgnorePattern: '^_+$',
113
- ignoreRestSiblings: true,
114
- varsIgnorePattern: '^_+$',
115
- },
116
- ],
117
- 'no-useless-rename': 0,
118
- 'object-shorthand': 0,
119
- 'prefer-arrow-callback': 'warn',
120
- 'prefer-exponentiation-operator': 0,
121
- 'prefer-template': 'warn',
122
- 'spaced-comment': 0,
123
- '@eslint-community/eslint-comments/no-unused-enable': 'warn',
124
- '@eslint-community/eslint-comments/disable-enable-pair': 0,
125
- },
126
- };
package/lib/bundler.cjs DELETED
@@ -1,26 +0,0 @@
1
- 'use strict';
2
-
3
- const {
4
- matches: { source },
5
- } = require('./utils.cjs');
6
- const { isReachable } = require('settingz');
7
-
8
- function webpack() {
9
- return isReachable('webpack/package.json') ||
10
- isReachable('best-shot/package.json')
11
- ? [
12
- {
13
- files: source,
14
- excludedFiles: ['*.html', '*.htm'],
15
- globals: {
16
- __webpack_public_path__: true,
17
- __webpack_base_uri__: true,
18
- },
19
- },
20
- ]
21
- : [];
22
- }
23
-
24
- module.exports = {
25
- overrides: webpack(),
26
- };
package/lib/electron.cjs DELETED
@@ -1,31 +0,0 @@
1
- 'use strict';
2
-
3
- const {
4
- pkgHas,
5
- matches: { source },
6
- } = require('./utils.cjs');
7
-
8
- module.exports =
9
- pkgHas(
10
- ({ devDependencies: { electron } = {} }) => electron,
11
- () => ({
12
- overrides: [
13
- {
14
- files: source,
15
- settings: {
16
- 'import/core-modules': ['electron'],
17
- },
18
- globals: {
19
- Buffer: 'readonly',
20
- clearImmediate: 'readonly',
21
- global: 'readonly',
22
- process: 'readonly',
23
- setImmediate: 'readonly',
24
- },
25
- rules: {
26
- 'import/no-nodejs-modules': 'off',
27
- },
28
- },
29
- ],
30
- }),
31
- ) || {};
package/lib/import.cjs DELETED
@@ -1,100 +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
- ],
95
- rules: {
96
- 'import/no-default-export': 'warn',
97
- },
98
- },
99
- ],
100
- };
package/lib/markdown.cjs DELETED
@@ -1,36 +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
- env: {
18
- browser: false,
19
- commonjs: false,
20
- node: false,
21
- },
22
- },
23
- {
24
- files: '**/*.md/*',
25
- rules: {
26
- ...rules,
27
- 'import/no-extraneous-dependencies': 'off',
28
- 'import/no-unresolved': 'off',
29
- 'unicorn/filename-case': 'off',
30
- 'unicorn/custom-error-definition': 'off',
31
- '@typescript-eslint/no-unused-vars': 'off',
32
- '@typescript-eslint/no-extraneous-class': 'off',
33
- },
34
- },
35
- ],
36
- };