@scayle/eslint-config-storefront 4.8.2 → 5.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.
package/config/v3.mjs ADDED
@@ -0,0 +1,49 @@
1
+ import { FlatConfigComposer } from 'eslint-flat-config-utils'
2
+ import { storefront } from './index.mjs'
3
+ import { vueConfig } from './v3/vue.mjs'
4
+ import { vueI18nConfig } from './v3/vueI18n.mjs'
5
+ import { vueComposableConfig } from './v3/vueComposable.mjs'
6
+ import { storybookConfig } from './v3/storybook.mjs'
7
+ import { tailwindConfig } from './v3/tailwind.mjs'
8
+
9
+ /**
10
+ * @typedef {object} EslintConfigStorefrontV3Options
11
+ * @property {object} [typescript] Options forwarded to `typescriptConfig` (see `storefront`).
12
+ * @property {string} [typescript.tsconfigPath] Enables type-aware TypeScript rules when set.
13
+ * @property {object} tailwind Tailwind CSS settings.
14
+ * @property {string} tailwind.entryPoint Path to the project's Tailwind CSS entry point.
15
+ * @property {object} i18n `vue-i18n` linting settings.
16
+ * @property {string} i18n.localeDir Glob pointing at the project's locale JSON files.
17
+ * @property {string} [i18n.messageSyntaxVersion] `vue-i18n` message syntax version.
18
+ * @property {string[]} [i18n.unusedKeyIgnores] Regex-string patterns for dynamically-used keys.
19
+ * @property {object} [vue] Vue rule settings.
20
+ * @property {string[]} [vue.undefComponentIgnores] Custom element tag names exempt from `vue/no-undef-components`.
21
+ * @property {object} [vueComposable] `@scayle/vue-composable` rule settings.
22
+ * @property {string[]} [vueComposable.fallthroughAttrsIgnores] Path fragments exempt from `require-explicit-fallthrough-attrs`.
23
+ */
24
+
25
+ /**
26
+ * Builds the SCAYLE Storefront ESLint flat config for the Storefront Application V3 stack
27
+ * (Hono + Inertia.js + Vue 3, not Nuxt). Extends `storefront()` with Vue language wiring,
28
+ * Vue rules, accessibility rules, `vue-i18n` rules, `@scayle/vue-composable` rules,
29
+ * Storybook file conventions, and Tailwind CSS class validation. Kept separate from
30
+ * `storefront()`/`storefrontNuxt()` since those two stay framework-agnostic.
31
+ *
32
+ * @param {EslintConfigStorefrontV3Options} config
33
+ * @returns {FlatConfigComposer<import('eslint').Linter.Config, never>} Returns a FlatConfigComposer object to be consumed in projects eslint.config.mjs files
34
+ */
35
+ export const storefrontV3 = function (config) {
36
+ const { typescript, tailwind, i18n, vue, vueComposable } = config ?? {}
37
+
38
+ /** @type {FlatConfigComposer<import('eslint').Linter.Config, never>} */
39
+ const flatConfigComposer = new FlatConfigComposer()
40
+
41
+ return flatConfigComposer.append(
42
+ storefront({ typescript }),
43
+ ...tailwindConfig(tailwind),
44
+ ...storybookConfig(),
45
+ ...vueConfig(vue),
46
+ ...vueI18nConfig(i18n),
47
+ ...vueComposableConfig(vueComposable),
48
+ )
49
+ }
@@ -0,0 +1,30 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { storefrontV3 } from './v3.mjs'
3
+
4
+ describe('storefrontV3', () => {
5
+ it('throws without tailwind.entryPoint', () => {
6
+ expect(() =>
7
+ // @ts-expect-error missing required `tailwind`, exercising the runtime guard
8
+ storefrontV3({ i18n: { localeDir: './src/i18n/locales/*.json' } }),
9
+ ).toThrow('config.tailwind.entryPoint is required')
10
+ })
11
+
12
+ it('throws without i18n.localeDir', () => {
13
+ expect(() =>
14
+ // @ts-expect-error missing required `i18n`, exercising the runtime guard
15
+ storefrontV3({ tailwind: { entryPoint: './src/client/index.css' } }),
16
+ ).toThrow('config.i18n.localeDir is required')
17
+ })
18
+
19
+ it('returns a config with both required options set', async () => {
20
+ const config = storefrontV3({
21
+ tailwind: { entryPoint: './src/client/index.css' },
22
+ i18n: { localeDir: './src/i18n/locales/*.json' },
23
+ })
24
+
25
+ const resolved = await config.toConfigs()
26
+
27
+ expect(Array.isArray(resolved)).toBe(true)
28
+ expect(resolved.length).toBeGreaterThan(0)
29
+ })
30
+ })
package/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
- import { eslintConfigStorefront } from './config/flat/index.mjs'
1
+ import { storefront } from './config/index.mjs'
2
2
 
