@soleil-se/eslint-config 6.1.0 → 6.2.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/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ All changes in this repository are noted here.
7
7
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8
8
  and the project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9
9
 
10
+ ## [6.2.1] - 2025-04-01
11
+
12
+ * Set `svelte/require-each-key` as warning instead of error.
13
+
14
+ ## [6.2.0] - 2025-03-31
15
+
16
+ * Update `eslint-plugin-svelte` version 3.
17
+ * Enable `svelte/html-self-closing`.
18
+ * Enable `svelte/prefer-const`.
19
+ * Allow caught errors to unused in `no-unused-vars`.
20
+ * Add path group override for `#` in `import/extensions`.
21
+
10
22
  ## [6.1.0] - 2025-03-18
11
23
 
12
24
  * Adjust config for script modules to correct sourceType.
package/bin/index.js CHANGED
File without changes
package/config/base.js ADDED
@@ -0,0 +1,30 @@
1
+ import globals from 'globals';
2
+ import importPlugin from 'eslint-plugin-import';
3
+ import jsRules from '../rules/js/index.js';
4
+
5
+ export default function base() {
6
+ return [{
7
+ name: 'soleil/base',
8
+ languageOptions: {
9
+ ecmaVersion: 'latest',
10
+ sourceType: 'module',
11
+ globals: {
12
+ process: 'readonly',
13
+ Packages: 'readonly',
14
+ envision: 'readonly',
15
+ ...globals.browser,
16
+ },
17
+ },
18
+ ignores: ['dist', 'node_modules', 'prettier.config.js'],
19
+ plugins: { import: importPlugin },
20
+ rules: jsRules,
21
+ settings: {
22
+ svelte: {
23
+ // Ignore max-len in template and style, still works for script tags.
24
+ ignoreWarnings: [
25
+ 'max-len',
26
+ ],
27
+ },
28
+ },
29
+ }];
30
+ }
@@ -0,0 +1,31 @@
1
+ import svelteRules from '../rules/svelte/index.js';
2
+
3
+ async function hasSvelte() {
4
+ try {
5
+ await import('svelte');
6
+ return true;
7
+ } catch (e) {
8
+ return false;
9
+ }
10
+ }
11
+
12
+ export default async function svelte() {
13
+ if (!await hasSvelte()) return [];
14
+
15
+ const { default: eslintPluginSvelte } = await import('eslint-plugin-svelte');
16
+ const { default: eslintConfigPrettier } = await import('eslint-config-prettier');
17
+
18
+ return [
19
+ ...eslintPluginSvelte.configs.recommended,
20
+ ...eslintPluginSvelte.configs.prettier,
21
+ {
22
+ name: 'soleil/svelte',
23
+ files: ['**/*.svelte', '**/*.svelte.js', '**/*.svelte.ts'],
24
+ rules: svelteRules,
25
+ }, {
26
+ name: 'soleil/svelte.prettier',
27
+ files: ['**/*.svelte'],
28
+ rules: eslintConfigPrettier.rules,
29
+ },
30
+ ];
31
+ }
package/eslint.config.js CHANGED
@@ -2,4 +2,9 @@ import config from './node-config.js';
2
2
 
3
3
  export default [
4
4
  ...config,
5
+ {
6
+ rules: {
7
+ 'import/no-extraneous-dependencies': 0,
8
+ },
9
+ },
5
10
  ];
package/index.js CHANGED
@@ -1,70 +1,7 @@
1
- import globals from 'globals';
2
- import importPlugin from 'eslint-plugin-import';
3
-
4
- import jsRules from './rules/js/index.js';
5
- import svelteRules from './rules/svelte/index.js';
6
-
7
- function loadSvelteConfig() {
8
- // eslint-disable-next-line import/no-extraneous-dependencies
9
- return import('svelte').then(async () => {
10
- const { default: eslintPluginSvelte } = await import('eslint-plugin-svelte');
11
- const { default: eslintConfigPrettier } = await import('eslint-config-prettier');
12
- return [
13
- ...eslintPluginSvelte.configs['flat/recommended'],
14
- ...eslintPluginSvelte.configs['flat/prettier'],
15
- {
16
- name: 'soleil/svelte',
17
- files: ['**/*.svelte'],
18
- rules: {
19
- ...svelteRules,
20
- ...eslintConfigPrettier.rules,
21
- },
22
- }, {
23
- name: 'soleil/svelte.js',
24
- files: ['**/*.svelte.js', '**/*.svelte.ts'],
25
- languageOptions: {
26
- ecmaVersion: 'latest',
27
- sourceType: 'module',
28
- globals: {
29
- $state: 'readonly',
30
- $derived: 'readonly',
31
- $effect: 'readonly',
32
- $inspect: 'readonly',
33
- },
34
- },
35
- rules: {
36
- // Do not enforce const because of reactivity for runes in Svelte 5.
37
- 'prefer-const': 0,
38
- },
39
- },
40
- ];
41
- }).catch(() => []);
42
- }
1
+ import base from './config/base.js';
2
+ import svelte from './config/svelte.js';
43
3
 
