@flint.fyi/vue 0.0.1 → 0.1.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/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ # MIT License
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ 'Software'), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,45 +1,9 @@
1
- # @flint.fyi/vue
1
+ <h1 align="center"><code>@flint.fyi/vue</code></h1>
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
3
+ <p align="center">
4
+ [Experimental] Vue.js language plugin for Flint.
5
+ ❤️‍🔥
6
+ </p>
4
7
 
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
6
-
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
-
9
- ## Purpose
10
-
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@flint.fyi/vue`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
15
-
16
- ## What is OIDC Trusted Publishing?
17
-
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
-
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**
8
+ This is an internal package for Flint.
9
+ Documentation will eventually be added.
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { vue } from "./plugin.js";
2
+ export { vue };
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { vue } from "./plugin.js";
2
+ export { vue };
@@ -0,0 +1,14 @@
1
+ import * as _flint_fyi_core0 from "@flint.fyi/core";
2
+
3
+ //#region src/plugin.d.ts
4
+ declare const vue: _flint_fyi_core0.Plugin<_flint_fyi_core0.RuleAbout<string>, "all", [_flint_fyi_core0.Rule<{
5
+ readonly description: "Reports v-for directives without a valid key binding.";
6
+ readonly id: "vForKeys";
7
+ readonly presets: readonly ["logical"];
8
+ } & {
9
+ readonly pluginId: string;
10
+ readonly url: string;
11
+ }, "invalidKey" | "missingKey" | "staticKey", undefined>]>;
12
+ //#endregion
13
+ export { vue };
14
+ //# sourceMappingURL=plugin.d.ts.map
package/lib/plugin.js ADDED
@@ -0,0 +1,13 @@
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
@@ -0,0 +1,3 @@
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
@@ -0,0 +1,16 @@
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
@@ -0,0 +1,10 @@
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
@@ -0,0 +1,139 @@
1
+ import { ruleCreator } from "./ruleCreator.js";
2
+ import { nullThrows } from "@flint.fyi/utils";
3
+ import { reportSourceCode } from "@flint.fyi/volar-language";
4
+ import { vueLanguage } from "@flint.fyi/vue-language";
5
+ import * as vue from "@vue/compiler-dom";
6
+ import ts from "typescript";
7
+ //#region src/rules/vForKeys.ts
8
+ var vForKeys_default = ruleCreator.createRule(vueLanguage, {
9
+ about: {
10
+ description: "Reports v-for directives without a valid key binding.",
11
+ id: "vForKeys",
12
+ presets: ["logical"]
13
+ },
14
+ messages: {
15
+ invalidKey: {
16
+ primary: "The :key on this v-for element does not reference the iteration variable.",
17
+ secondary: ["Keys must uniquely identify each item in the v-for loop to maintain object constancy.", "Using values unrelated to the loop can still lead to rendering issues during reordering."],
18
+ suggestions: ["Bind the :key to something derived from the v-for item, like item.id or the index if no unique identifier exists."]
19
+ },
20
+ missingKey: {
21
+ primary: "Elements using v-for must include a unique :key to ensure correct reactivity and DOM stability.",
22
+ secondary: ["A missing :key can cause unpredictable updates during rendering optimizations.", "Without a key, Vue may reuse or reorder elements incorrectly, which breaks expected behavior in transitions and stateful components."],
23
+ suggestions: ["Always provide a unique :key based on the v-for item, such as an id."]
24
+ },
25
+ staticKey: {
26
+ primary: "Static key values prevent Vue from tracking changes in v-for lists.",
27
+ secondary: ["Using key=\"literal\" means every item in the v-for shares the same key, which prevents Vue from tracking list updates correctly.", "This blocks proper reactivity, leading to stale DOM content and skipped updates."],
28
+ suggestions: ["Replace the static key with a dynamic and unique :key derived from the v-for item, such as item.id."]
29
+ }
30
+ },
31
+ setup(context) {
32
+ return { visitors: { SourceFile(node, services) {
33
+ if (services.vue == null) return;
34
+ const { map, sfc } = services.vue;
35
+ const toGeneratedLocation = (sourceLocation) => {
36
+ for (const [loc] of map.toGeneratedLocation(sourceLocation)) return loc;
37
+ };
38
+ const toGeneratedLocationOrThrow = (sourceLocation) => {
39
+ return nullThrows(toGeneratedLocation(sourceLocation), "Unable to map source location to generated location");
40
+ };
41
+ const templateBlock = sfc.children.find((c) => c.type === vue.NodeTypes.ELEMENT && c.tag === "template");
42
+ if (templateBlock == null) return {};
43
+ const propValueRange = (propValue) => {
44
+ const strip = propValue.loc.source === propValue.content ? 0 : 1;
45
+ return {
46
+ begin: propValue.loc.start.offset + strip,
47
+ end: propValue.loc.end.offset - strip
48
+ };
49
+ };
50
+ const checkFor = (forDirective, forParseResult, keyProp) => {
51
+ if (keyProp == null) {
52
+ reportSourceCode(context, {
53
+ message: "missingKey",
54
+ range: {
55
+ begin: forDirective.loc.start.offset,
56
+ end: forDirective.loc.start.offset + 5
57
+ }
58
+ });
59
+ return;
60
+ }
61
+ if (keyProp.type === vue.NodeTypes.ATTRIBUTE) {
62
+ if (keyProp.value == null) return;
63
+ reportSourceCode(context, {
64
+ message: "staticKey",
65
+ range: propValueRange(keyProp.value)
66
+ });
67
+ return;
68
+ }
69
+ let reportRange;
70
+ let valueRange;
71
+ if (keyProp.exp == null) {
72
+ reportRange = {
73
+ begin: keyProp.loc.start.offset,
74
+ end: keyProp.loc.end.offset
75
+ };
76
+ const valueMapping = nullThrows(Array.from(map.toGeneratedLocation(nullThrows(keyProp.arg, "Expected keyProp.arg to be non-null").loc.start.offset)).filter(([, m]) => nullThrows(m.lengths[0], "Expected mapping to have at least one range") > 0)[1], "Expected :key two have two mappings")[1];
77
+ const generatedBegin = nullThrows(valueMapping.generatedOffsets[0], "Expected mapping to have at least one range");
78
+ valueRange = {
79
+ begin: generatedBegin,
80
+ end: generatedBegin + nullThrows(valueMapping.lengths[0], "Expected mapping to have at least one range")
81
+ };
82
+ } else {
83
+ reportRange = {
84
+ begin: keyProp.exp.loc.start.offset,
85
+ end: keyProp.exp.loc.end.offset
86
+ };
87
+ valueRange = {
88
+ begin: toGeneratedLocationOrThrow(keyProp.exp.loc.start.offset),
89
+ end: toGeneratedLocationOrThrow(keyProp.exp.loc.end.offset)
90
+ };
91
+ }
92
+ const loopVariableRanges = [
93
+ forParseResult.value,
94
+ forParseResult.key,
95
+ forParseResult.index
96
+ ].filter((v) => v != null).map((v) => ({
97
+ begin: toGeneratedLocationOrThrow(v.loc.start.offset),
98
+ end: toGeneratedLocationOrThrow(v.loc.end.offset)
99
+ }));
100
+ const find = (current) => {
101
+ const currentBegin = current.getStart(node);
102
+ const currentEnd = current.getEnd();
103
+ if (currentBegin > valueRange.end || currentEnd <= valueRange.begin) return false;
104
+ if (currentBegin >= valueRange.begin && currentEnd <= valueRange.end && ts.isIdentifier(current)) {
105
+ const symbol = services.typeChecker.getSymbolAtLocation(current);
106
+ if (symbol?.valueDeclaration == null) return false;
107
+ const declStart = symbol.valueDeclaration.getStart(node);
108
+ const declEnd = symbol.valueDeclaration.getEnd();
109
+ return loopVariableRanges.some(({ begin, end }) => declStart >= begin && declEnd <= end);
110
+ }
111
+ return current.getChildren(node).some(find);
112
+ };
113
+ if (!find(node)) reportSourceCode(context, {
114
+ message: "invalidKey",
115
+ range: reportRange
116
+ });
117
+ };
118
+ function visitTag(node) {
119
+ if (node.type === vue.NodeTypes.ELEMENT) {
120
+ let forDirective = null;
121
+ let forParseResult = null;
122
+ let keyProp = null;
123
+ for (const prop of node.props) if (prop.type === vue.NodeTypes.DIRECTIVE && prop.name === "for" && prop.forParseResult != null) {
124
+ forDirective = prop;
125
+ 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;
128
+ if (forDirective != null && forParseResult != null) checkFor(forDirective, forParseResult, keyProp);
129
+ for (const child of node.children) visitTag(child);
130
+ }
131
+ }
132
+ for (const child of templateBlock.children) visitTag(child);
133
+ } } };
134
+ }
135
+ });
136
+ //#endregion
137
+ export { vForKeys_default as default };
138
+
139
+ //# sourceMappingURL=vForKeys.js.map
package/package.json CHANGED
@@ -1,10 +1,50 @@
1
1
  {
2
2
  "name": "@flint.fyi/vue",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for @flint.fyi/vue",
5
- "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
10
- }
3
+ "version": "0.1.1",
4
+ "description": "[Experimental] Vue.js language plugin for Flint.",
5
+ "homepage": "https://flint.fyi/rules/vue",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/flint-fyi/flint.git",
9
+ "directory": "packages/vue"
10
+ },
11
+ "license": "MIT",
12
+ "author": {
13
+ "name": "JoshuaKGoldberg",
14
+ "email": "npm@joshuakgoldberg.com"
15
+ },
16
+ "sideEffects": false,
17
+ "type": "module",
18
+ "exports": {
19
+ ".": "./lib/index.js"
20
+ },
21
+ "files": [
22
+ "lib/",
23
+ "!lib/**/*.map"
24
+ ],
25
+ "dependencies": {
26
+ "@vue/compiler-dom": "^3.5.0",
27
+ "typescript": "^5.9.0 || ^6.0.0",
28
+ "@flint.fyi/core": "^0.21.2",
29
+ "@flint.fyi/ts": "^0.19.0",
30
+ "@flint.fyi/utils": "^0.14.1",
31
+ "@flint.fyi/volar-language": "^0.1.0",
32
+ "@flint.fyi/vue-language": "^0.1.0"
33
+ },
34
+ "devDependencies": {
35
+ "tsdown": "0.21.0",
36
+ "vitest": "4.1.0",
37
+ "vue": "3.5.30",
38
+ "@flint.fyi/rule-tester": "^0.16.2",
39
+ "@flint.fyi/typescript-language": "^0.18.1"
40
+ },
41
+ "engines": {
42
+ "node": ">=24.0.0"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "scripts": {
48
+ "test": "vitest --project vue"
49
+ }
50
+ }