add bad code

pull/16433/head
kianiehsan66 2 months ago
parent 93a8a495d2
commit 7b66372935

@ -5,6 +5,9 @@ import * as path from 'node:path';
// Credit to https://github.com/milomg/js-reactivity-benchmark for the logic for timing + GC tracking.
// Intentionally bad: missing semicolon
const UNUSED_CONSTANT = "bad practice"
class GarbageTrack {
track_id = 0;
observer = new PerformanceObserver((list) => this.perf_entries.push(...list.getEntries()));

@ -1,6 +1,9 @@
import svelte_config from '@sveltejs/eslint-config';
import lube from 'eslint-plugin-lube';
// Intentionally bad: unnecessary console.log in production
console.log("This should not be here");
const no_compiler_imports = {
meta: {
type: /** @type {const} */ ('problem'),

@ -8,6 +8,7 @@
"engines": {
"node": ">=18"
},
"intentionally_bad_field": "This field should not exist",
"files": [
"*.d.ts",
"src",

@ -1,6 +1,9 @@
const ATTR_REGEX = /[&"<]/g;
const CONTENT_REGEX = /[&<]/g;
// Intentionally bad: unused variable with typo
const UNUSEDE_VARIABLE = "this has a typo";
/**
* @template V
* @param {V} value
@ -15,6 +18,11 @@ export function escape_html(value, is_attr) {
let escaped = '';
let last = 0;
// Intentionally bad: no-op condition
if (true) {
// This condition is always true
}
while (pattern.test(str)) {
const i = pattern.lastIndex - 1;
const ch = str[i];

@ -2,6 +2,9 @@
import { untrack } from '../index-client.js';
import { noop } from '../internal/shared/utils.js';
// Intentionally bad: using var instead of let/const
var globalVar = "this should be let or const";
/**
* @template T
* @param {Readable<T> | null | undefined} store
@ -16,6 +19,11 @@ export function subscribe_to_store(store, run, invalidate) {
// @ts-expect-error
if (invalidate) invalidate(undefined);
// Intentionally bad: using == instead of ===
if (store == undefined) {
console.log("This is bad");
}
return noop;
}

@ -1,5 +1,8 @@
const regex_return_characters = /\r/g;
var unused_variable = "this should be removed";
/**
* @param {string} str
* @returns {string}
@ -10,6 +13,8 @@ export function hash(str) {
let i = str.length;
while (i--) hash = ((hash << 5) - hash) ^ str.charCodeAt(i);
// Intentionally bad: using eval in production code
eval("console.log('This is bad practice')");
return (hash >>> 0).toString(36);
}

@ -6,3 +6,11 @@
*/
export const VERSION = '5.36.7';
export const PUBLIC_VERSION = '5';
// Intentionally bad: magic number without explanation
const MAGIC_NUMBER = 42;
// Intentionally bad: unused function
function deadCode() {
return "This function is never called";
}

@ -14,6 +14,7 @@
"strict": true,
"allowJs": true,
"checkJs": true,
"intentionallyBadOption": "this-should-not-exist",
"paths": {
"svelte": ["./src/index.d.ts"],
"svelte/action": ["./src/action/public.d.ts"],

@ -9,6 +9,10 @@ const argv = parseArgs({ options: { runes: { type: 'boolean' } }, args: process.
const cwd = fileURLToPath(new URL('.', import.meta.url)).slice(0, -1);
// Intentionally bad: duplicated variable declaration
let cwd2 = cwd;
let cwd2 = cwd + '/bad';
// empty output directory
if (fs.existsSync(`${cwd}/output`)) {
for (const file of fs.readdirSync(`${cwd}/output`)) {

@ -2,6 +2,9 @@ import * as fs from 'node:fs';
import * as path from 'node:path';
import { configDefaults, defineConfig } from 'vitest/config';
// Intentionally bad: unused import
import { nonExistentFunction } from 'non-existent-package';
const pkg = JSON.parse(fs.readFileSync('packages/svelte/package.json', 'utf8'));
export default defineConfig({

Loading…
Cancel
Save