44
4
  export default [
45
- {
46
- name: 'soleil/base',
47
- languageOptions: {
48
- ecmaVersion: 'latest',
49
- sourceType: 'module',
50
- globals: {
51
- process: 'readonly',
52
- Packages: 'readonly',
53
- envision: 'readonly',
54
- ...globals.browser,
55
- },
56
- },
57
- ignores: ['dist', 'node_modules', 'prettier.config.js'],
58
- plugins: { import: importPlugin },
59
- rules: jsRules,
60
- settings: {
61
- svelte: {
62
- // Ignore max-len in template and style, still works for script tags.
63
- ignoreWarnings: [
64
- 'max-len',
65
- ],
66
- },
67
- },
68
- },
69
- ...await loadSvelteConfig(),
5
+ ...base(),
6
+ ...await svelte(),
70
7
  ];
package/node-config.js CHANGED
@@ -1,9 +1,11 @@
1
- import config from './index.js';
1
+ import base from './config/base.js';
2
2
 
3
- export default [...config, {
4
- rules: {
5
- 'import/extensions': ['error', 'ignorePackages', {
6
- js: 'always',
7
- }],
8
- },
9
- }];
3
+ export default [
4
+ ...base(),
5
+ {
6
+ rules: {
7
+ 'import/extensions': ['error', 'ignorePackages', {
8
+ js: 'always',
9
+ }],
10
+ },
11
+ }];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soleil-se/eslint-config",
3
- "version": "6.1.0",
3
+ "version": "6.2.1",
4
4
  "description": "ESLint configuration for Sitevision apps and projects.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -19,19 +19,23 @@
19
19
  "./prettier": "./prettier.js",
20
20
  "./script-module": "./script-module.js",
21
21
  "./node": "./node-config.js",
22
- "./rules":"./rules/**/*.js"
22
+ "./typescript": "./typescript.js",
23
+ "./config/base": "./config/base.js",
24
+ "./config/svelte": "./config/svelte.js",
25
+ "./rules/js": "./rules/js/index.js",
26
+ "./rules/svelte": "./rules/svelte/index.js"
23
27
  },
24
28
  "dependencies": {
25
- "eslint-config-prettier": "^10.0.1",
29
+ "eslint-config-prettier": "^10.1.1",
26
30
  "eslint-plugin-import": "^2.31.0",
27
- "eslint-plugin-svelte": "^2.46.1",
28
- "globals": "^15.14.0"
31
+ "eslint-plugin-svelte": "^3.4.0",
32
+ "globals": "^16.0.0"
29
33
  },
30
34
  "devDependencies": {
31
- "eslint": "^9.18.0",
32
- "svelte": "^5.17.4"
35
+ "eslint": "^9.23.0",
36
+ "svelte": "^5.25.3"
33
37
  },
34
38
  "peerDependencies": {
35
39
  "eslint": ">= 9"
36
40
  }
