@dword-design/eslint-config 7.0.1 → 7.0.3

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.
@@ -20,196 +20,202 @@ import loadPkg from 'load-pkg';
20
20
  import { compact, omit, without } from 'lodash-es';
21
21
  import { sortOrder as packageJsonSortOrder } from 'sort-package-json';
22
22
  import tseslint from 'typescript-eslint';
23
- import restrictedImports from './restricted-imports.js';
24
- export default ({ cwd = '.' } = {}) => {
25
- const packageConfig = loadPkg.sync(cwd) || {};
26
- const eslintRestrictedImports = restrictedImports
27
- .filter(importDef => importDef.alternative === undefined ||
28
- importDef.alternative !== packageConfig.name)
29
- .map(importDef => ({
30
- ...omit(importDef, ['alternative']),
31
- message: compact([
32
- importDef.message,
33
- importDef.alternative ? `Use '${importDef.alternative}' instead` : '',
34
- ]).join(' '),
35
- }));
36
- // mimic CommonJS variables -- not needed if using CommonJS
37
- const __filename = fileURLToPath(import.meta.url);
38
- const __dirname = pathLib.dirname(__filename);
39
- const compat = new FlatCompat({ baseDirectory: __dirname });
40
- return defineConfig([
41
- gitignore({ strict: false }),
42
- js.configs.recommended,
43
- tseslint.configs.recommended,
44
- importX.flatConfigs.recommended,
45
- importX.flatConfigs.typescript,
46
- pluginPromise.configs['flat/recommended'],
47
- ...pluginVue.configs['flat/recommended'].map(plugin => ({
48
- files: ['**/*.ts', '**/*.vue'],
49
- ...plugin,
50
- })),
51
- importAlias.configs.recommended,
52
- { files: ['**/*.ts', '**/*.vue'], ...eslintPluginPrettierRecommended },
53
- pluginPlaywright.configs['flat/recommended'],
54
- ...compat.plugins(packageName `eslint-plugin-prefer-arrow`),
55
- ...compat.plugins(packageName `eslint-plugin-simple-import-sort`),
56
- ...compat.plugins(packageName `eslint-plugin-sort-keys-fix`),
57
- {
58
- files: ['**/*.ts', '**/*.vue'],
59
- ...eslintPluginUnicorn.configs.recommended,
23
+ import restrictedImports from "./restricted-imports.js";
24
+ export default ({
25
+ cwd = '.'
26
+ } = {}) => {
27
+ const packageConfig = loadPkg.sync(cwd) || {};
28
+ const eslintRestrictedImports = restrictedImports.filter(importDef => importDef.alternative === undefined || importDef.alternative !== packageConfig.name).map(importDef => ({
29
+ ...omit(importDef, ['alternative']),
30
+ message: compact([importDef.message, importDef.alternative ? `Use '${importDef.alternative}' instead` : '']).join(' ')
31
+ }));
32
+ // mimic CommonJS variables -- not needed if using CommonJS
33
+ const __filename = fileURLToPath(import.meta.url);
34
+ const __dirname = pathLib.dirname(__filename);
35
+ const compat = new FlatCompat({
36
+ baseDirectory: __dirname
37
+ });
38
+ return defineConfig([gitignore({
39
+ strict: false
40
+ }), js.configs.recommended, tseslint.configs.recommended, importX.flatConfigs.recommended, importX.flatConfigs.typescript, pluginPromise.configs['flat/recommended'], ...pluginVue.configs['flat/recommended'].map(plugin => ({
41
+ files: ['**/*.ts', '**/*.vue'],
42
+ ...plugin
43
+ })), {
44
+ files: ['**/*.ts', '**/*.vue'],
45
+ ...importAlias.configs.recommended
46
+ }, {
47
+ files: ['**/*.ts', '**/*.vue'],
48
+ ...eslintPluginPrettierRecommended
49
+ }, pluginPlaywright.configs['flat/recommended'], ...compat.plugins(packageName`eslint-plugin-prefer-arrow`), ...compat.plugins(packageName`eslint-plugin-simple-import-sort`), ...compat.plugins(packageName`eslint-plugin-sort-keys-fix`), {
50
+ files: ['**/*.ts', '**/*.vue'],
51
+ ...eslintPluginUnicorn.configs.recommended
52
+ }, ...eslintPluginJsonc.configs['flat/recommended-with-jsonc'], {
53
+ files: ['**/*.json'],
54
+ rules: {
55
+ 'jsonc/indent': ['error', 2],
56
+ 'jsonc/sort-keys': 'error'
57
+ }
58
+ }, {
59
+ files: ['**/package.json'],
60
+ rules: {
61
+ 'jsonc/sort-keys': ['error', {
62
+ order: packageJsonSortOrder,
63
+ pathPattern: '^$'
64
+ }]
65
+ }
66
+ }, {
67
+ files: ['**/*.ts', '**/*.vue'],
68
+ languageOptions: {
69
+ globals: {
70
+ ...globals.node,
71
+ ...globals.browser
72
+ }
73
+ },
74
+ rules: {
75
+ '@dword-design/import-alias/prefer-alias': ['error', {
76
+ alias: {
77
+ '@': '.'
78
+ }
79
+ }],
80
+ 'arrow-body-style': ['error', 'as-needed'],
81
+ 'func-names': ['error', 'never'],
82
+ 'global-require': 'off',
83
+ 'import-x/extensions': ['error', 'ignorePackages', {
84
+ ts: 'never'
85
+ }],
86
+ 'import-x/no-extraneous-dependencies': ['error', {
87
+ devDependencies: ['**/*.spec.ts', 'fixtures/**', 'global-setup.ts', 'global-teardown.ts', 'playwright.config.ts']
88
+ }],
89
+ 'import-x/no-named-as-default': 'off',
90
+ 'import-x/no-named-as-default-member': 'off',
91
+ 'linebreak-style': ['error', 'unix'],
92
+ 'new-cap': 'off',
93
+ 'no-await-in-loop': 'off',
94
+ 'no-console': 'off',
95
+ 'no-constant-condition': ['error', {
96
+ checkLoops: false
97
+ }],
98
+ 'no-continue': 'off',
99
+ 'no-empty-pattern': 'error',
100
+ 'no-lonely-if': 'off',
101
+ 'no-negated-condition': 'error',
102
+ 'no-nested-ternary': 'off',
103
+ 'no-param-reassign': 'off',
104
+ 'no-promise-executor-return': 'off',
105
+ 'no-regex-spaces': 'off',
106
+ // https://github.com/facebook/create-react-app/issues/12847
107
+ 'no-restricted-globals': ['error', {
108
+ message: 'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite',
109
+ name: 'isFinite'
110
+ }, {
111
+ message: 'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan',
112
+ name: 'isNaN'
113
+ }, ...without(confusingBrowserGlobals, 'self').map(g => ({
114
+ message: `Use window.${g} instead. https://github.com/facebook/create-react-app/blob/HEAD/packages/confusing-browser-globals/README.md`,
115
+ name: g
116
+ }))],
117
+ 'no-restricted-imports': ['error', {
118
+ paths: eslintRestrictedImports
119
+ }],
120
+ 'no-return-assign': 'off',
121
+ 'no-template-curly-in-string': 'off',
122
+ 'no-underscore-dangle': 'off',
123
+ 'no-var': 'error',
124
+ [`${packageName`prettier`}/prettier`]: ['error', {
125
+ arrowParens: 'avoid',
126
+ objectWrap: 'collapse',
127
+ singleQuote: true,
128
+ trailingComma: 'all'
129
+ }],
130
+ 'object-shorthand': ['error', 'always'],
131
+ 'padding-line-between-statements': ['error', {
132
+ blankLine: 'never',
133
+ next: '*',
134
+ prev: '*'
135
+ }, {
136
+ blankLine: 'always',
137
+ next: '*',
138
+ prev: 'import'
139
+ }, {
140
+ blankLine: 'any',
141
+ next: 'import',
142
+ prev: 'import'
143
+ }, ...Object.keys({
144
+ 'block-like': true,
145
+ const: true,
146
+ expression: true,
147
+ let: true
148
+ }).flatMap(name => [{
149
+ blankLine: 'always',
150
+ next: `multiline-${name}`,
151
+ prev: '*'
152
+ }, {
153
+ blankLine: 'always',
154
+ next: '*',
155
+ prev: `multiline-${name}`
156
+ }]), {
157
+ blankLine: 'always',
158
+ next: 'export',
159
+ prev: '*'
160
+ }],
161
+ 'prefer-arrow/prefer-arrow-functions': ['error'],
162
+ 'prefer-destructuring': 'off',
163
+ 'require-await': 'error',
164
+ 'simple-import-sort/imports': 'error',
165
+ 'sort-keys-fix/sort-keys-fix': 'error',
166
+ 'unicorn/catch-error-name': 'off',
167
+ 'unicorn/consistent-function-scoping': 'off',
168
+ 'unicorn/no-anonymous-default-export': 'off',
169
+ 'unicorn/no-negated-condition': 'off',
170
+ 'unicorn/no-nested-ternary': 'off',
171
+ 'unicorn/no-null': 'off',
172
+ 'unicorn/prevent-abbreviations': 'off',
173
+ 'unicorn/template-indent': ['error', {
174
+ tags: Object.keys({
175
+ css: true,
176
+ endent: true,
177
+ html: true,
178
+ javascript: true,
179
+ sql: true,
180
+ svg: true,
181
+ xml: true
182
+ })
183
+ }],
184
+ 'vue/attributes-order': ['error', {
185
+ alphabetical: true
186
+ }],
187
+ 'vue/no-deprecated-functional-template': 'error',
188
+ 'vue/order-in-components': 'off',
189
+ 'vue/prefer-true-attribute-shorthand': 'error',
190
+ 'vue/require-default-prop': 'off',
191
+ 'vue/require-prop-types': 'off' // Complains about title not being a string if variable is passed
192
+ },
193
+ settings: {
194
+ 'import-x/resolver-next': [createTypeScriptImportResolver({
195
+ extensionAlias: {
196
+ '.js': ['.js']
60
197
  },
61
- ...eslintPluginJsonc.configs['flat/recommended-with-jsonc'],
62
- {
63
- files: ['**/*.json'],
64
- rules: { 'jsonc/indent': ['error', 2], 'jsonc/sort-keys': 'error' },
65
- },
66
- {
67
- files: ['**/package.json'],
68
- rules: {
69
- 'jsonc/sort-keys': [
70
- 'error',
71
- { order: packageJsonSortOrder, pathPattern: '^$' },
72
- ],
73
- },
74
- },
75
- {
76
- files: ['**/*.ts', '**/*.vue'],
77
- languageOptions: { globals: { ...globals.node, ...globals.browser } },
78
- rules: {
79
- '@dword-design/import-alias/prefer-alias': [
80
- 'error',
81
- { alias: { '@': '.' } },
82
- ],
83
- 'arrow-body-style': ['error', 'as-needed'],
84
- 'func-names': ['error', 'never'],
85
- 'global-require': 'off',
86
- 'import-x/extensions': ['error', 'ignorePackages', { ts: 'never' }],
87
- 'import-x/no-extraneous-dependencies': [
88
- 'error',
89
- {
90
- devDependencies: [
91
- '**/*.spec.ts',
92
- 'fixtures/**',
93
- 'global-setup.ts',
94
- 'global-teardown.ts',
95
- 'playwright.config.ts',
96
- ],
97
- },
98
- ],
99
- 'import-x/no-named-as-default': 'off',
100
- 'import-x/no-named-as-default-member': 'off',
101
- 'linebreak-style': ['error', 'unix'],
102
- 'new-cap': 'off',
103
- 'no-await-in-loop': 'off',
104
- 'no-console': 'off',
105
- 'no-constant-condition': ['error', { checkLoops: false }],
106
- 'no-continue': 'off',
107
- 'no-empty-pattern': 'error',
108
- 'no-lonely-if': 'off',
109
- 'no-negated-condition': 'error',
110
- 'no-nested-ternary': 'off',
111
- 'no-param-reassign': 'off',
112
- 'no-promise-executor-return': 'off',
113
- 'no-regex-spaces': 'off',
114
- // https://github.com/facebook/create-react-app/issues/12847
115
- 'no-restricted-globals': [
116
- 'error',
117
- {
118
- message: 'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite',
119
- name: 'isFinite',
120
- },
121
- {
122
- message: 'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan',
123
- name: 'isNaN',
124
- },
125
- ...without(confusingBrowserGlobals, 'self').map(g => ({
126
- message: `Use window.${g} instead. https://github.com/facebook/create-react-app/blob/HEAD/packages/confusing-browser-globals/README.md`,
127
- name: g,
128
- })),
129
- ],
130
- 'no-restricted-imports': ['error', { paths: eslintRestrictedImports }],
131
- 'no-return-assign': 'off',
132
- 'no-template-curly-in-string': 'off',
133
- 'no-underscore-dangle': 'off',
134
- 'no-var': 'error',
135
- [`${packageName `prettier`}/prettier`]: [
136
- 'error',
137
- {
138
- arrowParens: 'avoid',
139
- objectWrap: 'collapse',
140
- singleQuote: true,
141
- trailingComma: 'all',
142
- },
143
- ],
144
- 'object-shorthand': ['error', 'always'],
145
- 'padding-line-between-statements': [
146
- 'error',
147
- { blankLine: 'never', next: '*', prev: '*' },
148
- { blankLine: 'always', next: '*', prev: 'import' },
149
- { blankLine: 'any', next: 'import', prev: 'import' },
150
- ...Object.keys({
151
- 'block-like': true,
152
- const: true,
153
- expression: true,
154
- let: true,
155
- }).flatMap(name => [
156
- { blankLine: 'always', next: `multiline-${name}`, prev: '*' },
157
- { blankLine: 'always', next: '*', prev: `multiline-${name}` },
158
- ]),
159
- { blankLine: 'always', next: 'export', prev: '*' },
160
- ],
161
- 'prefer-arrow/prefer-arrow-functions': ['error'],
162
- 'prefer-destructuring': 'off',
163
- 'require-await': 'error',
164
- 'simple-import-sort/imports': 'error',
165
- 'sort-keys-fix/sort-keys-fix': 'error',
166
- 'unicorn/catch-error-name': 'off',
167
- 'unicorn/consistent-function-scoping': 'off',
168
- 'unicorn/no-anonymous-default-export': 'off',
169
- 'unicorn/no-negated-condition': 'off',
170
- 'unicorn/no-nested-ternary': 'off',
171
- 'unicorn/no-null': 'off',
172
- 'unicorn/prevent-abbreviations': 'off',
173
- 'unicorn/template-indent': [
174
- 'error',
175
- {
176
- tags: Object.keys({
177
- css: true,
178
- endent: true,
179
- html: true,
180
- javascript: true,
181
- sql: true,
182
- svg: true,
183
- xml: true,
184
- }),
185
- },
186
- ],
187
- 'vue/attributes-order': ['error', { alphabetical: true }],
188
- 'vue/no-deprecated-functional-template': 'error',
189
- 'vue/order-in-components': 'off',
190
- 'vue/prefer-true-attribute-shorthand': 'error',
191
- 'vue/require-default-prop': 'off',
192
- 'vue/require-prop-types': 'off', // Complains about title not being a string if variable is passed
193
- },
194
- settings: {
195
- 'import-x/resolver-next': [
196
- createTypeScriptImportResolver({
197
- project: pathLib.join(cwd, 'tsconfig.json'),
198
- }),
199
- ],
200
- },
201
- },
202
- {
203
- files: ['**/*.spec.ts'],
204
- rules: {
205
- 'playwright/expect-expect': 'off',
206
- 'playwright/valid-title': ['error', { ignoreTypeOfTestName: true }],
207
- },
208
- },
209
- {
210
- files: ['fixtures/**', '**/*.spec.ts'],
211
- rules: { 'no-empty-pattern': 'off' },
212
- },
213
- { files: ['**/*.vue'], rules: { 'vue/multi-word-component-names': 'off' } },
214
- ]);
215
- };
198
+ // Disable auto-guessing of .ts when .js is imported
199
+ project: pathLib.join(cwd, 'tsconfig.json')
200
+ })]
201
+ }
202
+ }, {
203
+ files: ['**/*.spec.ts'],
204
+ rules: {
205
+ 'playwright/expect-expect': 'off',
206
+ 'playwright/valid-title': ['error', {
207
+ ignoreTypeOfTestName: true
208
+ }]
209
+ }
210
+ }, {
211
+ files: ['fixtures/**', '**/*.spec.ts'],
212
+ rules: {
213
+ 'no-empty-pattern': 'off'
214
+ }
215
+ }, {
216
+ files: ['**/*.vue'],
217
+ rules: {
218
+ 'vue/multi-word-component-names': 'off'
219
+ }
220
+ }]);
221
+ };
@@ -1,79 +1,67 @@
1
- export default [
2
- {
3
- alternative: 'parse-packagejson-name',
4
- message: 'Does not work in the browser due to fs dependency in ow.',
5
- name: 'parse-pkg-name',
6
- },
7
- {
8
- alternative: '@dword-design/nuxt-auth',
9
- message: 'Does not auto-rewrite redirects.',
10
- name: '@nuxtjs/auth',
11
- },
12
- {
13
- alternative: '@dword-design/chdir',
14
- message: 'It is not maintained anymore.',
15
- name: 'chdir',
16
- },
17
- {
18
- alternative: 'execa',
19
- message: "'execa' provides more features and syntactic sugar.",
20
- name: 'child-process-promise',
21
- },
22
- {
23
- alternative: 'execa',
24
- message: 'It does not support promises.',
25
- name: 'child_process',
26
- },
27
- {
28
- alternative: 'fs-extra',
29
- message: 'Does not support promises.',
30
- name: 'fs',
31
- },
32
- {
33
- alternative: 'globby',
34
- message: 'Does not support promises.',
35
- name: 'glob',
36
- },
37
- {
38
- alternative: 'globby',
39
- message: 'Does not support pattern arrays.',
40
- name: 'glob-promise',
41
- },
42
- {
43
- alternative: 'globby',
44
- message: 'Only works for Node.js >= 12.',
45
- name: 'matched',
46
- },
47
- {
48
- alternative: 'node-sass-package-importer',
49
- message: 'Does not support inline importing CSS files.',
50
- name: 'node-sass-tilde-importer',
51
- },
52
- {
53
- alternative: '@dword-design/proxyquire',
54
- message: 'Does not set some important default values.',
55
- name: 'proxyquire',
56
- },
57
- {
58
- alternative: 'stealthy-require-no-leak',
59
- message: 'Has a memory leak when requiring the same module multiple times.',
60
- name: 'stealthy-require',
61
- },
62
- { alternative: 'matchdep', name: 'resolve-dep' },
63
- { alternative: '@dword-design/endent', name: 'dedent' },
64
- {
65
- alternative: 'sort-keys',
66
- message: 'Does not support recursive sorting.',
67
- name: 'sort-object-keys',
68
- },
69
- {
70
- alternative: 'tree-kill-promise',
71
- message: 'Does not support promises.',
72
- name: 'tree-kill',
73
- },
74
- {
75
- importNames: ['zipObject'],
76
- message: 'Use map and fromPairs instead',
77
- name: '@dword-design/functions',
78
- },
79
- ];
1
+ export default [{
2
+ alternative: 'parse-packagejson-name',
3
+ message: 'Does not work in the browser due to fs dependency in ow.',
4
+ name: 'parse-pkg-name'
5
+ }, {
6
+ alternative: '@dword-design/nuxt-auth',
7
+ message: 'Does not auto-rewrite redirects.',
8
+ name: '@nuxtjs/auth'
9
+ }, {
10
+ alternative: '@dword-design/chdir',
11
+ message: 'It is not maintained anymore.',
12
+ name: 'chdir'
13
+ }, {
14
+ alternative: 'execa',
15
+ message: "'execa' provides more features and syntactic sugar.",
16
+ name: 'child-process-promise'
17
+ }, {
18
+ alternative: 'execa',
19
+ message: 'It does not support promises.',
20
+ name: 'child_process'
21
+ }, {
22
+ alternative: 'fs-extra',
23
+ message: 'Does not support promises.',
24
+ name: 'fs'
25
+ }, {
26
+ alternative: 'globby',
27
+ message: 'Does not support promises.',
28
+ name: 'glob'
29
+ }, {
30
+ alternative: 'globby',
31
+ message: 'Does not support pattern arrays.',
32
+ name: 'glob-promise'
33
+ }, {
34
+ alternative: 'globby',
35
+ message: 'Only works for Node.js >= 12.',
36
+ name: 'matched'
37
+ }, {
38
+ alternative: 'node-sass-package-importer',
39
+ message: 'Does not support inline importing CSS files.',
40
+ name: 'node-sass-tilde-importer'
41
+ }, {
42
+ alternative: '@dword-design/proxyquire',
43
+ message: 'Does not set some important default values.',
44
+ name: 'proxyquire'
45
+ }, {
46
+ alternative: 'stealthy-require-no-leak',
47
+ message: 'Has a memory leak when requiring the same module multiple times.',
48
+ name: 'stealthy-require'
49
+ }, {
50
+ alternative: 'matchdep',
51
+ name: 'resolve-dep'
52
+ }, {
53
+ alternative: '@dword-design/endent',
54
+ name: 'dedent'
55
+ }, {
56
+ alternative: 'sort-keys',
57
+ message: 'Does not support recursive sorting.',
58
+ name: 'sort-object-keys'
59
+ }, {
60
+ alternative: 'tree-kill-promise',
61
+ message: 'Does not support promises.',
62
+ name: 'tree-kill'
63
+ }, {
64
+ importNames: ['zipObject'],
65
+ message: 'Use map and fromPairs instead',
66
+ name: '@dword-design/functions'
67
+ }];
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import create from './create/index.js';
2
- export default create();
1
+ import create from "./create/index.js";
2
+ export default create();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dword-design/eslint-config",
3
- "version": "7.0.1",
3
+ "version": "7.0.3",
4
4
  "repository": "dword-design/eslint-config",
5
5
  "funding": "https://github.com/sponsors/dword-design",
6
6
  "license": "MIT",
@@ -22,7 +22,7 @@
22
22
  "test": "base test"
23
23
  },
24
24
  "dependencies": {
25
- "@dword-design/eslint-plugin-import-alias": "^6.0.2",
25
+ "@dword-design/eslint-plugin-import-alias": "^6.0.3",
26
26
  "@eslint/eslintrc": "^3.3.1",
27
27
  "@eslint/js": "^9.28.0",
28
28
  "confusing-browser-globals": "^1.0.11",
@@ -30,8 +30,8 @@
30
30
  "eslint": "^9.28.0",
31
31
  "eslint-config-flat-gitignore": "^2.1.0",
32
32
  "eslint-config-prettier": "^10.1.5",
33
- "eslint-import-resolver-typescript": "^4.4.2",
34
- "eslint-plugin-import-x": "npm:@dword-design/eslint-plugin-import-x-fork@^0.0.1",
33
+ "eslint-import-resolver-typescript": "^4.4.3",
34
+ "eslint-plugin-import-x": "^4.15.1",
35
35
  "eslint-plugin-jsonc": "^2.20.1",
36
36
  "eslint-plugin-playwright": "^2.2.0",
37
37
  "eslint-plugin-prefer-arrow": "^1.2.3",