@dword-design/eslint-config 5.0.32 → 6.0.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.
@@ -1,74 +1,98 @@
1
+ import pathLib from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ import babelParser from '@babel/eslint-parser';
1
4
  import defu from '@dword-design/defu';
2
- import { compact, filter, join, map, omit } from '@dword-design/functions';
5
+ import { includeIgnoreFile } from '@eslint/compat';
6
+ import { FlatCompat } from '@eslint/eslintrc';
7
+ import js from '@eslint/js';
3
8
  import confusingBrowserGlobals from 'confusing-browser-globals';
4
9
  import packageName from 'depcheck-package-name';
10
+ import { defineConfig } from 'eslint/config';
11
+ import importPlugin from 'eslint-plugin-import';
12
+ import eslintPluginJsonc from 'eslint-plugin-jsonc';
13
+ import pluginPlaywright from 'eslint-plugin-playwright';
14
+ import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
15
+ import pluginPromise from 'eslint-plugin-promise';
16
+ import eslintPluginUnicorn from 'eslint-plugin-unicorn';
17
+ import pluginVue from 'eslint-plugin-vue';
5
18
  import fs from 'fs-extra';
19
+ import globals from 'globals';
6
20
  import loadPkg from 'load-pkg';
7
- import { without } from 'lodash-es';
21
+ import { compact, omit, without } from 'lodash-es';
22
+ import { sortOrder as packageJsonSortOrder } from 'sort-package-json';
8
23
  import restrictedImports from "./restricted-imports.js";