3
- export default eslintConfigStorefront
3
+ export default storefront
4
+ export { storefront }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/eslint-config-storefront",
3
- "version": "4.8.2",
3
+ "version": "5.0.0",
4
4
  "description": "SCAYLE Commerce Engine specific eslint configuration",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -17,46 +17,65 @@
17
17
  "type": "module",
18
18
  "exports": {
19
19
  ".": "./index.mjs",
20
- "./config/flat/index.mjs": "./config/flat/index.mjs",
21
- "./config/flat/sonarjs": "./config/flat/sonarjs.mjs",
22
- "./config/flat/promise.mjs": "./config/flat/promise.mjs",
23
- "./config/flat/importX.mjs": "./config/flat/importX.mjs"
20
+ "./nuxt": "./storefront-nuxt.mjs",
21
+ "./v3": "./storefront-v3.mjs"
24
22
  },
25
23
  "main": "./index.mjs",
26
24
  "files": [
27
25
  "CHANGELOG.md",
28
26
  "README.md",
29
27
  "./index.mjs",
28
+ "./storefront-nuxt.mjs",
29
+ "./storefront-v3.mjs",
30
30
  "./config/"
31
31
  ],
32
32
  "engines": {
33
33
  "node": ">= 22.0.0"
34
34
  },
35
35
  "peerDependencies": {
36
- "eslint": ">=9.0.0",
36
+ "eslint": ">=10.4.0",
37
37
  "typescript": ">=5.4.0"
38
38
  },
39
39
  "dependencies": {
40
- "@antfu/eslint-config": "^9.0.0",
41
- "@eslint/eslintrc": "^3.3.5",
42
- "eslint-config-flat-gitignore": "^2.2.0",
40
+ "@e18e/eslint-plugin": "^0.8.0",
41
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.7.2",
42
+ "@eslint/js": "^10.0.0",
43
+ "@intlify/eslint-plugin-vue-i18n": "^4.5.1",
44
+ "@vitest/eslint-plugin": "^1.6.20",
45
+ "eslint-config-flat-gitignore": "^2.3.0",
43
46
  "eslint-flat-config-utils": "^3.2.0",
44
- "eslint-plugin-import-x": "^4.16.2",
47
+ "eslint-plugin-better-tailwindcss": "^4.7.0",
48
+ "eslint-plugin-import-x": "^4.17.1",
49
+ "eslint-plugin-jsdoc": "^64.2.1",
50
+ "eslint-plugin-jsonc": "^3.4.1",
51
+ "eslint-plugin-n": "^18.3.0",
52
+ "eslint-plugin-no-only-tests": "^3.4.0",
45
53
  "eslint-plugin-promise": "^7.3.0",
46
- "eslint-plugin-sonarjs": "^4.0.3",
47
- "local-pkg": "^1.2.1",
48
- "typescript-eslint": "8.65.0"
54
+ "eslint-plugin-regexp": "^3.2.0",
55
+ "eslint-plugin-sonarjs": "^4.2.0",
56
+ "eslint-plugin-storybook": "^10.5.8",
57
+ "eslint-plugin-unicorn": "^73.0.0",
58
+ "eslint-plugin-vue": "^10.10.0",
59
+ "eslint-plugin-vuejs-accessibility": "^2.6.0",
60
+ "globals": "^17.7.0",
61
+ "typescript-eslint": "^8.67.0",
62
+ "vue-eslint-parser": "^10.4.1",
63
+ "@scayle/eslint-plugin-vue-composable": "1.2.1"
49
64
  },
50
65
  "devDependencies": {
51
- "eslint": "10.8.0",
66
+ "@types/node": "^24",
67
+ "@vitest/coverage-v8": "4.1.11",
68
+ "eslint": "10.8.1",
52
69
  "eslint-formatter-gitlab": "7.2.0",
53
- "publint": "0.3.22",
54
- "typescript": "6.0.3"
70
+ "publint": "0.3.23",
71
+ "typescript": "6.0.3",
72
+ "vitest": "4.1.11"
55
73
  },
56
74
  "scripts": {
57
75
  "lint": "eslint .",
58
76
  "lint:ci": "eslint . --format gitlab",
59
77
  "lint:fix": "eslint . --fix",
60
- "package:lint": "publint"
78
+ "package:lint": "publint",
79
+ "typecheck": "tsc"
61
80
  }
62
81
  }
