@flint.fyi/vue 0.1.3 → 0.2.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/{lib/plugin.d.ts → dist/index.d.mts} +2 -5
- package/{lib/rules/vForKeys.js → dist/index.mjs} +30 -14
- package/package.json +12 -12
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -2
- package/lib/plugin.js +0 -13
- package/lib/rules/ruleCreator.d.ts +0 -3
- package/lib/rules/ruleCreator.js +0 -16
- package/lib/rules/vForKeys.d.ts +0 -10
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import * as _flint_fyi_core0 from "@flint.fyi/core";
|
|
2
|
-
|
|
3
1
|
//#region src/plugin.d.ts
|
|
4
|
-
declare const vue:
|
|
2
|
+
declare const vue: import("@flint.fyi/core").Plugin<import("@flint.fyi/core").RuleAbout<string>, "all", [import("@flint.fyi/core").Rule<{
|
|
5
3
|
readonly description: "Reports v-for directives without a valid key binding.";
|
|
6
4
|
readonly id: "vForKeys";
|
|
7
5
|
readonly presets: readonly ["logical"];
|
|
@@ -10,5 +8,4 @@ declare const vue: _flint_fyi_core0.Plugin<_flint_fyi_core0.RuleAbout<string>, "
|
|
|
10
8
|
readonly url: string;
|
|
11
9
|
}, "invalidKey" | "missingKey" | "staticKey", undefined>]>;
|
|
12
10
|
//#endregion
|
|
13
|
-
export { vue };
|
|
14
|
-
//# sourceMappingURL=plugin.d.ts.map
|
|
11
|
+
export { vue };
|
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { RuleCreator, createPlugin } from "@flint.fyi/core";
|
|
2
|
+
import { ts } from "@flint.fyi/ts";
|
|
3
|
+
import * as vue$1 from "@vue/compiler-dom";
|
|
4
|
+
import ts$1 from "typescript";
|
|
4
5
|
import { nullThrows } from "@flint.fyi/utils";
|
|
5
6
|
import { reportSourceCode } from "@flint.fyi/volar-language";
|
|
6
7
|
import { vueLanguage } from "@flint.fyi/vue-language";
|
|
8
|
+
//#endregion
|
|
7
9
|
//#region src/rules/vForKeys.ts
|
|
8
|
-
var vForKeys_default =
|
|
10
|
+
var vForKeys_default = new RuleCreator({
|
|
11
|
+
docs: (ruleId) => `https://flint.fyi/rules/vue/${ruleId.toLowerCase()}`,
|
|
12
|
+
pluginId: "vue",
|
|
13
|
+
presets: [
|
|
14
|
+
"logical",
|
|
15
|
+
"logicalStrict",
|
|
16
|
+
"stylistic",
|
|
17
|
+
"stylisticStrict"
|
|
18
|
+
]
|
|
19
|
+
}).createRule(vueLanguage, {
|
|
9
20
|
about: {
|
|
10
21
|
description: "Reports v-for directives without a valid key binding.",
|
|
11
22
|
id: "vForKeys",
|
|
@@ -38,7 +49,7 @@ var vForKeys_default = ruleCreator.createRule(vueLanguage, {
|
|
|
38
49
|
const toGeneratedLocationOrThrow = (sourceLocation) => {
|
|
39
50
|
return nullThrows(toGeneratedLocation(sourceLocation), "Unable to map source location to generated location");
|
|
40
51
|
};
|
|
41
|
-
const templateBlock = sfc.children.find((c) => c.type === vue.NodeTypes.ELEMENT && c.tag === "template");
|
|
52
|
+
const templateBlock = sfc.children.find((c) => c.type === vue$1.NodeTypes.ELEMENT && c.tag === "template");
|
|
42
53
|
if (templateBlock == null) return {};
|
|
43
54
|
const propValueRange = (propValue) => {
|
|
44
55
|
const strip = propValue.loc.source === propValue.content ? 0 : 1;
|
|
@@ -58,7 +69,7 @@ var vForKeys_default = ruleCreator.createRule(vueLanguage, {
|
|
|
58
69
|
});
|
|
59
70
|
return;
|
|
60
71
|
}
|
|
61
|
-
if (keyProp.type === vue.NodeTypes.ATTRIBUTE) {
|
|
72
|
+
if (keyProp.type === vue$1.NodeTypes.ATTRIBUTE) {
|
|
62
73
|
if (keyProp.value == null) return;
|
|
63
74
|
reportSourceCode(context, {
|
|
64
75
|
message: "staticKey",
|
|
@@ -101,7 +112,7 @@ var vForKeys_default = ruleCreator.createRule(vueLanguage, {
|
|
|
101
112
|
const currentBegin = current.getStart(node);
|
|
102
113
|
const currentEnd = current.getEnd();
|
|
103
114
|
if (currentBegin > valueRange.end || currentEnd <= valueRange.begin) return false;
|
|
104
|
-
if (currentBegin >= valueRange.begin && currentEnd <= valueRange.end && ts.isIdentifier(current)) {
|
|
115
|
+
if (currentBegin >= valueRange.begin && currentEnd <= valueRange.end && ts$1.isIdentifier(current)) {
|
|
105
116
|
const symbol = services.typeChecker.getSymbolAtLocation(current);
|
|
106
117
|
if (symbol?.valueDeclaration == null) return false;
|
|
107
118
|
const declStart = symbol.valueDeclaration.getStart(node);
|
|
@@ -116,15 +127,15 @@ var vForKeys_default = ruleCreator.createRule(vueLanguage, {
|
|
|
116
127
|
});
|
|
117
128
|
};
|
|
118
129
|
function visitTag(node) {
|
|
119
|
-
if (node.type === vue.NodeTypes.ELEMENT) {
|
|
130
|
+
if (node.type === vue$1.NodeTypes.ELEMENT) {
|
|
120
131
|
let forDirective = null;
|
|
121
132
|
let forParseResult = null;
|
|
122
133
|
let keyProp = null;
|
|
123
|
-
for (const prop of node.props) if (prop.type === vue.NodeTypes.DIRECTIVE && prop.name === "for" && prop.forParseResult != null) {
|
|
134
|
+
for (const prop of node.props) if (prop.type === vue$1.NodeTypes.DIRECTIVE && prop.name === "for" && prop.forParseResult != null) {
|
|
124
135
|
forDirective = prop;
|
|
125
136
|
forParseResult = prop.forParseResult;
|
|
126
|
-
} else if (prop.type === vue.NodeTypes.DIRECTIVE && prop.name === "bind" && vue.isStaticArgOf(prop.arg, "key")) keyProp = prop;
|
|
127
|
-
else if (prop.type === vue.NodeTypes.ATTRIBUTE && prop.name === "key") keyProp = prop;
|
|
137
|
+
} else if (prop.type === vue$1.NodeTypes.DIRECTIVE && prop.name === "bind" && vue$1.isStaticArgOf(prop.arg, "key")) keyProp = prop;
|
|
138
|
+
else if (prop.type === vue$1.NodeTypes.ATTRIBUTE && prop.name === "key") keyProp = prop;
|
|
128
139
|
if (forDirective != null && forParseResult != null) checkFor(forDirective, forParseResult, keyProp);
|
|
129
140
|
for (const child of node.children) visitTag(child);
|
|
130
141
|
}
|
|
@@ -134,6 +145,11 @@ var vForKeys_default = ruleCreator.createRule(vueLanguage, {
|
|
|
134
145
|
}
|
|
135
146
|
});
|
|
136
147
|
//#endregion
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
148
|
+
//#region src/plugin.ts
|
|
149
|
+
const vue = createPlugin({
|
|
150
|
+
files: { all: [ts.files.all, "**/*.vue"] },
|
|
151
|
+
name: "Vue.js",
|
|
152
|
+
rules: [vForKeys_default]
|
|
153
|
+
});
|
|
154
|
+
//#endregion
|
|
155
|
+
export { vue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flint.fyi/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "[Experimental] Vue.js language plugin for Flint.",
|
|
5
5
|
"homepage": "https://flint.fyi/rules/vue",
|
|
6
6
|
"repository": {
|
|
@@ -16,27 +16,27 @@
|
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"type": "module",
|
|
18
18
|
"exports": {
|
|
19
|
-
".": "./
|
|
19
|
+
".": "./dist/index.mjs"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"
|
|
23
|
-
"!lib/**/*.map"
|
|
22
|
+
"dist/"
|
|
24
23
|
],
|
|
25
24
|
"dependencies": {
|
|
26
25
|
"@vue/compiler-dom": "^3.5.0",
|
|
27
26
|
"typescript": "^5.9.0 || ^6.0.0",
|
|
28
|
-
"@flint.fyi/
|
|
29
|
-
"@flint.fyi/
|
|
30
|
-
"@flint.fyi/
|
|
31
|
-
"@flint.fyi/
|
|
32
|
-
"@flint.fyi/
|
|
27
|
+
"@flint.fyi/ts": "^0.22.0",
|
|
28
|
+
"@flint.fyi/volar-language": "^0.2.0",
|
|
29
|
+
"@flint.fyi/utils": "^0.15.0",
|
|
30
|
+
"@flint.fyi/core": "^0.24.0",
|
|
31
|
+
"@flint.fyi/vue-language": "^0.2.0"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|
|
35
|
-
"tsdown": "0.
|
|
34
|
+
"tsdown": "0.22.3",
|
|
36
35
|
"vitest": "4.1.0",
|
|
37
36
|
"vue": "3.5.30",
|
|
38
|
-
"@flint.fyi/
|
|
39
|
-
"@flint.fyi/rule-tester": "^0.
|
|
37
|
+
"@flint.fyi/build": "^0.1.0",
|
|
38
|
+
"@flint.fyi/rule-tester": "^0.17.0",
|
|
39
|
+
"@flint.fyi/typescript-language": "^0.19.0"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=24.0.0"
|
package/lib/index.d.ts
DELETED
package/lib/index.js
DELETED
package/lib/plugin.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import vForKeys_default from "./rules/vForKeys.js";
|
|
2
|
-
import { createPlugin } from "@flint.fyi/core";
|
|
3
|
-
import { ts } from "@flint.fyi/ts";
|
|
4
|
-
//#region src/plugin.ts
|
|
5
|
-
const vue = createPlugin({
|
|
6
|
-
files: { all: [ts.files.all, "**/*.vue"] },
|
|
7
|
-
name: "Vue.js",
|
|
8
|
-
rules: [vForKeys_default]
|
|
9
|
-
});
|
|
10
|
-
//#endregion
|
|
11
|
-
export { vue };
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=plugin.js.map
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { RuleCreator } from "@flint.fyi/core";
|
|
2
|
-
export declare const ruleCreator: RuleCreator<"logical" | "logicalStrict" | "stylistic" | "stylisticStrict", import("@flint.fyi/core").RuleAbout<"logical" | "logicalStrict" | "stylistic" | "stylisticStrict">>;
|
|
3
|
-
//# sourceMappingURL=ruleCreator.d.ts.map
|
package/lib/rules/ruleCreator.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { RuleCreator } from "@flint.fyi/core";
|
|
2
|
-
//#region src/rules/ruleCreator.ts
|
|
3
|
-
const ruleCreator = new RuleCreator({
|
|
4
|
-
docs: (ruleId) => `https://flint.fyi/rules/vue/${ruleId.toLowerCase()}`,
|
|
5
|
-
pluginId: "vue",
|
|
6
|
-
presets: [
|
|
7
|
-
"logical",
|
|
8
|
-
"logicalStrict",
|
|
9
|
-
"stylistic",
|
|
10
|
-
"stylisticStrict"
|
|
11
|
-
]
|
|
12
|
-
});
|
|
13
|
-
//#endregion
|
|
14
|
-
export { ruleCreator };
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=ruleCreator.js.map
|
package/lib/rules/vForKeys.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
-
readonly description: "Reports v-for directives without a valid key binding.";
|
|
3
|
-
readonly id: "vForKeys";
|
|
4
|
-
readonly presets: readonly ["logical"];
|
|
5
|
-
} & {
|
|
6
|
-
readonly pluginId: string;
|
|
7
|
-
readonly url: string;
|
|
8
|
-
}, "invalidKey" | "missingKey" | "staticKey", undefined>;
|
|
9
|
-
export default _default;
|
|
10
|
-
//# sourceMappingURL=vForKeys.d.ts.map
|