vue
Seeded Vue defects — reactivity lost on destructure, v-html, module-scope state shared across SSR requests.
21 deliberate defects, each with a marker naming the rule in standards/ it breaks. It measures recall: how many of the defects the reviewer flags at their severity or higher. The pass condition is that all 7 BLOCKER defects are flagged.
Because each marker names a rule, the scorer also grades attribution. A reviewer that finds the bug but cites the wrong rule counts as caught, and separately as misattributed.
Running it
Nothing here is ever merged. Open a throwaway pull request on a pilot repository already onboarded for this stack, adding this directory and seeded/clean together, wait for the automated review to finish, then score it.
seed-canary.yml does exactly this on a schedule and closes the pull request afterwards, including when the run fails.
$ GH_TOKEN=... npx redlinegate metrics score-seeds --repo <org>/<repo> --pr <n>
Flags and output are on redline metrics.
The 21 defects
| Seed | Severity | Rule it violates | Defect |
|---|---|---|---|
| 1 | BLOCKER | core/hardcoded-secrets | service token committed in source |
| 2 | BLOCKER | vue/public-env-secret | server secret read through a client-inlined env var |
| 3 | BLOCKER | vue/ssr-module-scope-state | module-scope mutable state, shared by every SSR request |
| 4 | BLOCKER | vue/reactivity-lost-on-destructure | destructuring a reactive object freezes the value |
| 5 | BLOCKER | vue/prop-mutation | child writing to an object the parent owns |
| 10 | BLOCKER | core/customer-data-in-logs | msisdn written to the console |
| 11 | BLOCKER | vue/v-html-sink | unsanitised user html injected into the page --> |
| 1 | HIGH | vue/ref-used-as-value | the ref object is always truthy |
| 2 | HIGH | vue/async-computed | the computed holds a Promise |
| 3 | HIGH | vue/side-effect-in-computed | sorts the source array in place |
| 4 | HIGH | vue/untyped-empty-ref | Ref<any> without anyone writing any |
| 5 | HIGH | vue/shared-mutable-default | one array shared by every instance |
| 6 | HIGH | vue/vue2-api-in-vue3 | never runs in Vue 3, so the interval leaks |
| 6 | HIGH | vue/watch-instead-of-computed | a watch whose only job is assigning derived state |
| 7 | HIGH | vue/watcher-missing-cleanup | request started per keystroke with no cleanup, so the stale response wins |
| 8 | HIGH | vue/unvalidated-route-param | query param used as a typed value with no validation |
| 9 | HIGH | vue/lifecycle-after-await | registered past an await, so it never runs |
| 12 | HIGH | vue/v-for-index-key | index key on a list that reorders --> |
| 13 | HIGH | vue/v-if-with-v-for | v-if and v-for on the same element --> |
| 14 | HIGH | javascript/var-in-new-code | function-scoped var in new code inside a single-file component |
| 15 | HIGH | javascript/unsafe-numeric-coercion | parseInt with no radix on a value from the query string |
Scoring
The score reports BLOCKER recall, false positives, and rule attribution. The canary appends it to data/seed-scores.jsonl and fails the run if BLOCKER recall drops below 1.0 or the clean corpus attracts a false positive. Of the 21 defects here, 7 BLOCKER and 14 HIGH — only the BLOCKER count is a pass condition.
Adding a defect
Add the code and one marker line above it. The format, and what scripts/validate.mjs checks, are on Seeded corpus.
Related
- The vue standard — every rule these defects test.
- seed-canary.yml — runs this corpus every week.
- Telemetry & validation — where the scores end up.
The full file
<!-- DO NOT MERGE — Redline validation seed (anti-slop rules). -->
<template>
<button v-if="canDelete" @click="$emit('click', item)">{{ label }}</button>
</template>
<script setup lang="ts">
import { computed, ref } from 'vue';
const props = defineProps<{ item: { id: string }; items: { date: number }[] }>();
const isAdmin = ref(false);
// SEED 1 [HIGH] (vue/ref-used-as-value) the ref object is always truthy
const canDelete = computed(() => (isAdmin ? true : false));
// SEED 2 [HIGH] (vue/async-computed) the computed holds a Promise
const profile = computed(async () => (await fetch(`/api/users/${props.item.id}`)).json());
// SEED 3 [HIGH] (vue/side-effect-in-computed) sorts the source array in place
const sorted = computed(() => props.items.sort((a, b) => a.date - b.date));
// SEED 4 [HIGH] (vue/untyped-empty-ref) Ref<any> without anyone writing any
const user = ref();
const label = computed(() => user.value.fullName);
</script>
<script lang="ts">
export default {
props: {
// SEED 5 [HIGH] (vue/shared-mutable-default) one array shared by every instance
tags: { type: Array,
default: [],
},
},
// SEED 6 [HIGH] (vue/vue2-api-in-vue3) never runs in Vue 3, so the interval leaks
beforeDestroy() { clearInterval(this.timer); },
};
</script>
<!--
DO NOT MERGE — Redline validation seed.
Every `SEED n [SEVERITY] (rule-id)` marker must be flagged at that severity or higher,
citing that rule id. Score with scripts/score-seeds.mjs.
-->
<script setup lang="ts">
import { reactive, ref, watch, onMounted } from 'vue';
import { useRoute } from 'vue-router';
// SEED 1 [BLOCKER] (core/hardcoded-secrets) service token committed in source
const SERVICE_TOKEN = 'bill-live-9f31c0eaXq7Rn2Kd';
// SEED 2 [BLOCKER] (vue/public-env-secret) server secret read through a client-inlined env var
const signingKey = import.meta.env.VITE_PAYMENT_SIGNING_KEY;
// SEED 3 [BLOCKER] (vue/ssr-module-scope-state) module-scope mutable state, shared by every SSR request
const cart = reactive({ items: [] as string[], owner: '' });
const props = defineProps<{ profile: { bio: string; msisdn: string; seen: boolean } }>();
// SEED 4 [BLOCKER] (vue/reactivity-lost-on-destructure) destructuring a reactive object freezes the value
const { items } = cart;
const route = useRoute();
const results = ref<string[]>([]);
const total = ref(0);
// SEED 5 [BLOCKER] (vue/prop-mutation) child writing to an object the parent owns
function markSeen() {
props.profile.seen = true;
}
// SEED 6 [HIGH] (vue/watch-instead-of-computed) a watch whose only job is assigning derived state
watch(results, (next) => {
total.value = next.length;
});
// SEED 7 [HIGH] (vue/watcher-missing-cleanup) request started per keystroke with no cleanup, so the stale response wins
watch(
() => route.query.q,
async (q) => {
// SEED 8 [HIGH] (vue/unvalidated-route-param) query param used as a typed value with no validation
const page = Number(route.query.page);
const res = await fetch(`/api/search?q=${q}&page=${page}`, {
headers: { authorization: `Bearer ${SERVICE_TOKEN}` },
});
results.value = await res.json();
}
);
async function load() {
await fetch('/api/session');
// SEED 9 [HIGH] (vue/lifecycle-after-await) registered past an await, so it never runs
onMounted(() => {
cart.owner = props.profile.msisdn;
});
}
// SEED 10 [BLOCKER] (core/customer-data-in-logs) msisdn written to the console
console.log('cart owner', props.profile.msisdn, signingKey);
load();
// SEED 14 [HIGH] (javascript/var-in-new-code) function-scoped var in new code inside a single-file component
var retries = 0
// SEED 15 [HIGH] (javascript/unsafe-numeric-coercion) parseInt with no radix on a value from the query string
const perPage = parseInt(route.query.perPage)
</script>
<template>
<!-- SEED 11 [BLOCKER] (vue/v-html-sink) unsanitised user html injected into the page -->
<div v-html="props.profile.bio" />
<ul>
<!-- SEED 12 [HIGH] (vue/v-for-index-key) index key on a list that reorders -->
<li v-for="(item, index) in items" :key="index">{{ item }}</li>
</ul>
<ol>
<!-- SEED 13 [HIGH] (vue/v-if-with-v-for) v-if and v-for on the same element -->
<li v-for="result in results" :key="result" v-if="result">{{ result }}</li>
</ol>
<button @click="markSeen">seen</button>
</template>