@@ -0,0 +1,4 @@
1
+ import { storefrontNuxt } from './config/index.mjs'
2
+
3
+ export default storefrontNuxt
4
+ export { storefrontNuxt }
@@ -0,0 +1,4 @@
1
+ import { storefrontV3 } from './config/v3.mjs'
2
+
3
+ export default storefrontV3
4
+ export { storefrontV3 }
@@ -1,22 +0,0 @@
1
- import { importX as pluginImportX } from 'eslint-plugin-import-x'
2
-
3
- // Pre-defined rule configurations for better performance
4
- const IMPORT_X_RULES = {
5
- 'import-x/consistent-type-specifier-style': ['error', 'prefer-top-level'],
6
- 'import-x/first': 'error',
7
- 'import-x/no-duplicates': 'error',
8
- 'import-x/no-mutable-exports': 'error',
9
- 'import-x/no-named-default': 'error',
10
- 'import-x/no-self-import': 'error',
11
- 'import-x/no-extraneous-dependencies': 'error',
12
- }
13
-
14
- export function importX() {
15
- return [
16
- {
17
- name: 'storefront/import-x/rules',
18
- plugins: { 'import-x': pluginImportX },
19
- rules: IMPORT_X_RULES,
20
- },
21
- ]
22
- }
@@ -1,155 +0,0 @@
1
- import { FlatConfigComposer } from 'eslint-flat-config-utils'
2
- import { isPackageExists } from 'local-pkg'
3
- import {
4
- GLOB_TESTS,
5
- combine,
6
- comments,
7
- ignores,
8
- javascript,
9
- jsdoc,
10
- jsonc,
11
- node,
12
- test,
13
- typescript,
14
- } from '@antfu/eslint-config'
15
- import gitignore from 'eslint-config-flat-gitignore'
16
- import tseslint from 'typescript-eslint'
17
- import { sonarjs } from './sonarjs.mjs'
18
- import { promise } from './promise.mjs'
19
- import { importX } from './importX.mjs'
20
-
21
- // Partial eslint config by `@antfu/eslint-config`
22
- // <https://github.com/antfu/eslint-config/blob/main/README.md>
23
-
24
- /**
25
- * @param {object=} config
26
- * @param {boolean=} config.isNuxt
27
- * @param {object=} config.typescript
28
- * @param {string=} config.typescript.tsconfigPath
29
- * @returns {FlatConfigComposer<Linter.FlatConfig<Linter.RulesRecord>, never>} Returns a FlatConfigComposer object to be consumed in projects eslint.config.mjs files
30
- */
31
- export const eslintConfigStorefront = function (
32
- config = {
33
- isNuxt: isPackageExists('@nuxt/eslint'),
34
- typescript: { tsconfigPath: undefined },
35
- },
36
- ) {
37
- const flatConfigComposer = new FlatConfigComposer()
38
- const isNuxtProject = config.isNuxt
39
-
40
- // Pre-defined rule configurations for better performance
41
- const TYPESCRIPT_JSON_RULES = {
42
- '@typescript-eslint/ban-ts-comment': 'off',
43
- '@typescript-eslint/no-array-constructor': 'off',
44
- '@typescript-eslint/no-duplicate-enum-values': 'off',
45
- '@typescript-eslint/no-empty-object-type': 'off',
46
- '@typescript-eslint/no-explicit-any': 'off',
47
- '@typescript-eslint/no-extra-non-null-assertion': 'off',
48
- '@typescript-eslint/no-misused-new': 'off',
49
- '@typescript-eslint/no-namespace': 'off',
50
- '@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
51
- '@typescript-eslint/no-require-imports': 'off',
52
- '@typescript-eslint/no-this-alias': 'off',
53
- '@typescript-eslint/no-unnecessary-type-constraint': 'off',
54
- '@typescript-eslint/no-unsafe-declaration-merging': 'off',
55
- '@typescript-eslint/no-unsafe-function-type': 'off',
56
- '@typescript-eslint/no-unused-expressions': 'off',
57
- '@typescript-eslint/no-unused-vars': 'off',
58
- '@typescript-eslint/no-wrapper-object-types': 'off',
59
- '@typescript-eslint/prefer-as-const': 'off',
60
- '@typescript-eslint/prefer-namespace-keyword': 'off',
61
- '@typescript-eslint/triple-slash-reference': 'off',
62
- }
63
-
64
- const CURLY_RULE = ['error', 'all']
65
-
66
- const TYPESCRIPT_RULES = {
67
- curly: CURLY_RULE,
68
- '@typescript-eslint/no-explicit-any': ['warn', { ignoreRestArgs: true }],
69
- '@typescript-eslint/no-empty-object-type': [
70
- 'error',
71
- {
72
- allowInterfaces: 'always',
73
- },
74
- ],
75
- '@typescript-eslint/no-unused-vars': [
76
- 'error',
77
- {
78
- args: 'all',
79
- argsIgnorePattern: '^_',
80
- caughtErrors: 'all',
81
- caughtErrorsIgnorePattern: '^_',
82
- destructuredArrayIgnorePattern: '^_',
83
- varsIgnorePattern: '^_',
84
- ignoreRestSiblings: true,
85
- },
86
- ],
87
- }
88
-
89
- const BASE_CONFIGS = [
90
- comments(),
91
- node(),
92
- jsonc(),
93
- test(),
94
- sonarjs(),
95
- promise(),
96
- ]
97
-
98
- const GLOBAL_RULES = {
99
- curly: CURLY_RULE,
100
- 'node/prefer-global/process': 'off',
101
- }
102
-
103
- const TEST_RULES = {
104
- 'no-console': 'off',
105
- '@typescript-eslint/no-explicit-any': 'off',
106
- 'promise/avoid-new': 'off',
107
- }
108
-
109
- const IGNORE_PATTERNS = ['**/fixtures/**/*', '**/*.jsonc']
110
-
111
- // The following rules are already handled by `@nuxt/eslint` and
112
- // don't need to be extended from `@antfu/eslint-config` if it is used
113
- const nonNuxtRules = !isNuxtProject
114
- ? combine(
115
- gitignore(),
116
- ignores(),
117
- importX(),
118
- javascript(),
119
- typescript(config.typescript),
120
- jsdoc(),
121
- tseslint.configs.recommended,
122
- [{ rules: TYPESCRIPT_RULES }],
123
- )
124
- : {}
125
-
126
- const configs = [
127
- combine(...BASE_CONFIGS),
128
- nonNuxtRules,
129
- {
130
- rules: GLOBAL_RULES,
131
- ignores: [IGNORE_PATTERNS[0]],
132
- },
133
- {
134
- files: ['**/*.json'],
135
- rules: TYPESCRIPT_JSON_RULES,
136
- },
137
- {
138
- files: GLOB_TESTS,
139
- rules: TEST_RULES,
140
- },
141
- { ignores: [IGNORE_PATTERNS[1]] },
142
- // Set tsconfigRootDir for all TypeScript files to support monorepo structure
143
- // This ensures ESLint uses the correct tsconfig.json when multiple exist
144
- {
145
- files: ['**/*.mjs', '**/*.cjs', '**/*.ts', '**/*.tsx'],
146
- languageOptions: {
147
- parserOptions: {
148
- tsconfigRootDir: process.cwd(),
149
- },
150
- },
151
- },
152
- ]
153
-
154
- return flatConfigComposer.append(...configs)
155
- }
@@ -1,28 +0,0 @@
1
- import pluginPromise from 'eslint-plugin-promise'
2
-
3
- // Pre-defined rule configurations for better performance
4
- const PROMISE_RULES = {
5
- 'promise/no-multiple-resolved': 'error',
6
- 'promise/no-new-statics': 'error',
7
- 'promise/no-return-wrap': 'error',
8
- 'promise/always-return': 'warn',
9
- 'promise/avoid-new': 'warn',
10
- 'promise/catch-or-return': 'warn',
11
- 'promise/no-callback-in-promise': 'warn',
12
- 'promise/no-nesting': 'warn',
13
- 'promise/no-promise-in-callback': 'warn',
14
- 'promise/no-return-in-finally': 'warn',
15
- 'promise/param-names': 'warn',
16
- 'promise/valid-params': 'warn',
17
- 'promise/no-native': 'off',
18
- }
19
-
20
- export function promise() {
21
- return [
22
- {
23
- name: 'storefront/promise/rules',
24
- plugins: { promise: pluginPromise },
25
- rules: PROMISE_RULES,
26
- },
27
- ]
28
- }
@@ -1,19 +0,0 @@
1
- import pluginSonarjs from 'eslint-plugin-sonarjs'
2
-
3
- // Pre-defined rule configurations for better performance
4
- const SONARJS_RULES = {
5
- 'sonarjs/no-duplicate-string': 'off',
6
- 'sonarjs/todo-tag': 'warn',
7
- 'sonarjs/fixme-tag': 'warn',
8
- }
9
-
10
- export function sonarjs() {
11
- return [
12
- pluginSonarjs.configs.recommended,
13
- {
14
- name: 'storefront/sonarjs/rules',
15
- plugins: { pluginSonarjs },
16
- rules: SONARJS_RULES,
17
- },
18
- ]
19
- }