@koffeine/eslint-config-svelte 1.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/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © Kornél Horváth
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ <h1>
2
+ eslint-config-svelte
3
+ <a href="https://www.npmjs.com/package/@koffeine/eslint-config-svelte"><img alt="npm" src="https://img.shields.io/npm/v/@koffeine/eslint-config-svelte"></a>
4
+ </h1>
5
+
6
+ Koffeine's ESLint shareable config for Svelte
7
+
8
+ ## Installation
9
+
10
+ ```sh
11
+ npm install --save-dev @koffeine/eslint-config-svelte eslint svelte
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ Add the following to your `eslint.config.js` file:
17
+
18
+ ```js
19
+ import koffeineSvelte from '@koffeine/eslint-config-svelte';
20
+
21
+ export default [
22
+ ...koffeineSvelte
23
+ ];
24
+ ```
25
+
26
+ ## License
27
+
28
+ Copyright © Kornél Horváth
29
+
30
+ Licensed under the [MIT License](https://raw.githubusercontent.com/koffeine/eslint-config-svelte/master/LICENSE).
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import type { Linter } from 'eslint';
2
+
3
+ declare const config: Linter.Config[];
4
+
5
+ export default config;
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@koffeine/eslint-config-svelte",
3
+ "version": "1.0.0",
4
+ "description": "Koffeine's ESLint shareable config for Svelte",
5
+ "keywords": [
6
+ "eslint",
7
+ "eslintconfig",
8
+ "svelte"
9
+ ],
10
+ "homepage": "https://github.com/koffeine/eslint-config-svelte",
11
+ "bugs": {
12
+ "url": "https://github.com/koffeine/eslint-config-svelte/issues"
13
+ },
14
+ "license": "MIT",
15
+ "author": "Kornél Horváth <kornel.horvath@me.com>",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/koffeine/eslint-config-svelte.git"
19
+ },
20
+ "files": [
21
+ "src",
22
+ "index.d.ts"
23
+ ],
24
+ "exports": {
25
+ ".": {
26
+ "types": "./index.d.ts",
27
+ "default": "./src/index.js"
28
+ }
29
+ },
30
+ "type": "module",
31
+ "scripts": {
32
+ "test": "eslint && tsc -p jsconfig.json && node test",
33
+ "prepublishOnly": "npm test"
34
+ },
35
+ "dependencies": {
36
+ "eslint-plugin-svelte": "3.10.1",
37
+ "svelte-eslint-parser": "^1.2.0"
38
+ },
39
+ "devDependencies": {
40
+ "@koffeine/eslint-config": "44.4.0",
41
+ "@types/node": "^22",
42
+ "@types/punycode": "^2",
43
+ "@typescript-eslint/parser": "^8",
44
+ "eslint": "9.31.0",
45
+ "globals": "^16",
46
+ "svelte": "^5",
47
+ "typescript": "^5"
48
+ },
49
+ "peerDependencies": {
50
+ "eslint": "^9.0.0",
51
+ "svelte": "^5.0.0"
52
+ }
53
+ }
package/src/index.js ADDED
@@ -0,0 +1,134 @@
1
+ import svelteParser from 'svelte-eslint-parser';
2
+ import sveltePlugin from 'eslint-plugin-svelte';
3
+
4
+ /** @type {import('eslint').Linter.Config[]} */
5
+ export default [
6
+ {
7
+ name: 'koffeine/svelte/base',
8
+ files: [ '**/*.svelte.js', '**/*.svelte' ],
9
+ languageOptions: {
10
+ parser: svelteParser
11
+ },
12
+ plugins: {
13
+ svelte: sveltePlugin
14
+ },
15
+ rules: {
16
+ // POSSIBLE ERRORS
17
+
18
+ 'svelte/infinite-reactive-loop': 'off', // legacy
19
+ 'svelte/no-dom-manipulating': 'error',
20
+ 'svelte/no-dupe-else-if-blocks': 'error',
21
+ 'svelte/no-dupe-on-directives': 'error',
22
+ 'svelte/no-dupe-style-properties': 'error',
23
+ 'svelte/no-dupe-use-directives': 'error',
24
+ 'svelte/no-not-function-handler': 'error',
25
+ 'svelte/no-object-in-text-mustaches': 'error',
26
+ 'svelte/no-raw-special-elements': 'error',
27
+ 'svelte/no-reactive-reassign': 'off', // legacy
28
+ 'svelte/no-shorthand-style-property-overrides': 'error',
29
+ 'svelte/no-store-async': 'error',
30
+ 'svelte/no-top-level-browser-globals': 'off', // SSR
31
+ 'svelte/no-unknown-style-directive-property': 'error',
32
+ 'svelte/require-store-callbacks-use-set-param': 'error',
33
+ 'svelte/require-store-reactive-access': 'error',
34
+ 'svelte/valid-compile': [ 'error', { ignoreWarnings: false } ],
35
+ 'svelte/valid-style-parse': 'error',
36
+
37
+ // SECURITY VULNERABILITY
38
+
39
+ 'svelte/no-at-html-tags': 'error',
40
+ 'svelte/no-target-blank': [ 'error', { allowReferrer: false, enforceDynamicLinks: 'always' } ],
41
+
42
+ // BEST PRACTICES
43
+
44
+ 'svelte/block-lang': 'off',
45
+ 'svelte/button-has-type': [ 'error', { button: true, submit: true, reset: true } ],
46
+ 'svelte/no-add-event-listener': 'error',
47
+ 'svelte/no-at-debug-tags': 'warn',
48
+ 'svelte/no-ignored-unsubscribe': 'error',
49
+ 'svelte/no-immutable-reactive-statements': 'error',
50
+ 'svelte/no-inline-styles': 'off',
51
+ 'svelte/no-inspect': 'warn',
52
+ 'svelte/no-reactive-functions': 'off', // legacy
53
+ 'svelte/no-reactive-literals': 'off', // legacy
54
+ 'svelte/no-svelte-internal': 'error',
55
+ 'svelte/no-unnecessary-state-wrap': [ 'error', { allowReassign: false } ],
56
+ 'svelte/no-unused-class-name': 'off',
57
+ 'svelte/no-unused-props': 'off', // requires @typescript-eslint/parser
58
+ 'svelte/no-unused-svelte-ignore': 'error',
59
+ 'svelte/no-useless-children-snippet': 'error',
60
+ 'svelte/no-useless-mustaches': [ 'error', { ignoreIncludesComment: false, ignoreStringEscape: false } ],
61
+ 'prefer-const': 'off', 'svelte/prefer-const': [ 'error', { destructuring: 'any', ignoreReadBeforeAssign: false } ],
62
+ 'svelte/prefer-destructured-store-props': 'off',
63
+ 'svelte/prefer-writable-derived': 'error',
64
+ 'svelte/require-each-key': 'error',
65
+ 'svelte/require-event-dispatcher-types': 'off', // legacy
66
+ 'svelte/require-optimized-style-attribute': 'error',
67
+ 'svelte/require-stores-init': 'error',
68
+ 'svelte/valid-each-key': 'error',
69
+
70
+ // STYLISTIC ISSUES
71
+
72
+ 'svelte/consistent-selector-style': 'off',
73
+ 'svelte/derived-has-same-inputs-outputs': 'error',
74
+ 'svelte/first-attribute-linebreak': 'off',
75
+ 'svelte/html-closing-bracket-new-line': 'off',
76
+ 'svelte/html-closing-bracket-spacing': [ 'error', { startTag: 'never', endTag: 'never', selfClosingTag: 'always' } ],
77
+ 'svelte/html-quotes': [ 'error', { prefer: 'double', dynamic: { quoted: false, avoidInvalidUnquotedInHTML: false } } ],
78
+ 'svelte/html-self-closing': [ 'error', { void: 'never', normal: 'never', svg: 'always', math: 'never', component: 'always', svelte: 'always' } ],
79
+ // '@stylistic/indent': 'off', 'svelte/indent': [ 'error', { indent: 'tab', indentScript: false, switchCase: 1, alignAttributesVertically: false } ], // only in .svelte files
80
+ 'svelte/max-attributes-per-line': 'off',
81
+ 'svelte/mustache-spacing': [ 'error', { textExpressions: 'never', attributesAndProps: 'never', directiveExpressions: 'never', tags: { openingBrace: 'never', closingBrace: 'never' } } ],
82
+ 'svelte/no-extra-reactive-curlies': 'error',
83
+ 'svelte/no-restricted-html-elements': 'off',
84
+ 'svelte/no-spaces-around-equal-signs-in-attribute': 'error',
85
+ 'svelte/prefer-class-directive': [ 'error', { prefer: 'empty' } ],
86
+ 'svelte/prefer-style-directive': 'error',
87
+ 'svelte/require-event-prefix': [ 'error', { checkAsyncFunctions: false } ],
88
+ 'svelte/shorthand-attribute': [ 'error', { prefer: 'always' } ],
89
+ 'svelte/shorthand-directive': [ 'error', { prefer: 'always' } ],
90
+ 'svelte/sort-attributes': 'off',
91
+ 'svelte/spaced-html-comment': [ 'error', 'always' ],
92
+
93
+ // EXTENSION RULES
94
+
95
+ 'no-inner-declarations': 'off', 'svelte/no-inner-declarations': [ 'error', 'both', { blockScopedFunctions: 'allow' } ],
96
+ '@stylistic/no-trailing-spaces': 'off', 'svelte/no-trailing-spaces': [ 'error', { skipBlankLines: false, ignoreComments: false } ],
97
+
98
+ // SVELTEKIT
99
+
100
+ 'svelte/no-export-load-in-svelte-module-in-kit-pages': 'off',
101
+ 'svelte/no-navigation-without-base': 'off',
102
+ 'svelte/valid-prop-names-in-kit-pages': 'off',
103
+
104
+ // EXPERIMENTAL
105
+
106
+ 'svelte/experimental-require-slot-types': 'off',
107
+ 'svelte/experimental-require-strict-events': 'off',
108
+
109
+ // SYSTEM
110
+
111
+ 'svelte/comment-directive': [ 'error', { reportUnusedDisableDirectives: true } ],
112
+ 'svelte/system': 'error'
113
+ }
114
+ },
115
+ {
116
+ name: 'koffeine/svelte/.svelte.js',
117
+ files: [ '**/*.svelte.js' ],
118
+ rules: {
119
+ // STYLISTIC ISSUES
120
+
121
+ 'svelte/indent': 'off' // only in .svelte files
122
+ }
123
+ },
124
+ {
125
+ name: 'koffeine/svelte/.svelte',
126
+ files: [ '**/*.svelte' ],
127
+ processor: sveltePlugin.processors.svelte,
128
+ rules: {
129
+ // STYLISTIC ISSUES
130
+
131
+ '@stylistic/indent': 'off', 'svelte/indent': [ 'error', { indent: 'tab', indentScript: false, switchCase: 1, alignAttributesVertically: false } ], // only in .svelte files
132
+ }
133
+ }
134
+ ];