eslint-plugin-svelte 2.17.0 → 2.18.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 +9 -0
- package/lib/rules/experimental-require-slot-types.d.ts +2 -0
- package/lib/rules/experimental-require-slot-types.js +50 -0
- package/lib/rules/experimental-require-strict-events.d.ts +2 -0
- package/lib/rules/experimental-require-strict-events.js +45 -0
- package/lib/types.d.ts +1 -1
- package/lib/utils/rules.js +4 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -373,6 +373,15 @@ These rules extend the rules provided by ESLint itself, or other plugins to work
|
|
|
373
373
|
| [svelte/no-inner-declarations](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-inner-declarations/) | disallow variable or `function` declarations in nested blocks | :star: |
|
|
374
374
|
| [svelte/no-trailing-spaces](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-trailing-spaces/) | disallow trailing whitespace at the end of lines | :wrench: |
|
|
375
375
|
|
|
376
|
+
## Experimental
|
|
377
|
+
|
|
378
|
+
:warning: These rules are considered experimental and may change or be removed in the future:
|
|
379
|
+
|
|
380
|
+
| Rule ID | Description | |
|
|
381
|
+
|:--------|:------------|:---|
|
|
382
|
+
| [svelte/experimental-require-slot-types](https://ota-meshi.github.io/eslint-plugin-svelte/rules/experimental-require-slot-types/) | require slot type declaration using the `$$Slots` interface | |
|
|
383
|
+
| [svelte/experimental-require-strict-events](https://ota-meshi.github.io/eslint-plugin-svelte/rules/experimental-require-strict-events/) | require the strictEvents attribute on `<script>` tags | |
|
|
384
|
+
|
|
376
385
|
## System
|
|
377
386
|
|
|
378
387
|
These rules relate to this plugin works:
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
exports.default = (0, utils_1.createRule)("experimental-require-slot-types", {
|
|
6
|
+
meta: {
|
|
7
|
+
docs: {
|
|
8
|
+
description: "require slot type declaration using the `$$Slots` interface",
|
|
9
|
+
category: "Experimental",
|
|
10
|
+
recommended: false,
|
|
11
|
+
},
|
|
12
|
+
schema: [],
|
|
13
|
+
messages: {
|
|
14
|
+
missingSlotsInterface: `The component must define the $$Slots interface.`,
|
|
15
|
+
},
|
|
16
|
+
type: "suggestion",
|
|
17
|
+
},
|
|
18
|
+
create(context) {
|
|
19
|
+
let isTs = false;
|
|
20
|
+
let hasSlot = false;
|
|
21
|
+
let hasInterface = false;
|
|
22
|
+
return {
|
|
23
|
+
SvelteScriptElement(node) {
|
|
24
|
+
const lang = (0, ast_utils_1.getLangValue)(node)?.toLowerCase();
|
|
25
|
+
isTs = lang === "ts" || lang === "typescript";
|
|
26
|
+
},
|
|
27
|
+
SvelteElement(node) {
|
|
28
|
+
if (node.name.type === "SvelteName" && node.name.name === "slot") {
|
|
29
|
+
hasSlot = true;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
TSInterfaceDeclaration(node) {
|
|
33
|
+
if (node.id.name === "$$Slots") {
|
|
34
|
+
hasInterface = true;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"Program:exit"() {
|
|
38
|
+
if (isTs && hasSlot && !hasInterface) {
|
|
39
|
+
context.report({
|
|
40
|
+
loc: {
|
|
41
|
+
line: 1,
|
|
42
|
+
column: 1,
|
|
43
|
+
},
|
|
44
|
+
messageId: "missingSlotsInterface",
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
exports.default = (0, utils_1.createRule)("experimental-require-strict-events", {
|
|
6
|
+
meta: {
|
|
7
|
+
docs: {
|
|
8
|
+
description: "require the strictEvents attribute on `<script>` tags",
|
|
9
|
+
category: "Experimental",
|
|
10
|
+
recommended: false,
|
|
11
|
+
},
|
|
12
|
+
schema: [],
|
|
13
|
+
messages: {
|
|
14
|
+
missingStrictEvents: `The component must have the strictEvents attribute on its <script> tag or it must define the $$Events interface.`,
|
|
15
|
+
},
|
|
16
|
+
type: "suggestion",
|
|
17
|
+
},
|
|
18
|
+
create(context) {
|
|
19
|
+
let isTs = false;
|
|
20
|
+
let hasAttribute = false;
|
|
21
|
+
let hasInterface = false;
|
|
22
|
+
let scriptNode;
|
|
23
|
+
return {
|
|
24
|
+
SvelteScriptElement(node) {
|
|
25
|
+
const lang = (0, ast_utils_1.getLangValue)(node)?.toLowerCase();
|
|
26
|
+
isTs = lang === "ts" || lang === "typescript";
|
|
27
|
+
hasAttribute = (0, ast_utils_1.findAttribute)(node, "strictEvents") !== null;
|
|
28
|
+
scriptNode = node;
|
|
29
|
+
},
|
|
30
|
+
TSInterfaceDeclaration(node) {
|
|
31
|
+
if (node.id.name === "$$Events") {
|
|
32
|
+
hasInterface = true;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"Program:exit"() {
|
|
36
|
+
if (isTs && !hasAttribute && !hasInterface) {
|
|
37
|
+
context.report({
|
|
38
|
+
node: scriptNode,
|
|
39
|
+
messageId: "missingStrictEvents",
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
});
|
package/lib/types.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface RuleModule {
|
|
|
17
17
|
meta: RuleMetaData;
|
|
18
18
|
create: (context: RuleContext) => RuleListener;
|
|
19
19
|
}
|
|
20
|
-
export type RuleCategory = "Possible Errors" | "Security Vulnerability" | "Best Practices" | "Stylistic Issues" | "Extension Rules" | "System";
|
|
20
|
+
export type RuleCategory = "Possible Errors" | "Security Vulnerability" | "Best Practices" | "Stylistic Issues" | "Extension Rules" | "Experimental" | "System";
|
|
21
21
|
export interface RuleMetaData {
|
|
22
22
|
docs: {
|
|
23
23
|
description: string;
|
package/lib/utils/rules.js
CHANGED
|
@@ -8,6 +8,8 @@ const no_unnecessary_condition_1 = __importDefault(require("../rules/@typescript
|
|
|
8
8
|
const button_has_type_1 = __importDefault(require("../rules/button-has-type"));
|
|
9
9
|
const comment_directive_1 = __importDefault(require("../rules/comment-directive"));
|
|
10
10
|
const derived_has_same_inputs_outputs_1 = __importDefault(require("../rules/derived-has-same-inputs-outputs"));
|
|
11
|
+
const experimental_require_slot_types_1 = __importDefault(require("../rules/experimental-require-slot-types"));
|
|
12
|
+
const experimental_require_strict_events_1 = __importDefault(require("../rules/experimental-require-strict-events"));
|
|
11
13
|
const first_attribute_linebreak_1 = __importDefault(require("../rules/first-attribute-linebreak"));
|
|
12
14
|
const html_closing_bracket_spacing_1 = __importDefault(require("../rules/html-closing-bracket-spacing"));
|
|
13
15
|
const html_quotes_1 = __importDefault(require("../rules/html-quotes"));
|
|
@@ -59,6 +61,8 @@ exports.rules = [
|
|
|
59
61
|
button_has_type_1.default,
|
|
60
62
|
comment_directive_1.default,
|
|
61
63
|
derived_has_same_inputs_outputs_1.default,
|
|
64
|
+
experimental_require_slot_types_1.default,
|
|
65
|
+
experimental_require_strict_events_1.default,
|
|
62
66
|
first_attribute_linebreak_1.default,
|
|
63
67
|
html_closing_bracket_spacing_1.default,
|
|
64
68
|
html_quotes_1.default,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-svelte",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.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",
|
|
@@ -157,8 +157,8 @@
|
|
|
157
157
|
"sass": "^1.51.0",
|
|
158
158
|
"semver": "^7.3.5",
|
|
159
159
|
"simple-git-hooks": "^2.8.0",
|
|
160
|
-
"stylelint": "^
|
|
161
|
-
"stylelint-config-standard": "^
|
|
160
|
+
"stylelint": "^15.0.0",
|
|
161
|
+
"stylelint-config-standard": "^30.0.0",
|
|
162
162
|
"stylus": "^0.59.0",
|
|
163
163
|
"svelte": "^3.46.1",
|
|
164
164
|
"svelte-adapter-ghpages": "0.1.0",
|