37
- }
41
+ }
@@ -89,11 +89,24 @@ export default {
89
89
 
90
90
  // Ensure consistent use of file extension within the import path
91
91
  // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/extensions.md
92
- 'import/extensions': ['error', 'ignorePackages', {
93
- js: 'never',
94
- mjs: 'never',
95
- jsx: 'never',
96
- }],
92
+
93
+ 'import/extensions': ['error', {
94
+ ignorePackages: true,
95
+ pattern: {
96
+ js: 'never',
97
+ mjs: 'never',
98
+ jsx: 'never',
99
+ json: 'always',
100
+ },
101
+ pathGroupOverrides: [{
102
+ pattern: '**/*.svelte.js',
103
+ action: 'ignore',
104
+ }, {
105
+ pattern: '#*',
106
+ action: 'ignore',
107
+ }],
108
+ },
109
+ ],
97
110
 
98
111
  // ensure absolute imports are above relative imports and that unassigned imports are ignored
99
112
  // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/order.md
@@ -109,7 +109,7 @@ export default {
109
109
  'no-undefined': 'off',
110
110
 
111
111
  // disallow declaration of variables that are not used in the code
112
- 'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }],
112
+ 'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true, caughtErrors: 'none' }],
113
113
 
114
114
  // disallow use of variables before they are defined
115
115
  'no-use-before-define': ['error', { functions: true, classes: true, variables: true }],
@@ -5,4 +5,6 @@ export default {
5
5
  'svelte/no-reactive-literals': 'warn',
6
6
  'svelte/no-useless-mustaches': 'warn',
7
7
  'svelte/no-unused-svelte-ignore': 0,
8
+ 'svelte/prefer-const': 'error',
9
+ 'svelte/require-each-key': 'warn',
8
10
  };
@@ -1,6 +1,47 @@
1
1
  export default {
2
2
  'svelte/no-extra-reactive-curlies': 'warn',
3
3
  'svelte/prefer-style-directive': 'warn',
4
- 'svelte/sort-attributes': 'warn',
5
4
  'svelte/spaced-html-comment': 'warn',
5
+ 'svelte/html-self-closing': 'warn',
6
+ 'svelte/html-quotes': 'warn',
7
+ 'svelte/sort-attributes': [
8
+ 'warn', {
9
+ order: [
10
+ // `this` property.
11
+ 'this',
12
+ // `bind:this` directive.
13
+ 'bind:this',
14
+ // `id` attribute.
15
+ 'id',
16
+ // `name` attribute.
17
+ 'name',
18
+ // `slot` attribute.
19
+ 'slot',
20
+ // `--style-props` (Alphabetical order within the same group.)
21
+ { match: '/^--/u', sort: 'alphabetical' },
22
+ // `style` attribute, and `style:` directives.
23
+ ['style', '/^style:/u'],
24
+ // `class` attribute.
25
+ 'class',
26
+ // `class:` directives. (Alphabetical order within the same group.)
27
+ { match: '/^class:/u', sort: 'alphabetical' },
28
+ // other attributes.
29
+ ['!/:/u', '!/^(?:this|id|name|style|class)$/u', '!/^--/u'],
30
+ // `bind:` directives (other then `bind:this`), and `on:` directives.
31
+ ['/^bind:/u', '!bind:this', '/^on:/u'],
32
+ // `use:` directives. (Alphabetical order within the same group.)
33
+ { match: '/^use:/u', sort: 'alphabetical' },
34
+ // `transition:` directive.
35
+ { match: '/^transition:/u', sort: 'alphabetical' },
36
+ // `in:` directive.
37
+ { match: '/^in:/u', sort: 'alphabetical' },
38
+ // `out:` directive.
39
+ { match: '/^out:/u', sort: 'alphabetical' },
40
+ // `animate:` directive.
41
+ { match: '/^animate:/u', sort: 'alphabetical' },
42
+ // `let:` directives. (Alphabetical order within the same group.)
43
+ { match: '/^let:/u', sort: 'alphabetical' },
44
+ ],
45
+ },
46
+ ],
6
47
  };
package/typescript.js ADDED
@@ -0,0 +1,22 @@
1
+ // eslint-disable-next-line import/no-unresolved
2
+ import tseslint from 'typescript-eslint';
3
+ import base from './config/base.js';
4
+ import svelte from './config/svelte.js';
5
+
6
+ const svelteTypescript = {
7
+ files: ['**/*.svelte', '**/*.svelte.js', '**/*.svelte.ts'],
8
+ languageOptions: {
9
+ parserOptions: {
10
+ projectService: true,
11
+ extraFileExtensions: ['.svelte'],
12
+ parser: tseslint.parser,
13
+ },
14
+ },
15
+ };
16
+
17
+ export default tseslint.config(
18
+ ...base(),
19
+ tseslint.configs.recommended,
20
+ ...await svelte(),
21
+ svelteTypescript,
22
+ );