9
24
  export default () => {
10
- var _ref, _restrictedImports;
11
25
  const packageConfig = loadPkg.sync() || {};
12
26
  const baseConfig = defu(fs.existsSync('.baserc.json') ? fs.readJsonSync('.baserc.json') : {}, {
13
27
  testRunner: 'mocha'
14
28
  });
15
- const eslintRestrictedImports = (_ref = (_restrictedImports = restrictedImports, filter(importDef => importDef.alternative === undefined || importDef.alternative !== packageConfig.name)(_restrictedImports)), map(importDef => {
16
- var _importDef, _ref2, _ref3;
17
- return {
18
- ...(_importDef = importDef, omit(['alternative'])(_importDef)),
19
- message: (_ref2 = (_ref3 = [importDef.message, importDef.alternative ? `Use '${importDef.alternative}' instead` : ''], compact(_ref3)), join(' ')(_ref2))
20
- };
21
- })(_ref));
22
- return {
23
- extends: [packageName`eslint-config-airbnb-base`, `plugin:${packageName`eslint-plugin-promise`}/recommended`, `plugin:${packageName`eslint-plugin-import`}/recommended`, `plugin:${packageName`@dword-design/eslint-plugin-import-alias`}/recommended`, `plugin:${packageName`eslint-plugin-vue`}/recommended`, `plugin:${packageName`eslint-plugin-prettier`}/recommended`, ...(baseConfig.testRunner === 'playwright' ? [`plugin:${packageName`eslint-plugin-playwright`}/recommended`] : [])],
24
- globals: {
25
- globalThis: true,
26
- self: true,
27
- window: true
28
- },
29
- overrides: [{
30
- files: '**/*.spec.js',
31
- ...(baseConfig.testRunner === 'mocha' && {
32
- globals: {
33
- expect: 'readonly'
29
+ const eslintRestrictedImports = restrictedImports.filter(importDef => importDef.alternative === undefined || importDef.alternative !== packageConfig.name).map(importDef => ({
30
+ ...omit(importDef, ['alternative']),
31
+ message: compact([importDef.message, importDef.alternative ? `Use '${importDef.alternative}' instead` : '']).join(' ')
32
+ }));
33
+
34
+ // mimic CommonJS variables -- not needed if using CommonJS
35
+ const __filename = fileURLToPath(import.meta.url);
36
+ const __dirname = pathLib.dirname(__filename);
37
+ const compat = new FlatCompat({
38
+ baseDirectory: __dirname
39
+ });
40
+ return defineConfig([...(fs.existsSync('.gitignore') ? [includeIgnoreFile(pathLib.resolve('.gitignore'))] : []), {
41
+ languageOptions: {
42
+ parser: babelParser,
43
+ parserOptions: {
44
+ babelOptions: {
45
+ rootMode: 'upward-optional'
34
46
  }
35
- }),
36
- rules: {
37
- 'no-restricted-imports': ['error', {
38
- paths: [...eslintRestrictedImports, {
39
- message: "Use the global 'expect' variable instead",
40
- name: 'expect'
41
- }]
42
- }]
43
47
  }
44
- }, {
45
- files: [...(baseConfig.testRunner === 'playwright' ? ['fixtures/**'] : []), '**/*.spec.js'],
46
- rules: {
47
- ...(baseConfig.testRunner === 'playwright' && {
48
- 'no-empty-pattern': 'off'
49
- })
48
+ }
49
+ }, js.configs.recommended, importPlugin.flatConfigs.recommended, pluginPromise.configs['flat/recommended'], ...pluginVue.configs['flat/recommended'].map(plugin => ({
50
+ files: ['**/*.js', '**/*.vue'],
51
+ ...plugin
52
+ })), ...compat.extends(`plugin:${packageName`@dword-design/eslint-plugin-import-alias`}/recommended`), {
53
+ files: ['**/*.js', '**/*.vue'],
54
+ ...eslintPluginPrettierRecommended
55
+ }, ...(baseConfig.testRunner === 'playwright' ? [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`), {
56
+ files: ['**/*.js', '**/*.vue'],
57
+ ...eslintPluginUnicorn.configs.recommended
58
+ }, ...eslintPluginJsonc.configs['flat/recommended-with-jsonc'], {
59
+ files: ['**/*.vue'],
60
+ languageOptions: {
61
+ parserOptions: {
62
+ babelOptions: {
63
+ rootMode: 'upward-optional'
64
+ },
65
+ parser: packageName`@babel/eslint-parser`
50
66
  }
51
- }, {
52
- files: '**/*.vue',
53
- rules: {
54
- 'vue/multi-word-component-names': 'off'
67
+ }
68
+ }, {
69
+ files: ['**/*.json'],
70
+ rules: {
71
+ 'jsonc/indent': ['error', 2],
72
+ 'jsonc/sort-keys': 'error'
73
+ }
74
+ }, {
75
+ files: ['**/package.json'],
76
+ rules: {
77
+ 'jsonc/sort-keys': ['error', {
78
+ order: packageJsonSortOrder,
79
+ pathPattern: '^$'
80
+ }]
81
+ }
82
+ }, {
83
+ files: ['**/*.js', '**/*.vue'],
84
+ languageOptions: {
85
+ globals: {
86
+ ...globals.node,
87
+ ...globals.browser
55
88
  }
56
- }],
57
- parser: packageName`vue-eslint-parser`,
58
- parserOptions: {
59
- babelOptions: {
60
- rootMode: 'upward-optional'
61
- },
62
- parser: packageName`@babel/eslint-parser`
63
89
  },
64
- plugins: [packageName`eslint-plugin-prefer-arrow`, packageName`eslint-plugin-simple-import-sort`, packageName`eslint-plugin-json-format`, packageName`eslint-plugin-sort-keys-fix`, packageName`eslint-plugin-github`, packageName`eslint-plugin-unicorn`],
65
90
  rules: {
66
91
  ...(baseConfig.testRunner === 'playwright' && {
67
92
  'playwright/expect-expect': 'off'
68
93
  }),
69
94
  'arrow-body-style': ['error', 'as-needed'],
70
95
  'func-names': ['error', 'never'],
71
- 'github/array-foreach': 'error',
72
96
  'global-require': 'off',
73
97
  'import/extensions': ['error', 'ignorePackages'],
74
98
  'import/no-commonjs': 'error',
@@ -111,7 +135,14 @@ export default () => {
111
135
  'no-return-assign': 'off',
112
136
  'no-template-curly-in-string': 'off',
113
137
  'no-underscore-dangle': 'off',
138
+ 'no-var': 'error',
114
139
  'object-shorthand': ['error', 'always'],
140
+ [`${packageName`prettier`}/prettier`]: ['error', {
141
+ arrowParens: 'avoid',
142
+ objectWrap: 'collapse',
143
+ singleQuote: true,
144
+ trailingComma: 'all'
145
+ }],
115
146
  'padding-line-between-statements': ['error', {
116
147
  blankLine: 'never',
117
148
  next: '*',
@@ -142,18 +173,18 @@ export default () => {
142
173
  next: 'export',
143
174
  prev: '*'
144
175
  }],
145
- [`${packageName`prettier`}/prettier`]: ['error', {
146
- arrowParens: 'avoid',
147
- plugins: [packageName`prettier-plugin-compactify`],
148
- singleQuote: true,
149
- trailingComma: 'all'
150
- }],
151
176
  'prefer-arrow/prefer-arrow-functions': ['error'],
152
177
  // Everything from airbnb except ForOfStatement
153
178
  'prefer-destructuring': 'off',
154
179
  'require-await': 'error',
155
180
  'simple-import-sort/imports': 'error',
156
181
  'sort-keys-fix/sort-keys-fix': 'error',
182
+ 'unicorn/catch-error-name': 'off',
183
+ 'unicorn/no-anonymous-default-export': 'off',
184
+ 'unicorn/no-negated-condition': 'off',
185
+ 'unicorn/no-nested-ternary': 'off',
186
+ 'unicorn/no-null': 'off',
187
+ 'unicorn/prevent-abbreviations': 'off',
157
188
  'unicorn/template-indent': ['error', {
158
189
  tags: Object.keys({
159
190
  css: true,
@@ -165,11 +196,6 @@ export default () => {
165
196
  xml: true
166
197
  })
167
198
  }],
168
- ...(baseConfig.testRunner === 'playwright' && {
169
- 'playwright/valid-title': ['error', {
170
- ignoreTypeOfTestName: true
171
- }]
172
- }),
173
199
  'vue/attributes-order': ['error', {
174
200
  alphabetical: true
175
201
  }],
@@ -177,7 +203,13 @@ export default () => {
177
203
  'vue/order-in-components': 'off',
178
204
  'vue/prefer-true-attribute-shorthand': 'error',
179
205
  'vue/require-default-prop': 'off',
180
- 'vue/require-prop-types': 'off' // Complains about title not being a string if variable is passed
206
+ 'vue/require-prop-types': 'off',
207
+ // Complains about title not being a string if variable is passed
208
+ ...(baseConfig.testRunner === 'playwright' && {
209
+ 'playwright/valid-title': ['error', {
210
+ ignoreTypeOfTestName: true
211
+ }]
212
+ })
181
213
  },
182
214
  settings: {
183
215
  'import/resolver': {
@@ -187,5 +219,34 @@ export default () => {
187
219
  [packageName`eslint-import-resolver-exports`]: {}
188
220
  }
189
221
  }
190
- };
222
+ }, {
223
+ files: ['**/*.spec.js'],
224
+ ...(baseConfig.testRunner === 'mocha' && {
225
+ languageOptions: {
226
+ globals: {
227
+ expect: 'readonly'
228
+ }
229
+ }
230
+ }),
231
+ rules: {
232
+ 'no-restricted-imports': ['error', {
233
+ paths: [...eslintRestrictedImports, {
234
+ message: "Use the global 'expect' variable instead",
235
+ name: 'expect'
236
+ }]
237
+ }]
238
+ }
239
+ }, {
240
+ files: [...(baseConfig.testRunner === 'playwright' ? ['fixtures/**'] : []), '**/*.spec.js'],
241
+ rules: {
242
+ ...(baseConfig.testRunner === 'playwright' && {
243
+ 'no-empty-pattern': 'off'
244
+ })
245
+ }
246
+ }, {
247
+ files: ['**/*.vue'],
248
+ rules: {
249
+ 'vue/multi-word-component-names': 'off'
250
+ }
251
+ }]);
191
252
  };
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@dword-design/eslint-config",
3
- "version": "5.0.32",
3
+ "version": "6.0.0",
4
4
  "repository": "dword-design/eslint-config",
5
5
  "funding": "https://github.com/sponsors/dword-design",
6
6
  "license": "MIT",
7
7
  "author": "Sebastian Landwehr <info@sebastianlandwehr.com>",
8
8
  "type": "module",
9
- "main": "dist/cjs-fallback.cjs",
9
+ "exports": "./dist/index.js",
10
+ "main": "dist/index.js",
10
11
  "files": [
11
12
  "dist"
12
13
  ],
@@ -21,44 +22,43 @@
21
22
  "test": "base test"
22
23
  },
23
24
  "dependencies": {
24
- "@babel/eslint-parser": "^7.13.14",
25
+ "@babel/eslint-parser": "7.27.1",
25
26
  "@dword-design/defu": "^1.0.0",
26
- "@dword-design/eslint-plugin-import-alias": "^5.0.0",
27
- "@dword-design/functions": "^6.0.0",
27
+ "@dword-design/eslint-plugin-import-alias": "^5.1.2",
28
+ "@eslint/compat": "^1.2.9",
29
+ "@eslint/eslintrc": "^3.3.1",
30
+ "@eslint/js": "^9.27.0",
28
31
  "confusing-browser-globals": "^1.0.11",
29
- "depcheck-package-name": "^3.0.0",
30
- "eslint-config-airbnb-base": "^15.0.0",
31
- "eslint-config-prettier": "^10.0.0",
32
- "eslint-import-resolver-babel-module": "^5.3.0",
33
- "eslint-import-resolver-exports": "^1.0.0-beta.5",
34
- "eslint-plugin-github": "^5.0.0",
32
+ "depcheck-package-name": "^3.0.1",
33
+ "eslint": "^9.27.0",
34
+ "eslint-config-prettier": "^10.1.5",
35
+ "eslint-import-resolver-babel-module": "^5.3.2",
36
+ "eslint-import-resolver-exports": "1.0.0-beta.5",
35
37
  "eslint-plugin-import": "npm:@dword-design/eslint-plugin-import@^0.1.0",
36
- "eslint-plugin-json-format": "^2.0.1",
38
+ "eslint-plugin-jsonc": "^2.20.1",
37
39
  "eslint-plugin-playwright": "^2.2.0",
38
- "eslint-plugin-prefer-arrow": "^1.1.6",
39
- "eslint-plugin-prettier": "^5.1.3",
40
- "eslint-plugin-promise": "^7.0.0",
41
- "eslint-plugin-simple-import-sort": "^12.1.0",
42
- "eslint-plugin-sort-keys-fix": "^1.1.1",
43
- "eslint-plugin-unicorn": "^56.0.0",
44
- "eslint-plugin-vue": "^10.0.0",
40
+ "eslint-plugin-prefer-arrow": "^1.2.3",
41
+ "eslint-plugin-prettier": "^5.4.0",
42
+ "eslint-plugin-promise": "^7.2.1",
43
+ "eslint-plugin-simple-import-sort": "^12.1.1",
44
+ "eslint-plugin-sort-keys-fix": "^1.1.2",
45
+ "eslint-plugin-unicorn": "npm:@dword-design/eslint-plugin-unicorn@^0.0.1",
46
+ "eslint-plugin-vue": "^10.1.0",
45
47
  "fs-extra": "^11.3.0",
46
- "jiti": "^1.18.2",
48
+ "globals": "^16.1.0",
47
49
  "load-pkg": "^4.0.0",
48
50
  "lodash-es": "^4.17.21",
49
- "prettier": "^3.2.4",
50
- "prettier-plugin-compactify": "npm:@dword-design/prettier-plugin-compactify@^0.0",
51
- "vue-eslint-parser": "^9.1.1"
51
+ "prettier": "^3.5.3",
52
+ "sort-package-json": "^3.2.1"
52
53
  },
53
54
  "devDependencies": {
54
- "@dword-design/base": "^11.0.1",
55
+ "@dword-design/base": "^11.3.14",
56
+ "@dword-design/functions": "^6.0.2",
55
57
  "@playwright/test": "^1.52.0",
56
- "eslint": "^8.35.0",
57
- "execa": "^9.3.0",
58
+ "execa": "^9.5.3",
58
59
  "in-folder": "^1.0.3",
59
- "node-version": "^3.0.0",
60
- "output-files": "^2.0.0",
61
- "with-local-tmp-dir": "^5.0.0"
60
+ "output-files": "^2.0.32",
61
+ "with-local-tmp-dir": "^5.1.1"
62
62
  },
63
63
  "packageManager": "pnpm@10.4.0+sha512.6b849d0787d97f8f4e1f03a9b8ff8f038e79e153d6f11ae539ae7c435ff9e796df6a862c991502695c7f9e8fac8aeafc1ac5a8dab47e36148d183832d886dd52",
64
64
  "engines": {
@@ -1,4 +0,0 @@
1
- const jiti = require('jiti')(__filename, { interopDefault: true })
2
- const api = jiti('.')
3
-
4
- module.exports = api