eslint-plugin-svelte 2.4.0 → 2.6.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/README.md CHANGED
@@ -13,6 +13,12 @@ You can check on the [Online DEMO](https://ota-meshi.github.io/eslint-plugin-sve
13
13
  [![NPM downloads](https://img.shields.io/npm/dt/eslint-plugin-svelte.svg)](http://www.npmtrends.com/eslint-plugin-svelte)
14
14
  [![Build Status](https://github.com/ota-meshi/eslint-plugin-svelte/workflows/CI/badge.svg?branch=main)](https://github.com/ota-meshi/eslint-plugin-svelte/actions?query=workflow%3ACI)
15
15
 
16
+ [![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/ota-meshi/eslint-plugin-svelte.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/ota-meshi/eslint-plugin-svelte/context:javascript)
17
+ [![type-coverage](https://img.shields.io/badge/dynamic/json.svg?label=type-coverage&prefix=%E2%89%A5&suffix=%&query=$.typeCoverage.atLeast&uri=https%3A%2F%2Fraw.githubusercontent.com%2Fota-meshi%2Feslint-plugin-svelte%2Fmain%2Fpackage.json)](https://github.com/plantain-00/type-coverage)
18
+ [![Conventional Commits](https://img.shields.io/badge/conventional%20commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
19
+ [![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
20
+ [![changesets](https://img.shields.io/badge/maintained%20with-changesets-176de3.svg)](https://github.com/atlassian/changesets)
21
+
16
22
  ## :name_badge: What is this plugin?
17
23
 
18
24
  [ESLint] plugin for [Svelte].
@@ -61,7 +67,7 @@ npm install --save-dev eslint eslint-plugin-svelte svelte
61
67
 
62
68
  ### Configuration
63
69
 
64
- Use `.eslintrc.*` file to configure rules. See also: [https://eslint.org/docs/user-guide/configuring](https://eslint.org/docs/user-guide/configuring).
70
+ Use `.eslintrc.*` file to configure rules. See also: <https://eslint.org/docs/user-guide/configuring>.
65
71
 
66
72
  Example **.eslintrc.js**:
67
73
 
@@ -176,7 +182,7 @@ module.exports = {
176
182
  }
177
183
  ```
178
184
 
179
- See also [https://github.com/ota-meshi/svelte-eslint-parser#readme](https://github.com/ota-meshi/svelte-eslint-parser#readme).
185
+ See also <https://github.com/ota-meshi/svelte-eslint-parser#readme>.
180
186
 
181
187
  #### settings.svelte
182
188
 
@@ -242,6 +248,7 @@ Example **.vscode/settings.json**:
242
248
 
243
249
  ## :white_check_mark: Rules
244
250
 
251
+ <!-- prettier-ignore-start -->
245
252
  <!--RULES_SECTION_START-->
246
253
 
247
254
  :wrench: Indicates that the rule is fixable, and using `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the reported problems.
@@ -282,10 +289,12 @@ These rules relate to better ways of doing things to help you avoid problems:
282
289
  |:--------|:------------|:---|
283
290
  | [svelte/button-has-type](https://ota-meshi.github.io/eslint-plugin-svelte/rules/button-has-type/) | disallow usage of button without an explicit type attribute | |
284
291
  | [svelte/no-at-debug-tags](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-at-debug-tags/) | disallow the use of `{@debug}` | :star: |
285
- | [svelte/no-reactive-literals](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-reactive-literals/) | Don't assign literal values in reactive statements | :bulb: |
292
+ | [svelte/no-reactive-functions](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-reactive-functions/) | it's not necessary to define functions in reactive statements | :bulb: |
293
+ | [svelte/no-reactive-literals](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-reactive-literals/) | don't assign literal values in reactive statements | :bulb: |
286
294
  | [svelte/no-unused-svelte-ignore](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-unused-svelte-ignore/) | disallow unused svelte-ignore comments | :star: |
287
295
  | [svelte/no-useless-mustaches](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-useless-mustaches/) | disallow unnecessary mustache interpolations | :wrench: |
288
296
  | [svelte/require-optimized-style-attribute](https://ota-meshi.github.io/eslint-plugin-svelte/rules/require-optimized-style-attribute/) | require style attributes that can be optimized | |
297
+ | [svelte/require-stores-init](https://ota-meshi.github.io/eslint-plugin-svelte/rules/require-stores-init/) | require initial value in store | |
289
298
 
290
299
  ## Stylistic Issues
291
300
 
@@ -296,6 +305,7 @@ These rules relate to style guidelines, and are therefore quite subjective:
296
305
  | [svelte/first-attribute-linebreak](https://ota-meshi.github.io/eslint-plugin-svelte/rules/first-attribute-linebreak/) | enforce the location of first attribute | :wrench: |
297
306
  | [svelte/html-closing-bracket-spacing](https://ota-meshi.github.io/eslint-plugin-svelte/rules/html-closing-bracket-spacing/) | require or disallow a space before tag's closing brackets | :wrench: |
298
307
  | [svelte/html-quotes](https://ota-meshi.github.io/eslint-plugin-svelte/rules/html-quotes/) | enforce quotes style of HTML attributes | :wrench: |
308
+ | [svelte/html-self-closing](https://ota-meshi.github.io/eslint-plugin-svelte/rules/html-self-closing/) | enforce self-closing style | :wrench: |
299
309
  | [svelte/indent](https://ota-meshi.github.io/eslint-plugin-svelte/rules/indent/) | enforce consistent indentation | :wrench: |
300
310
  | [svelte/max-attributes-per-line](https://ota-meshi.github.io/eslint-plugin-svelte/rules/max-attributes-per-line/) | enforce the maximum number of attributes per line | :wrench: |
301
311
  | [svelte/mustache-spacing](https://ota-meshi.github.io/eslint-plugin-svelte/rules/mustache-spacing/) | enforce unified spacing in mustache | :wrench: |
@@ -327,6 +337,7 @@ These rules relate to this plugin works:
327
337
 
328
338
  <!--RULES_TABLE_END-->
329
339
  <!--RULES_SECTION_END-->
340
+ <!-- prettier-ignore-end -->
330
341
 
331
342
  <!--DOCS_IGNORE_START-->
332
343
 
@@ -4,6 +4,7 @@ declare const _default: {
4
4
  "svelte/first-attribute-linebreak": string;
5
5
  "svelte/html-closing-bracket-spacing": string;
6
6
  "svelte/html-quotes": string;
7
+ "svelte/html-self-closing": string;
7
8
  "svelte/indent": string;
8
9
  "svelte/max-attributes-per-line": string;
9
10
  "svelte/mustache-spacing": string;
@@ -11,6 +11,7 @@ module.exports = {
11
11
  "svelte/first-attribute-linebreak": "off",
12
12
  "svelte/html-closing-bracket-spacing": "off",
13
13
  "svelte/html-quotes": "off",
14
+ "svelte/html-self-closing": "off",
14
15
  "svelte/indent": "off",
15
16
  "svelte/max-attributes-per-line": "off",
16
17
  "svelte/mustache-spacing": "off",
package/lib/index.d.ts CHANGED
@@ -39,6 +39,7 @@ declare const _default: {
39
39
  "svelte/first-attribute-linebreak": string;
40
40
  "svelte/html-closing-bracket-spacing": string;
41
41
  "svelte/html-quotes": string;
42
+ "svelte/html-self-closing": string;
42
43
  "svelte/indent": string;
43
44
  "svelte/max-attributes-per-line": string;
44
45
  "svelte/mustache-spacing": string;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../types").RuleModule;
2
+ export default _default;
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("../utils");
4
+ const ast_utils_1 = require("../utils/ast-utils");
5
+ const TYPE_MESSAGES = {
6
+ normal: "HTML elements",
7
+ void: "HTML void elements",
8
+ component: "Svelte custom components",
9
+ svelte: "Svelte special elements",
10
+ };
11
+ exports.default = (0, utils_1.createRule)("html-self-closing", {
12
+ meta: {
13
+ docs: {
14
+ description: "enforce self-closing style",
15
+ category: "Stylistic Issues",
16
+ recommended: false,
17
+ conflictWithPrettier: true,
18
+ },
19
+ type: "layout",
20
+ fixable: "code",
21
+ messages: {
22
+ requireClosing: "Require self-closing on {{type}}.",
23
+ disallowClosing: "Disallow self-closing on {{type}}.",
24
+ },
25
+ schema: [
26
+ {
27
+ anyOf: [
28
+ {
29
+ properties: {
30
+ void: {
31
+ enum: ["never", "always", "ignore"],
32
+ },
33
+ normal: {
34
+ enum: ["never", "always", "ignore"],
35
+ },
36
+ component: {
37
+ enum: ["never", "always", "ignore"],
38
+ },
39
+ svelte: {
40
+ enum: ["never", "always", "ignore"],
41
+ },
42
+ },
43
+ additionalProperties: false,
44
+ },
45
+ {
46
+ enum: ["all", "html", "none"],
47
+ },
48
+ ],
49
+ },
50
+ ],
51
+ },
52
+ create(ctx) {
53
+ let options = {
54
+ void: "always",
55
+ normal: "always",
56
+ component: "always",
57
+ svelte: "always",
58
+ };
59
+ const option = ctx.options?.[0];
60
+ switch (option) {
61
+ case "none":
62
+ options = {
63
+ void: "never",
64
+ normal: "never",
65
+ component: "never",
66
+ svelte: "never",
67
+ };
68
+ break;
69
+ case "html":
70
+ options = {
71
+ void: "always",
72
+ normal: "never",
73
+ component: "never",
74
+ svelte: "always",
75
+ };
76
+ break;
77
+ default:
78
+ if (typeof option !== "object" || option === null)
79
+ break;
80
+ options = {
81
+ ...options,
82
+ ...option,
83
+ };
84
+ break;
85
+ }
86
+ function getElementType(node) {
87
+ if (node.kind === "component")
88
+ return "component";
89
+ if (node.kind === "special")
90
+ return "svelte";
91
+ if ((0, ast_utils_1.isVoidHtmlElement)(node))
92
+ return "void";
93
+ return "normal";
94
+ }
95
+ function isElementEmpty(node) {
96
+ if (node.children.length <= 0)
97
+ return true;
98
+ for (const child of node.children) {
99
+ if (child.type !== "SvelteText")
100
+ return false;
101
+ if (!/^\s*$/.test(child.value))
102
+ return false;
103
+ }
104
+ return true;
105
+ }
106
+ function report(node, close) {
107
+ const elementType = getElementType(node);
108
+ ctx.report({
109
+ node,
110
+ messageId: close ? "requireClosing" : "disallowClosing",
111
+ data: {
112
+ type: TYPE_MESSAGES[elementType],
113
+ },
114
+ *fix(fixer) {
115
+ if (close) {
116
+ for (const child of node.children) {
117
+ yield fixer.removeRange(child.range);
118
+ }
119
+ yield fixer.insertTextBeforeRange([node.startTag.range[1] - 1, node.startTag.range[1]], "/");
120
+ if (node.endTag)
121
+ yield fixer.removeRange(node.endTag.range);
122
+ }
123
+ else {
124
+ yield fixer.removeRange([
125
+ node.startTag.range[1] - 2,
126
+ node.startTag.range[1] - 1,
127
+ ]);
128
+ if (!(0, ast_utils_1.isVoidHtmlElement)(node))
129
+ yield fixer.insertTextAfter(node, `</${(0, ast_utils_1.getNodeName)(node)}>`);
130
+ }
131
+ },
132
+ });
133
+ }
134
+ return {
135
+ SvelteElement(node) {
136
+ if (!isElementEmpty(node))
137
+ return;
138
+ const elementType = getElementType(node);
139
+ const elementTypeOptions = options[elementType];
140
+ if (elementTypeOptions === "ignore")
141
+ return;
142
+ const shouldBeClosed = elementTypeOptions === "always";
143
+ if (shouldBeClosed && !node.startTag.selfClosing) {
144
+ report(node, true);
145
+ }
146
+ else if (!shouldBeClosed && node.startTag.selfClosing) {
147
+ report(node, false);
148
+ }
149
+ },
150
+ };
151
+ },
152
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../types").RuleModule;
2
+ export default _default;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("../utils");
4
+ exports.default = (0, utils_1.createRule)("no-reactive-functions", {
5
+ meta: {
6
+ docs: {
7
+ description: "it's not necessary to define functions in reactive statements",
8
+ category: "Best Practices",
9
+ recommended: false,
10
+ },
11
+ hasSuggestions: true,
12
+ schema: [],
13
+ messages: {
14
+ noReactiveFns: `Do not create functions inside reactive statements unless absolutely necessary.`,
15
+ fixReactiveFns: `Move the function out of the reactive statement`,
16
+ },
17
+ type: "suggestion",
18
+ },
19
+ create(context) {
20
+ return {
21
+ [`SvelteReactiveStatement > ExpressionStatement > AssignmentExpression > :function`](node) {
22
+ const parent = node.parent?.parent?.parent;
23
+ if (!parent) {
24
+ return false;
25
+ }
26
+ const source = context.getSourceCode();
27
+ return context.report({
28
+ node: parent,
29
+ loc: parent.loc,
30
+ messageId: "noReactiveFns",
31
+ suggest: [
32
+ {
33
+ messageId: "fixReactiveFns",
34
+ fix(fixer) {
35
+ const tokens = source.getFirstTokens(parent, {
36
+ includeComments: false,
37
+ count: 3,
38
+ });
39
+ const noExtraSpace = source.isSpaceBetweenTokens(tokens[1], tokens[2]);
40
+ return fixer.replaceTextRange([tokens[0].range[0], tokens[1].range[1]], noExtraSpace ? "const" : "const ");
41
+ },
42
+ },
43
+ ],
44
+ });
45
+ },
46
+ };
47
+ },
48
+ });
@@ -4,7 +4,7 @@ const utils_1 = require("../utils");
4
4
  exports.default = (0, utils_1.createRule)("no-reactive-literals", {
5
5
  meta: {
6
6
  docs: {
7
- description: "Don't assign literal values in reactive statements",
7
+ description: "don't assign literal values in reactive statements",
8
8
  category: "Best Practices",
9
9
  recommended: false,
10
10
  },
@@ -18,11 +18,11 @@ exports.default = (0, utils_1.createRule)("no-reactive-literals", {
18
18
  },
19
19
  create(context) {
20
20
  return {
21
- [`SvelteReactiveStatement > ExpressionStatement > AssignmentExpression${[
21
+ [`SvelteReactiveStatement > ExpressionStatement > AssignmentExpression:matches(${[
22
22
  `[right.type="Literal"]`,
23
23
  `[right.type="ArrayExpression"][right.elements.length=0]`,
24
24
  `[right.type="ObjectExpression"][right.properties.length=0]`,
25
- ].join(",")}`](node) {
25
+ ].join(",")})`](node) {
26
26
  const parent = node.parent?.parent;
27
27
  if (!parent) {
28
28
  return false;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../types").RuleModule;
2
+ export default _default;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("../utils");
4
+ const eslint_utils_1 = require("eslint-utils");
5
+ exports.default = (0, utils_1.createRule)("require-stores-init", {
6
+ meta: {
7
+ docs: {
8
+ description: "require initial value in store",
9
+ category: "Best Practices",
10
+ recommended: false,
11
+ },
12
+ schema: [],
13
+ messages: {
14
+ storeDefaultValue: `Always set a default value for svelte stores.`,
15
+ },
16
+ type: "suggestion",
17
+ },
18
+ create(context) {
19
+ function* extractStoreReferences() {
20
+ const referenceTracker = new eslint_utils_1.ReferenceTracker(context.getScope());
21
+ for (const { node, path } of referenceTracker.iterateEsmReferences({
22
+ "svelte/store": {
23
+ [eslint_utils_1.ReferenceTracker.ESM]: true,
24
+ writable: {
25
+ [eslint_utils_1.ReferenceTracker.CALL]: true,
26
+ },
27
+ readable: {
28
+ [eslint_utils_1.ReferenceTracker.CALL]: true,
29
+ },
30
+ derived: {
31
+ [eslint_utils_1.ReferenceTracker.CALL]: true,
32
+ },
33
+ },
34
+ })) {
35
+ yield {
36
+ node: node,
37
+ name: path[path.length - 1],
38
+ };
39
+ }
40
+ }
41
+ return {
42
+ Program() {
43
+ for (const { node, name } of extractStoreReferences()) {
44
+ const minArgs = name === "writable" || name === "readable"
45
+ ? 1
46
+ : name === "derived"
47
+ ? 3
48
+ : 0;
49
+ if (node.arguments.length >= minArgs ||
50
+ node.arguments.some((arg) => arg.type === "SpreadElement")) {
51
+ continue;
52
+ }
53
+ context.report({
54
+ node,
55
+ messageId: "storeDefaultValue",
56
+ });
57
+ }
58
+ },
59
+ };
60
+ },
61
+ });
@@ -48,3 +48,5 @@ export declare function getMustacheTokens(node: SvAST.SvelteDirective | SvAST.Sv
48
48
  } | null;
49
49
  export declare function getAttributeKeyText(node: SvAST.SvelteAttribute | SvAST.SvelteShorthandAttribute | SvAST.SvelteStyleDirective | SvAST.SvelteDirective | SvAST.SvelteSpecialDirective): string;
50
50
  export declare function getDirectiveName(node: SvAST.SvelteDirective): string;
51
+ export declare function getNodeName(node: SvAST.SvelteElement): string;
52
+ export declare function isVoidHtmlElement(node: SvAST.SvelteElement): boolean;
@@ -22,9 +22,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
25
28
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getDirectiveName = exports.getAttributeKeyText = exports.getMustacheTokens = exports.getAttributeValueQuoteAndRange = exports.getScope = exports.findVariable = exports.getLangValue = exports.getStaticAttributeValue = exports.findBindDirective = exports.findShorthandAttribute = exports.findAttribute = exports.isHTMLElementLike = exports.needParentheses = exports.getStringIfConstant = exports.equalTokens = void 0;
29
+ exports.isVoidHtmlElement = exports.getNodeName = exports.getDirectiveName = exports.getAttributeKeyText = exports.getMustacheTokens = exports.getAttributeValueQuoteAndRange = exports.getScope = exports.findVariable = exports.getLangValue = exports.getStaticAttributeValue = exports.findBindDirective = exports.findShorthandAttribute = exports.findAttribute = exports.isHTMLElementLike = exports.needParentheses = exports.getStringIfConstant = exports.equalTokens = void 0;
27
30
  const eslintUtils = __importStar(require("eslint-utils"));
31
+ const void_elements_1 = __importDefault(require("./void-elements"));
28
32
  function equalTokens(left, right, sourceCode) {
29
33
  const tokensL = sourceCode.getTokens(left);
30
34
  const tokensR = sourceCode.getTokens(right);
@@ -322,3 +326,23 @@ function getAttributeValueRangeTokens(attr, sourceCode) {
322
326
  lastToken: tokens.closeToken,
323
327
  };
324
328
  }
329
+ function getNodeName(node) {
330
+ if ("name" in node.name) {
331
+ return node.name.name;
332
+ }
333
+ let object = "";
334
+ let currentObject = node.name.object;
335
+ while ("object" in currentObject) {
336
+ object = `${currentObject.property.name}.${object}`;
337
+ currentObject = currentObject.object;
338
+ }
339
+ if ("name" in currentObject) {
340
+ object = `${currentObject.name}.${object}`;
341
+ }
342
+ return object + node.name.property.name;
343
+ }
344
+ exports.getNodeName = getNodeName;
345
+ function isVoidHtmlElement(node) {
346
+ return void_elements_1.default.includes(getNodeName(node));
347
+ }
348
+ exports.isVoidHtmlElement = isVoidHtmlElement;
@@ -9,6 +9,7 @@ const comment_directive_1 = __importDefault(require("../rules/comment-directive"
9
9
  const first_attribute_linebreak_1 = __importDefault(require("../rules/first-attribute-linebreak"));
10
10
  const html_closing_bracket_spacing_1 = __importDefault(require("../rules/html-closing-bracket-spacing"));
11
11
  const html_quotes_1 = __importDefault(require("../rules/html-quotes"));
12
+ const html_self_closing_1 = __importDefault(require("../rules/html-self-closing"));
12
13
  const indent_1 = __importDefault(require("../rules/indent"));
13
14
  const max_attributes_per_line_1 = __importDefault(require("../rules/max-attributes-per-line"));
14
15
  const mustache_spacing_1 = __importDefault(require("../rules/mustache-spacing"));
@@ -21,6 +22,7 @@ const no_extra_reactive_curlies_1 = __importDefault(require("../rules/no-extra-r
21
22
  const no_inner_declarations_1 = __importDefault(require("../rules/no-inner-declarations"));
22
23
  const no_not_function_handler_1 = __importDefault(require("../rules/no-not-function-handler"));
23
24
  const no_object_in_text_mustaches_1 = __importDefault(require("../rules/no-object-in-text-mustaches"));
25
+ const no_reactive_functions_1 = __importDefault(require("../rules/no-reactive-functions"));
24
26
  const no_reactive_literals_1 = __importDefault(require("../rules/no-reactive-literals"));
25
27
  const no_shorthand_style_property_overrides_1 = __importDefault(require("../rules/no-shorthand-style-property-overrides"));
26
28
  const no_spaces_around_equal_signs_in_attribute_1 = __importDefault(require("../rules/no-spaces-around-equal-signs-in-attribute"));
@@ -31,6 +33,7 @@ const no_useless_mustaches_1 = __importDefault(require("../rules/no-useless-must
31
33
  const prefer_class_directive_1 = __importDefault(require("../rules/prefer-class-directive"));
32
34
  const prefer_style_directive_1 = __importDefault(require("../rules/prefer-style-directive"));
33
35
  const require_optimized_style_attribute_1 = __importDefault(require("../rules/require-optimized-style-attribute"));
36
+ const require_stores_init_1 = __importDefault(require("../rules/require-stores-init"));
34
37
  const shorthand_attribute_1 = __importDefault(require("../rules/shorthand-attribute"));
35
38
  const shorthand_directive_1 = __importDefault(require("../rules/shorthand-directive"));
36
39
  const sort_attributes_1 = __importDefault(require("../rules/sort-attributes"));
@@ -43,6 +46,7 @@ exports.rules = [
43
46
  first_attribute_linebreak_1.default,
44
47
  html_closing_bracket_spacing_1.default,
45
48
  html_quotes_1.default,
49
+ html_self_closing_1.default,
46
50
  indent_1.default,
47
51
  max_attributes_per_line_1.default,
48
52
  mustache_spacing_1.default,
@@ -55,6 +59,7 @@ exports.rules = [
55
59
  no_inner_declarations_1.default,
56
60
  no_not_function_handler_1.default,
57
61
  no_object_in_text_mustaches_1.default,
62
+ no_reactive_functions_1.default,
58
63
  no_reactive_literals_1.default,
59
64
  no_shorthand_style_property_overrides_1.default,
60
65
  no_spaces_around_equal_signs_in_attribute_1.default,
@@ -65,6 +70,7 @@ exports.rules = [
65
70
  prefer_class_directive_1.default,
66
71
  prefer_style_directive_1.default,
67
72
  require_optimized_style_attribute_1.default,
73
+ require_stores_init_1.default,
68
74
  shorthand_attribute_1.default,
69
75
  shorthand_directive_1.default,
70
76
  sort_attributes_1.default,
@@ -0,0 +1,2 @@
1
+ declare const voidElements: string[];
2
+ export default voidElements;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const voidElements = [
4
+ "area",
5
+ "base",
6
+ "br",
7
+ "col",
8
+ "embed",
9
+ "hr",
10
+ "img",
11
+ "input",
12
+ "keygen",
13
+ "link",
14
+ "menuitem",
15
+ "meta",
16
+ "param",
17
+ "source",
18
+ "track",
19
+ "wbr",
20
+ ];
21
+ exports.default = voidElements;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-svelte",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "description": "ESLint plugin for Svelte using AST",
5
5
  "repository": "git+https://github.com/ota-meshi/eslint-plugin-svelte.git",
6
6
  "homepage": "https://ota-meshi.github.io/eslint-plugin-svelte",
@@ -34,18 +34,23 @@
34
34
  "docs:build": "yarn svelte-kit build",
35
35
  "docs:preview": "yarn svelte-kit preview",
36
36
  "docs:watch": "yarn svelte-kit dev",
37
- "eslint-fix": "eslint . --fix",
38
37
  "format-for-gen-file": "eslint src/types-for-node.ts src/utils/rules.ts src/configs --fix",
39
- "lint": "eslint .",
38
+ "lint": "run-p lint:*",
39
+ "lint-fix": "yarn lint:es --fix && yarn lint:style --fix",
40
+ "lint:es": "eslint --cache -f friendly .",
41
+ "lint:style": "stylelint --cache .",
40
42
  "mocha": "yarn ts ./node_modules/mocha/bin/mocha.js",
41
43
  "new": "yarn ts ./tools/new-rule.ts",
42
44
  "prebuild": "yarn clean",
43
- "prepublishOnly": "yarn clean && yarn build",
44
- "pretest:base": "cross-env DEBUG=eslint-plugin-svelte*",
45
- "preversion": "yarn test && git add .",
45
+ "prepare": "simple-git-hooks && yarn-deduplicate --strategy fewer || exit 0",
46
+ "prerelease": "yarn clean && yarn build",
47
+ "pretest": "yarn build",
48
+ "release": "changeset publish",
46
49
  "svelte-kit": "node --experimental-loader ./svelte-kit-import-hook.mjs node_modules/vite/bin/vite.js",
47
50
  "test": "yarn mocha \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
51
+ "test:debug": "cross-env DEBUG=eslint-plugin-svelte* yarn test",
48
52
  "ts": "node -r esbuild-register",
53
+ "typecov": "type-coverage",
49
54
  "update": "yarn ts ./tools/update.ts && yarn format-for-gen-file",
50
55
  "version": "env-cmd -e version yarn update && git add ."
51
56
  },
@@ -66,13 +71,21 @@
66
71
  "postcss-load-config": "^3.1.4",
67
72
  "postcss-safe-parser": "^6.0.0",
68
73
  "sourcemap-codec": "^1.4.8",
69
- "svelte-eslint-parser": "^0.17.0"
74
+ "svelte-eslint-parser": "^0.18.0"
70
75
  },
71
76
  "devDependencies": {
77
+ "@1stg/browserslist-config": "^1.2.3",
78
+ "@1stg/commitlint-config": "^3.1.4",
79
+ "@1stg/lint-staged": "^3.3.0",
80
+ "@1stg/remark-config": "^4.0.3",
81
+ "@1stg/simple-git-hooks": "^0.2.1",
82
+ "@1stg/stylelint-config": "^4.6.1",
72
83
  "@babel/core": "^7.16.0",
73
84
  "@babel/eslint-parser": "^7.17.0",
74
85
  "@babel/plugin-proposal-function-bind": "^7.16.7",
75
86
  "@babel/types": "^7.16.0",
87
+ "@changesets/changelog-github": "^0.4.6",
88
+ "@changesets/cli": "^2.24.2",
76
89
  "@fontsource/fira-mono": "^4.5.0",
77
90
  "@ota-meshi/eslint-plugin": "^0.11.3",
78
91
  "@sindresorhus/slugify": "^2.1.0",
@@ -83,6 +96,7 @@
83
96
  "@types/escape-html": "^1.0.2",
84
97
  "@types/eslint": "^8.0.0",
85
98
  "@types/eslint-scope": "^3.7.0",
99
+ "@types/eslint-utils": "^3.0.1",
86
100
  "@types/eslint-visitor-keys": "^1.0.0",
87
101
  "@types/estree": "^1.0.0",
88
102
  "@types/less": "^3.0.3",
@@ -98,17 +112,21 @@
98
112
  "@typescript-eslint/parser": "^5.4.1-0",
99
113
  "@typescript-eslint/parser-v4": "npm:@typescript-eslint/parser@4",
100
114
  "assert": "^2.0.0",
115
+ "commitlint": "^17.0.3",
116
+ "cross-env": "^7.0.3",
101
117
  "env-cmd": "^10.1.0",
102
- "esbuild": "^0.14.1",
118
+ "esbuild": "^0.15.0",
103
119
  "esbuild-register": "^3.2.0",
104
120
  "escape-html": "^1.0.3",
105
121
  "eslint": "^8.0.0",
106
122
  "eslint-config-prettier": "^8.3.0",
123
+ "eslint-formatter-friendly": "^7.0.0",
107
124
  "eslint-plugin-eslint-comments": "^3.2.0",
108
125
  "eslint-plugin-eslint-plugin": "^5.0.0",
109
126
  "eslint-plugin-json-schema-validator": "^4.0.0",
110
127
  "eslint-plugin-jsonc": "^2.0.0",
111
128
  "eslint-plugin-markdown": "^3.0.0",
129
+ "eslint-plugin-mdx": "^2.0.2",
112
130
  "eslint-plugin-node": "^11.1.0",
113
131
  "eslint-plugin-node-dependencies": "^0.9.0",
114
132
  "eslint-plugin-prettier": "^4.0.0",
@@ -118,12 +136,14 @@
118
136
  "eslint-scope": "^7.1.1",
119
137
  "estree-walker": "^3.0.0",
120
138
  "less": "^4.1.2",
139
+ "lint-staged": "^13.0.3",
121
140
  "locate-character": "^2.0.5",
122
141
  "magic-string": "^0.26.0",
123
142
  "markdown-it-anchor": "^8.4.1",
124
143
  "markdown-it-container": "^3.0.0",
125
144
  "markdown-it-emoji": "^2.0.0",
126
145
  "mocha": "^10.0.0",
146
+ "npm-run-all": "^4.1.5",
127
147
  "nyc": "^15.1.0",
128
148
  "pako": "^2.0.3",
129
149
  "postcss-nested": "^5.0.6",
@@ -134,16 +154,31 @@
134
154
  "prismjs": "^1.25.0",
135
155
  "sass": "^1.51.0",
136
156
  "semver": "^7.3.5",
157
+ "simple-git-hooks": "^2.8.0",
137
158
  "stylelint": "^14.0.0",
138
- "stylelint-config-standard": "^26.0.0",
139
- "stylus": "^0.58.0",
159
+ "stylelint-config-standard": "^27.0.0",
160
+ "stylus": "^0.59.0",
140
161
  "svelte": "^3.46.1",
141
162
  "svelte-adapter-ghpages": "0.0.2",
163
+ "type-coverage": "^2.22.0",
142
164
  "typescript": "^4.5.2",
143
165
  "vite": "^3.0.0-0",
144
- "vite-plugin-svelte-md": "^0.1.5"
166
+ "vite-plugin-svelte-md": "^0.1.5",
167
+ "yaml": "^2.1.1",
168
+ "yarn-deduplicate": "^5.0.0"
145
169
  },
146
170
  "publishConfig": {
147
171
  "access": "public"
172
+ },
173
+ "typeCoverage": {
174
+ "atLeast": 98.63,
175
+ "cache": true,
176
+ "detail": true,
177
+ "ignoreAsAssertion": true,
178
+ "ignoreNested": true,
179
+ "ignoreNonNullAssertion": true,
180
+ "showRelativePath": true,
181
+ "strict": true,
182
+ "update": true
148
183
  }
149
184
  }