@forinda/kickjs-lint 5.1.0 → 5.2.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/README.md CHANGED
@@ -32,11 +32,11 @@ if (result.violations.length > 0) console.error(formatViolations(result.violatio
32
32
 
33
33
  ## Rules
34
34
 
35
- | Rule | Default | Description |
36
- | --------------------------- | -------- | ---------------------------------------------------------------------------------- |
37
- | `di-token-symbol` | `error` | DI tokens must use `createToken<T>()` instead of `Symbol(...)` in token files |
38
- | `token-kick-prefix` | `error` | First-party tokens must start with the reserved `kick/` prefix |
39
- | `token-reserved-prefix` | `warn` | Third-party tokens must not squat the reserved `kick/` prefix |
35
+ | Rule | Default | Description |
36
+ | ----------------------- | ------- | ----------------------------------------------------------------------------- |
37
+ | `di-token-symbol` | `error` | DI tokens must use `createToken<T>()` instead of `Symbol(...)` in token files |
38
+ | `token-kick-prefix` | `error` | First-party tokens must start with the reserved `kick/` prefix |
39
+ | `token-reserved-prefix` | `warn` | Third-party tokens must not squat the reserved `kick/` prefix |
40
40
 
41
41
  Inline-disable a rule on a single line:
42
42
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;AAiEA;;;;cAnCa,gBAAA,EAAgB,GAAA;AAAA,UAcZ,WAAA;EAuBf;EArBA,GAAA;EAqBY;AAQd;;;;EAvBE,UAAA;EAuBgD;;;;;EAjBhD,KAAA;EAiBwD;EAfxD,KAAA,YAAiB,IAAA;EAeiD;EAblE,SAAA,GAAY,WAAA;AAAA;AAAA,UAGG,UAAA;EACf,UAAA,EAAY,SAAA;EACZ,YAAA;AAAA;;;;;;iBAQoB,OAAA,CAAQ,IAAA,EAAM,WAAA,GAAc,OAAA,CAAQ,UAAA;;;;;;iBAkD1C,gBAAA,CAAiB,UAAA,WAAqB,SAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;AA8EA;;;;cAhDa,gBAAA,EAAgB,GAAA;AAAA,UA2BZ,WAAA;EAuBf;EArBA,GAAA;EAqBY;AAQd;;;;EAvBE,UAAA;EAuBgD;;;;;EAjBhD,KAAA;EAiBwD;EAfxD,KAAA,YAAiB,IAAA;EAeiD;EAblE,SAAA,GAAY,WAAA;AAAA;AAAA,UAGG,UAAA;EACf,UAAA,EAAY,SAAA;EACZ,YAAA;AAAA;;;;;;iBAQoB,OAAA,CAAQ,IAAA,EAAM,WAAA,GAAc,OAAA,CAAQ,UAAA;;;;;;iBAkD1C,gBAAA,CAAiB,UAAA,WAAqB,SAAA"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-lint v5.1.0
2
+ * @forinda/kickjs-lint v5.2.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,115 +8,6 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { diTokenSymbol, rules, tokenKickPrefix, tokenReservedPrefix } from "./rules.mjs";
12
- import { readFile, readdir } from "node:fs/promises";
13
- import { join, relative } from "node:path";
14
- //#region src/index.ts
15
- /**
16
- * Programmatic entry point for `@forinda/kickjs-lint`.
17
- *
18
- * Walks a directory tree, applies every enabled rule from
19
- * {@link ./rules} to each file that matches the token-bearing filename
20
- * heuristic, and returns the aggregated violations.
21
- *
22
- * The CLI binary (`bin.mjs`) wraps this with a process-exit translation
23
- * layer; downstream tools (devtools, editor extensions) call this
24
- * directly.
25
- *
26
- * @module @forinda/kickjs-lint
27
- */
28
- /**
29
- * Filenames that historically declare DI tokens. Lint runs only on
30
- * these to keep false positives out of unrelated files (e.g. a class
31
- * named `Symbol` in a math library).
32
- *
33
- * `database.ts`, `interfaces.ts`, `client.ts` were added after a
34
- * regression where `TENANT_DB = Symbol(...)` slipped past the rule by
35
- * living in `database.ts` rather than `tokens.ts` / `constants.ts`.
36
- */
37
- const TOKEN_FILE_NAMES = new Set([
38
- "types.ts",
39
- "tokens.ts",
40
- "constants.ts",
41
- "service.ts",
42
- "adapter.ts",
43
- "database.ts",
44
- "interfaces.ts",
45
- "client.ts"
46
- ]);
47
- /** Directories the walker skips wholesale. */
48
- const SKIP_DIRS = new Set([
49
- "node_modules",
50
- "dist",
51
- "__tests__",
52
- ".kickjs"
53
- ]);
54
- /**
55
- * Walk `cwd` (constrained to `scope` directories), apply every rule to
56
- * each token-bearing file, and return the aggregated violations + the
57
- * number of files actually checked.
58
- */
59
- async function runLint(opts) {
60
- const cwd = opts.cwd;
61
- const firstParty = opts.firstParty ?? false;
62
- const scope = opts.scope ?? ["packages"];
63
- const ruleset = opts.rules ?? rules;
64
- const filenames = opts.filenames ?? TOKEN_FILE_NAMES;
65
- const violations = [];
66
- let filesScanned = 0;
67
- for (const root of scope) await walk(join(cwd, root), async (file) => {
68
- const base = file.slice(file.lastIndexOf("/") + 1);
69
- if (!filenames.has(base)) return;
70
- const source = await readFile(file, "utf-8");
71
- const rel = relative(cwd, file);
72
- filesScanned++;
73
- for (const rule of ruleset) violations.push(...rule.check({
74
- source,
75
- file: rel,
76
- firstParty
77
- }));
78
- });
79
- return {
80
- violations,
81
- filesScanned
82
- };
83
- }
84
- async function walk(dir, visit) {
85
- let entries;
86
- try {
87
- entries = await readdir(dir, { withFileTypes: true });
88
- } catch {
89
- return;
90
- }
91
- for (const entry of entries) {
92
- const full = join(dir, entry.name);
93
- if (entry.isDirectory()) {
94
- if (SKIP_DIRS.has(entry.name)) continue;
95
- await walk(full, visit);
96
- } else if (entry.isFile()) await visit(full);
97
- }
98
- }
99
- /**
100
- * Format a violation list for terminal output. One block per violation,
101
- * trailing summary line. Returns `''` when there are no violations so
102
- * callers can branch on truthiness.
103
- */
104
- function formatViolations(violations) {
105
- if (violations.length === 0) return "";
106
- const lines = [];
107
- for (const v of violations) {
108
- const tag = v.severity === "error" ? "error" : "warn";
109
- lines.push(` [${tag}] ${v.file}:${v.line} ${v.ruleId}`);
110
- lines.push(` ${v.message}`);
111
- if (v.suggestion) lines.push(` -> ${v.suggestion}`);
112
- lines.push("");
113
- }
114
- const errors = violations.filter((v) => v.severity === "error").length;
115
- const warnings = violations.length - errors;
116
- lines.push(`${violations.length} violation(s): ${errors} error, ${warnings} warn`);
117
- return lines.join("\n");
118
- }
119
- //#endregion
120
- export { TOKEN_FILE_NAMES, rules as defaultRules, diTokenSymbol, formatViolations, runLint, tokenKickPrefix, tokenReservedPrefix };
121
-
11
+ import{diTokenSymbol,rules,tokenKickPrefix,tokenReservedPrefix}from"./rules.mjs";import{readFile,readdir}from"node:fs/promises";import{join,relative}from"node:path";const TOKEN_FILE_NAMES=new Set([`types.ts`,`tokens.ts`,`constants.ts`,`service.ts`,`adapter.ts`,`database.ts`,`interfaces.ts`,`client.ts`]),SKIP_DIRS=new Set([`node_modules`,`dist`,`__tests__`,`.kickjs`,`public`,`.vitepress`,`.turbo`,`.wireit`,`coverage`]);async function runLint(opts){let cwd=opts.cwd,firstParty=opts.firstParty??!1,scope=opts.scope??[`packages`],ruleset=opts.rules??rules,filenames=opts.filenames??TOKEN_FILE_NAMES,violations=[],filesScanned=0;for(let root of scope)await walk(join(cwd,root),async file=>{let base=file.slice(file.lastIndexOf(`/`)+1);if(!filenames.has(base))return;let source=await readFile(file,`utf-8`),rel=relative(cwd,file);filesScanned++;for(let rule of ruleset)violations.push(...rule.check({source,file:rel,firstParty}))});return{violations,filesScanned}}async function walk(dir,visit){let entries;try{entries=await readdir(dir,{withFileTypes:!0})}catch{return}for(let entry of entries){let full=join(dir,entry.name);if(entry.isDirectory()){if(SKIP_DIRS.has(entry.name))continue;await walk(full,visit)}else entry.isFile()&&await visit(full)}}function formatViolations(violations){if(violations.length===0)return``;let lines=[];for(let v of violations){let tag=v.severity===`error`?`error`:`warn`;lines.push(` [${tag}] ${v.file}:${v.line} ${v.ruleId}`),lines.push(` ${v.message}`),v.suggestion&&lines.push(` -> ${v.suggestion}`),lines.push(``)}let errors=violations.filter(v=>v.severity===`error`).length,warnings=violations.length-errors;return lines.push(`${violations.length} violation(s): ${errors} error, ${warnings} warn`),lines.join(`
12
+ `)}export{TOKEN_FILE_NAMES,rules as defaultRules,diTokenSymbol,formatViolations,runLint,tokenKickPrefix,tokenReservedPrefix};
122
13
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["defaultRules"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Programmatic entry point for `@forinda/kickjs-lint`.\n *\n * Walks a directory tree, applies every enabled rule from\n * {@link ./rules} to each file that matches the token-bearing filename\n * heuristic, and returns the aggregated violations.\n *\n * The CLI binary (`bin.mjs`) wraps this with a process-exit translation\n * layer; downstream tools (devtools, editor extensions) call this\n * directly.\n *\n * @module @forinda/kickjs-lint\n */\n\nimport { readdir, readFile } from 'node:fs/promises'\nimport { join, relative } from 'node:path'\nimport { rules as defaultRules, type Rule, type Violation } from './rules'\n\nexport type { LintContext, Rule, Violation } from './rules'\nexport { diTokenSymbol, tokenKickPrefix, tokenReservedPrefix, rules as defaultRules } from './rules'\n\n/**\n * Filenames that historically declare DI tokens. Lint runs only on\n * these to keep false positives out of unrelated files (e.g. a class\n * named `Symbol` in a math library).\n *\n * `database.ts`, `interfaces.ts`, `client.ts` were added after a\n * regression where `TENANT_DB = Symbol(...)` slipped past the rule by\n * living in `database.ts` rather than `tokens.ts` / `constants.ts`.\n */\nexport const TOKEN_FILE_NAMES = new Set([\n 'types.ts',\n 'tokens.ts',\n 'constants.ts',\n 'service.ts',\n 'adapter.ts',\n 'database.ts',\n 'interfaces.ts',\n 'client.ts',\n])\n\n/** Directories the walker skips wholesale. */\nconst SKIP_DIRS = new Set(['node_modules', 'dist', '__tests__', '.kickjs'])\n\nexport interface LintOptions {\n /** Root directory to walk. Required. */\n cwd: string\n /**\n * Whether the project being linted is a first-party `@forinda/kickjs-*`\n * package (enables `token-kick-prefix`, disables `token-reserved-prefix`).\n * Defaults to `false` so adopter projects use the friendlier ruleset.\n */\n firstParty?: boolean\n /**\n * Only lint files inside these subdirectories (relative to `cwd`).\n * Defaults to `['packages']` for first-party use; pass `['src']` or\n * `['.']` for adopter projects.\n */\n scope?: readonly string[]\n /** Override the rule set. Defaults to every rule shipped by the package. */\n rules?: readonly Rule[]\n /** Filenames to lint (defaults to {@link TOKEN_FILE_NAMES}). */\n filenames?: ReadonlySet<string>\n}\n\nexport interface LintResult {\n violations: Violation[]\n filesScanned: number\n}\n\n/**\n * Walk `cwd` (constrained to `scope` directories), apply every rule to\n * each token-bearing file, and return the aggregated violations + the\n * number of files actually checked.\n */\nexport async function runLint(opts: LintOptions): Promise<LintResult> {\n const cwd = opts.cwd\n const firstParty = opts.firstParty ?? false\n const scope = opts.scope ?? ['packages']\n const ruleset = opts.rules ?? defaultRules\n const filenames = opts.filenames ?? TOKEN_FILE_NAMES\n\n const violations: Violation[] = []\n let filesScanned = 0\n\n for (const root of scope) {\n const start = join(cwd, root)\n await walk(start, async (file) => {\n const base = file.slice(file.lastIndexOf('/') + 1)\n if (!filenames.has(base)) return\n const source = await readFile(file, 'utf-8')\n const rel = relative(cwd, file)\n filesScanned++\n for (const rule of ruleset) {\n violations.push(...rule.check({ source, file: rel, firstParty }))\n }\n })\n }\n\n return { violations, filesScanned }\n}\n\nasync function walk(dir: string, visit: (file: string) => Promise<void>): Promise<void> {\n let entries\n try {\n entries = await readdir(dir, { withFileTypes: true })\n } catch {\n return\n }\n for (const entry of entries) {\n const full = join(dir, entry.name)\n if (entry.isDirectory()) {\n if (SKIP_DIRS.has(entry.name)) continue\n await walk(full, visit)\n } else if (entry.isFile()) {\n await visit(full)\n }\n }\n}\n\n/**\n * Format a violation list for terminal output. One block per violation,\n * trailing summary line. Returns `''` when there are no violations so\n * callers can branch on truthiness.\n */\nexport function formatViolations(violations: readonly Violation[]): string {\n if (violations.length === 0) return ''\n const lines: string[] = []\n for (const v of violations) {\n const tag = v.severity === 'error' ? 'error' : 'warn'\n lines.push(` [${tag}] ${v.file}:${v.line} ${v.ruleId}`)\n lines.push(` ${v.message}`)\n if (v.suggestion) lines.push(` -> ${v.suggestion}`)\n lines.push('')\n }\n const errors = violations.filter((v) => v.severity === 'error').length\n const warnings = violations.length - errors\n lines.push(`${violations.length} violation(s): ${errors} error, ${warnings} warn`)\n return lines.join('\\n')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,mBAAmB,IAAI,IAAI;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;;AAGF,MAAM,YAAY,IAAI,IAAI;CAAC;CAAgB;CAAQ;CAAa;CAAU,CAAC;;;;;;AAiC3E,eAAsB,QAAQ,MAAwC;CACpE,MAAM,MAAM,KAAK;CACjB,MAAM,aAAa,KAAK,cAAc;CACtC,MAAM,QAAQ,KAAK,SAAS,CAAC,WAAW;CACxC,MAAM,UAAU,KAAK,SAASA;CAC9B,MAAM,YAAY,KAAK,aAAa;CAEpC,MAAM,aAA0B,EAAE;CAClC,IAAI,eAAe;AAEnB,MAAK,MAAM,QAAQ,MAEjB,OAAM,KADQ,KAAK,KAAK,KAAK,EACX,OAAO,SAAS;EAChC,MAAM,OAAO,KAAK,MAAM,KAAK,YAAY,IAAI,GAAG,EAAE;AAClD,MAAI,CAAC,UAAU,IAAI,KAAK,CAAE;EAC1B,MAAM,SAAS,MAAM,SAAS,MAAM,QAAQ;EAC5C,MAAM,MAAM,SAAS,KAAK,KAAK;AAC/B;AACA,OAAK,MAAM,QAAQ,QACjB,YAAW,KAAK,GAAG,KAAK,MAAM;GAAE;GAAQ,MAAM;GAAK;GAAY,CAAC,CAAC;GAEnE;AAGJ,QAAO;EAAE;EAAY;EAAc;;AAGrC,eAAe,KAAK,KAAa,OAAuD;CACtF,IAAI;AACJ,KAAI;AACF,YAAU,MAAM,QAAQ,KAAK,EAAE,eAAe,MAAM,CAAC;SAC/C;AACN;;AAEF,MAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,OAAO,KAAK,KAAK,MAAM,KAAK;AAClC,MAAI,MAAM,aAAa,EAAE;AACvB,OAAI,UAAU,IAAI,MAAM,KAAK,CAAE;AAC/B,SAAM,KAAK,MAAM,MAAM;aACd,MAAM,QAAQ,CACvB,OAAM,MAAM,KAAK;;;;;;;;AAUvB,SAAgB,iBAAiB,YAA0C;AACzE,KAAI,WAAW,WAAW,EAAG,QAAO;CACpC,MAAM,QAAkB,EAAE;AAC1B,MAAK,MAAM,KAAK,YAAY;EAC1B,MAAM,MAAM,EAAE,aAAa,UAAU,UAAU;AAC/C,QAAM,KAAK,MAAM,IAAI,IAAI,EAAE,KAAK,GAAG,EAAE,KAAK,IAAI,EAAE,SAAS;AACzD,QAAM,KAAK,OAAO,EAAE,UAAU;AAC9B,MAAI,EAAE,WAAY,OAAM,KAAK,UAAU,EAAE,aAAa;AACtD,QAAM,KAAK,GAAG;;CAEhB,MAAM,SAAS,WAAW,QAAQ,MAAM,EAAE,aAAa,QAAQ,CAAC;CAChE,MAAM,WAAW,WAAW,SAAS;AACrC,OAAM,KAAK,GAAG,WAAW,OAAO,iBAAiB,OAAO,UAAU,SAAS,OAAO;AAClF,QAAO,MAAM,KAAK,KAAK"}
1
+ {"version":3,"file":"index.mjs","names":["defaultRules"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Programmatic entry point for `@forinda/kickjs-lint`.\n *\n * Walks a directory tree, applies every enabled rule from\n * {@link ./rules} to each file that matches the token-bearing filename\n * heuristic, and returns the aggregated violations.\n *\n * The CLI binary (`bin.mjs`) wraps this with a process-exit translation\n * layer; downstream tools (devtools, editor extensions) call this\n * directly.\n *\n * @module @forinda/kickjs-lint\n */\n\nimport { readdir, readFile } from 'node:fs/promises'\nimport { join, relative } from 'node:path'\nimport { rules as defaultRules, type Rule, type Violation } from './rules'\n\nexport type { LintContext, Rule, Violation } from './rules'\nexport { diTokenSymbol, tokenKickPrefix, tokenReservedPrefix, rules as defaultRules } from './rules'\n\n/**\n * Filenames that historically declare DI tokens. Lint runs only on\n * these to keep false positives out of unrelated files (e.g. a class\n * named `Symbol` in a math library).\n *\n * `database.ts`, `interfaces.ts`, `client.ts` were added after a\n * regression where `TENANT_DB = Symbol(...)` slipped past the rule by\n * living in `database.ts` rather than `tokens.ts` / `constants.ts`.\n */\nexport const TOKEN_FILE_NAMES = new Set([\n 'types.ts',\n 'tokens.ts',\n 'constants.ts',\n 'service.ts',\n 'adapter.ts',\n 'database.ts',\n 'interfaces.ts',\n 'client.ts',\n])\n\n/** Directories the walker skips wholesale. */\nconst SKIP_DIRS = new Set([\n 'node_modules',\n 'dist',\n '__tests__',\n '.kickjs',\n // Built static assets (e.g. devtools SPA bundle) live under `public/`\n // and ship as-is to npm — no token literals to lint there.\n 'public',\n // VitePress / Vite build outputs that adopters sometimes commit.\n '.vitepress',\n '.turbo',\n '.wireit',\n 'coverage',\n])\n\nexport interface LintOptions {\n /** Root directory to walk. Required. */\n cwd: string\n /**\n * Whether the project being linted is a first-party `@forinda/kickjs-*`\n * package (enables `token-kick-prefix`, disables `token-reserved-prefix`).\n * Defaults to `false` so adopter projects use the friendlier ruleset.\n */\n firstParty?: boolean\n /**\n * Only lint files inside these subdirectories (relative to `cwd`).\n * Defaults to `['packages']` for first-party use; pass `['src']` or\n * `['.']` for adopter projects.\n */\n scope?: readonly string[]\n /** Override the rule set. Defaults to every rule shipped by the package. */\n rules?: readonly Rule[]\n /** Filenames to lint (defaults to {@link TOKEN_FILE_NAMES}). */\n filenames?: ReadonlySet<string>\n}\n\nexport interface LintResult {\n violations: Violation[]\n filesScanned: number\n}\n\n/**\n * Walk `cwd` (constrained to `scope` directories), apply every rule to\n * each token-bearing file, and return the aggregated violations + the\n * number of files actually checked.\n */\nexport async function runLint(opts: LintOptions): Promise<LintResult> {\n const cwd = opts.cwd\n const firstParty = opts.firstParty ?? false\n const scope = opts.scope ?? ['packages']\n const ruleset = opts.rules ?? defaultRules\n const filenames = opts.filenames ?? TOKEN_FILE_NAMES\n\n const violations: Violation[] = []\n let filesScanned = 0\n\n for (const root of scope) {\n const start = join(cwd, root)\n await walk(start, async (file) => {\n const base = file.slice(file.lastIndexOf('/') + 1)\n if (!filenames.has(base)) return\n const source = await readFile(file, 'utf-8')\n const rel = relative(cwd, file)\n filesScanned++\n for (const rule of ruleset) {\n violations.push(...rule.check({ source, file: rel, firstParty }))\n }\n })\n }\n\n return { violations, filesScanned }\n}\n\nasync function walk(dir: string, visit: (file: string) => Promise<void>): Promise<void> {\n let entries\n try {\n entries = await readdir(dir, { withFileTypes: true })\n } catch {\n return\n }\n for (const entry of entries) {\n const full = join(dir, entry.name)\n if (entry.isDirectory()) {\n if (SKIP_DIRS.has(entry.name)) continue\n await walk(full, visit)\n } else if (entry.isFile()) {\n await visit(full)\n }\n }\n}\n\n/**\n * Format a violation list for terminal output. One block per violation,\n * trailing summary line. Returns `''` when there are no violations so\n * callers can branch on truthiness.\n */\nexport function formatViolations(violations: readonly Violation[]): string {\n if (violations.length === 0) return ''\n const lines: string[] = []\n for (const v of violations) {\n const tag = v.severity === 'error' ? 'error' : 'warn'\n lines.push(` [${tag}] ${v.file}:${v.line} ${v.ruleId}`)\n lines.push(` ${v.message}`)\n if (v.suggestion) lines.push(` -> ${v.suggestion}`)\n lines.push('')\n }\n const errors = violations.filter((v) => v.severity === 'error').length\n const warnings = violations.length - errors\n lines.push(`${violations.length} violation(s): ${errors} error, ${warnings} warn`)\n return lines.join('\\n')\n}\n"],"mappings":";;;;;;;;;;qKA8BA,MAAa,iBAAmB,IAAI,IAAI,CACtC,WACA,YACA,eACA,aACA,aACA,cACA,gBACA,YACD,CAAC,CAGI,UAAY,IAAI,IAAI,CACxB,eACA,OACA,YACA,UAGA,SAEA,aACA,SACA,UACA,WACD,CAAC,CAiCF,eAAsB,QAAQ,KAAwC,CACpE,IAAM,IAAM,KAAK,IACX,WAAa,KAAK,YAAc,GAChC,MAAQ,KAAK,OAAS,CAAC,WAAW,CAClC,QAAU,KAAK,OAASA,MACxB,UAAY,KAAK,WAAa,iBAE9B,WAA0B,EAAE,CAC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AAG,WAAW,OAAO,iBAAiB,OAAO,UAAU,SAAS,OAAO,CAC3E,MAAM,KAAK;EAAK"}
package/dist/rules.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-lint v5.1.0
2
+ * @forinda/kickjs-lint v5.2.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,117 +8,7 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- //#region src/rules.ts
12
- const SYMBOL_DECL_REGEX = /\bexport\s+const\s+([A-Z_][A-Z0-9_]*)\s*=\s*Symbol\s*\(/g;
13
- const CREATE_TOKEN_LITERAL_REGEX = /createToken\s*(?:<[^>]*>)?\s*\(\s*['"`]([^'"`]+)['"`]/g;
14
- function lineOf(source, index) {
15
- return source.slice(0, index).split("\n").length;
16
- }
17
- /**
18
- * Forbid `export const X = Symbol('...')` declarations in token-bearing
19
- * files. The §22 v4 migration replaced first-party DI tokens with
20
- * `createToken<T>()`; this rule blocks regression in framework code and
21
- * encourages adopters to follow the same pattern.
22
- *
23
- * Inline-disable: append `// kick-lint-disable di-token-symbol` to the
24
- * declaration line.
25
- */
26
- const diTokenSymbol = {
27
- id: "di-token-symbol",
28
- description: "DI tokens must use createToken<T>() instead of Symbol(...)",
29
- defaultSeverity: "error",
30
- check({ source, file }) {
31
- const out = [];
32
- const lines = source.split("\n");
33
- for (let i = 0; i < lines.length; i++) {
34
- const line = lines[i];
35
- if (line.includes("// kick-lint-disable di-token-symbol")) continue;
36
- SYMBOL_DECL_REGEX.lastIndex = 0;
37
- const match = SYMBOL_DECL_REGEX.exec(line);
38
- if (!match) continue;
39
- out.push({
40
- ruleId: diTokenSymbol.id,
41
- severity: diTokenSymbol.defaultSeverity,
42
- file,
43
- line: i + 1,
44
- message: `\`${match[1]} = Symbol(...)\` declares a DI token via Symbol`,
45
- suggestion: `Use \`createToken<T>('kick/<area>/<key>')\` -- see architecture.md section 22`
46
- });
47
- }
48
- return out;
49
- }
50
- };
51
- /**
52
- * For first-party files, every `createToken('literal')` literal must
53
- * start with the reserved `kick/` prefix. Third-party adopter code is
54
- * exempt -- they use their own scope (`mycorp/`, `acme/`, etc.).
55
- *
56
- * Allowed back-compat exception: literals starting with `kickjs.` or
57
- * `kickjs/` (the dotted convention pre-dates section 22 and gets
58
- * migrated alongside the symbol-to-string work).
59
- */
60
- const tokenKickPrefix = {
61
- id: "token-kick-prefix",
62
- description: "First-party DI tokens must start with the reserved `kick/` prefix",
63
- defaultSeverity: "error",
64
- check({ source, file, firstParty }) {
65
- if (!firstParty) return [];
66
- const out = [];
67
- CREATE_TOKEN_LITERAL_REGEX.lastIndex = 0;
68
- let match;
69
- while ((match = CREATE_TOKEN_LITERAL_REGEX.exec(source)) !== null) {
70
- const literal = match[1];
71
- if (literal.startsWith("kick/")) continue;
72
- if (literal.startsWith("kickjs.") || literal.startsWith("kickjs/")) continue;
73
- out.push({
74
- ruleId: tokenKickPrefix.id,
75
- severity: tokenKickPrefix.defaultSeverity,
76
- file,
77
- line: lineOf(source, match.index),
78
- message: `\`createToken('${literal}')\` is missing the reserved \`kick/\` prefix`,
79
- suggestion: `Rename to \`'kick/${literal}'\` -- first-party tokens own the \`kick/\` namespace`
80
- });
81
- }
82
- return out;
83
- }
84
- };
85
- /**
86
- * Third-party adopters must NOT squat the reserved `kick/` prefix --
87
- * mirror image of {@link tokenKickPrefix}. Runs only on non-first-party
88
- * code and warns rather than errors so the rule is informative without
89
- * blocking adopter installs.
90
- */
91
- const tokenReservedPrefix = {
92
- id: "token-reserved-prefix",
93
- description: "Third-party tokens must not start with the reserved `kick/` prefix",
94
- defaultSeverity: "warn",
95
- check({ source, file, firstParty }) {
96
- if (firstParty) return [];
97
- const out = [];
98
- CREATE_TOKEN_LITERAL_REGEX.lastIndex = 0;
99
- let match;
100
- while ((match = CREATE_TOKEN_LITERAL_REGEX.exec(source)) !== null) {
101
- const literal = match[1];
102
- if (!literal.startsWith("kick/")) continue;
103
- out.push({
104
- ruleId: tokenReservedPrefix.id,
105
- severity: tokenReservedPrefix.defaultSeverity,
106
- file,
107
- line: lineOf(source, match.index),
108
- message: `\`createToken('${literal}')\` squats the reserved \`kick/\` prefix`,
109
- suggestion: `Pick an org-scoped prefix instead (e.g. \`'mycorp/...'\`)`
110
- });
111
- }
112
- return out;
113
- }
114
- };
115
- /** All rules shipped by this package, in run order. */
116
- const rules = [
117
- diTokenSymbol,
118
- tokenKickPrefix,
119
- tokenReservedPrefix
120
- ];
121
- //#endregion
122
- export { diTokenSymbol, rules, tokenKickPrefix, tokenReservedPrefix };
123
-
11
+ const SYMBOL_DECL_REGEX=/\bexport\s+const\s+([A-Z_][A-Z0-9_]*)\s*=\s*Symbol\s*\(/g,CREATE_TOKEN_LITERAL_REGEX=/createToken\s*(?:<[^>]*>)?\s*\(\s*['"`]([^'"`]+)['"`]/g;function lineOf(source,index){return source.slice(0,index).split(`
12
+ `).length}const diTokenSymbol={id:`di-token-symbol`,description:`DI tokens must use createToken<T>() instead of Symbol(...)`,defaultSeverity:`error`,check({source,file}){let out=[],lines=source.split(`
13
+ `);for(let i=0;i<lines.length;i++){let line=lines[i];if(line.includes(`// kick-lint-disable di-token-symbol`))continue;SYMBOL_DECL_REGEX.lastIndex=0;let match=SYMBOL_DECL_REGEX.exec(line);match&&out.push({ruleId:diTokenSymbol.id,severity:diTokenSymbol.defaultSeverity,file,line:i+1,message:`\`${match[1]} = Symbol(...)\` declares a DI token via Symbol`,suggestion:"Use `createToken<T>('kick/<area>/<key>')` -- see architecture.md section 22"})}return out}},tokenKickPrefix={id:`token-kick-prefix`,description:"First-party DI tokens must start with the reserved `kick/` prefix",defaultSeverity:`error`,check({source,file,firstParty}){if(!firstParty)return[];let out=[];CREATE_TOKEN_LITERAL_REGEX.lastIndex=0;let match;for(;(match=CREATE_TOKEN_LITERAL_REGEX.exec(source))!==null;){let literal=match[1];literal.startsWith(`kick/`)||literal.startsWith(`kickjs.`)||literal.startsWith(`kickjs/`)||out.push({ruleId:tokenKickPrefix.id,severity:tokenKickPrefix.defaultSeverity,file,line:lineOf(source,match.index),message:`\`createToken('${literal}')\` is missing the reserved \`kick/\` prefix`,suggestion:`Rename to \`'kick/${literal}'\` -- first-party tokens own the \`kick/\` namespace`})}return out}},tokenReservedPrefix={id:`token-reserved-prefix`,description:"Third-party tokens must not start with the reserved `kick/` prefix",defaultSeverity:`warn`,check({source,file,firstParty}){if(firstParty)return[];let out=[];CREATE_TOKEN_LITERAL_REGEX.lastIndex=0;let match;for(;(match=CREATE_TOKEN_LITERAL_REGEX.exec(source))!==null;){let literal=match[1];literal.startsWith(`kick/`)&&out.push({ruleId:tokenReservedPrefix.id,severity:tokenReservedPrefix.defaultSeverity,file,line:lineOf(source,match.index),message:`\`createToken('${literal}')\` squats the reserved \`kick/\` prefix`,suggestion:"Pick an org-scoped prefix instead (e.g. `'mycorp/...'`)"})}return out}},rules=[diTokenSymbol,tokenKickPrefix,tokenReservedPrefix];export{diTokenSymbol,rules,tokenKickPrefix,tokenReservedPrefix};
124
14
  //# sourceMappingURL=rules.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"rules.mjs","names":[],"sources":["../src/rules.ts"],"sourcesContent":["/**\n * Pure rule definitions. Each rule takes a source file's content + path\n * and returns the violations it found. Stateless and synchronous so the\n * runner can compose them freely (CLI, devtools, editor extension).\n */\n\nexport interface Violation {\n ruleId: string\n severity: 'error' | 'warn'\n file: string\n /** 1-based line number of the offending construct. */\n line: number\n message: string\n suggestion?: string\n}\n\nexport interface LintContext {\n source: string\n file: string\n /**\n * Whether the file lives inside `packages/<name>/src/` of the\n * `@forinda/kickjs-*` monorepo. First-party files are held to the\n * stricter `kick/` prefix; third-party adopter code is exempt.\n */\n firstParty: boolean\n}\n\nexport interface Rule {\n id: string\n description: string\n defaultSeverity: 'error' | 'warn'\n check(ctx: LintContext): Violation[]\n}\n\nconst SYMBOL_DECL_REGEX = /\\bexport\\s+const\\s+([A-Z_][A-Z0-9_]*)\\s*=\\s*Symbol\\s*\\(/g\nconst CREATE_TOKEN_LITERAL_REGEX = /createToken\\s*(?:<[^>]*>)?\\s*\\(\\s*['\"`]([^'\"`]+)['\"`]/g\n\nfunction lineOf(source: string, index: number): number {\n return source.slice(0, index).split('\\n').length\n}\n\n/**\n * Forbid `export const X = Symbol('...')` declarations in token-bearing\n * files. The §22 v4 migration replaced first-party DI tokens with\n * `createToken<T>()`; this rule blocks regression in framework code and\n * encourages adopters to follow the same pattern.\n *\n * Inline-disable: append `// kick-lint-disable di-token-symbol` to the\n * declaration line.\n */\nexport const diTokenSymbol: Rule = {\n id: 'di-token-symbol',\n description: 'DI tokens must use createToken<T>() instead of Symbol(...)',\n defaultSeverity: 'error',\n check({ source, file }) {\n const out: Violation[] = []\n const lines = source.split('\\n')\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]\n if (line.includes('// kick-lint-disable di-token-symbol')) continue\n SYMBOL_DECL_REGEX.lastIndex = 0\n const match = SYMBOL_DECL_REGEX.exec(line)\n if (!match) continue\n out.push({\n ruleId: diTokenSymbol.id,\n severity: diTokenSymbol.defaultSeverity,\n file,\n line: i + 1,\n message: `\\`${match[1]} = Symbol(...)\\` declares a DI token via Symbol`,\n suggestion: `Use \\`createToken<T>('kick/<area>/<key>')\\` -- see architecture.md section 22`,\n })\n }\n return out\n },\n}\n\n/**\n * For first-party files, every `createToken('literal')` literal must\n * start with the reserved `kick/` prefix. Third-party adopter code is\n * exempt -- they use their own scope (`mycorp/`, `acme/`, etc.).\n *\n * Allowed back-compat exception: literals starting with `kickjs.` or\n * `kickjs/` (the dotted convention pre-dates section 22 and gets\n * migrated alongside the symbol-to-string work).\n */\nexport const tokenKickPrefix: Rule = {\n id: 'token-kick-prefix',\n description: 'First-party DI tokens must start with the reserved `kick/` prefix',\n defaultSeverity: 'error',\n check({ source, file, firstParty }) {\n if (!firstParty) return []\n const out: Violation[] = []\n CREATE_TOKEN_LITERAL_REGEX.lastIndex = 0\n let match: RegExpExecArray | null\n while ((match = CREATE_TOKEN_LITERAL_REGEX.exec(source)) !== null) {\n const literal = match[1]\n if (literal.startsWith('kick/')) continue\n if (literal.startsWith('kickjs.') || literal.startsWith('kickjs/')) continue\n out.push({\n ruleId: tokenKickPrefix.id,\n severity: tokenKickPrefix.defaultSeverity,\n file,\n line: lineOf(source, match.index),\n message: `\\`createToken('${literal}')\\` is missing the reserved \\`kick/\\` prefix`,\n suggestion: `Rename to \\`'kick/${literal}'\\` -- first-party tokens own the \\`kick/\\` namespace`,\n })\n }\n return out\n },\n}\n\n/**\n * Third-party adopters must NOT squat the reserved `kick/` prefix --\n * mirror image of {@link tokenKickPrefix}. Runs only on non-first-party\n * code and warns rather than errors so the rule is informative without\n * blocking adopter installs.\n */\nexport const tokenReservedPrefix: Rule = {\n id: 'token-reserved-prefix',\n description: 'Third-party tokens must not start with the reserved `kick/` prefix',\n defaultSeverity: 'warn',\n check({ source, file, firstParty }) {\n if (firstParty) return []\n const out: Violation[] = []\n CREATE_TOKEN_LITERAL_REGEX.lastIndex = 0\n let match: RegExpExecArray | null\n while ((match = CREATE_TOKEN_LITERAL_REGEX.exec(source)) !== null) {\n const literal = match[1]\n if (!literal.startsWith('kick/')) continue\n out.push({\n ruleId: tokenReservedPrefix.id,\n severity: tokenReservedPrefix.defaultSeverity,\n file,\n line: lineOf(source, match.index),\n message: `\\`createToken('${literal}')\\` squats the reserved \\`kick/\\` prefix`,\n suggestion: `Pick an org-scoped prefix instead (e.g. \\`'mycorp/...'\\`)`,\n })\n }\n return out\n },\n}\n\n/** All rules shipped by this package, in run order. */\nexport const rules: readonly Rule[] = [diTokenSymbol, tokenKickPrefix, tokenReservedPrefix]\n"],"mappings":";;;;;;;;;;;AAkCA,MAAM,oBAAoB;AAC1B,MAAM,6BAA6B;AAEnC,SAAS,OAAO,QAAgB,OAAuB;AACrD,QAAO,OAAO,MAAM,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC;;;;;;;;;;;AAY5C,MAAa,gBAAsB;CACjC,IAAI;CACJ,aAAa;CACb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UAAQ,QAAQ,2BAA2B,KAAK,OAAO,MAAM,MAAM;GACjE,MAAM,UAAU,MAAM;AACtB,OAAI,CAAC,QAAQ,WAAW,QAAQ,CAAE;AAClC,OAAI,KAAK;IACP,QAAQ,oBAAoB;IAC5B,UAAU,oBAAoB;IAC9B;IACA,MAAM,OAAO,QAAQ,MAAM,MAAM;IACjC,SAAS,kBAAkB,QAAQ;IACnC,YAAY;IACb,CAAC;;AAEJ,SAAO;;CAEV;;AAGD,MAAa,QAAyB;CAAC;CAAe;CAAiB;CAAoB"}
1
+ {"version":3,"file":"rules.mjs","names":[],"sources":["../src/rules.ts"],"sourcesContent":["/**\n * Pure rule definitions. Each rule takes a source file's content + path\n * and returns the violations it found. Stateless and synchronous so the\n * runner can compose them freely (CLI, devtools, editor extension).\n */\n\nexport interface Violation {\n ruleId: string\n severity: 'error' | 'warn'\n file: string\n /** 1-based line number of the offending construct. */\n line: number\n message: string\n suggestion?: string\n}\n\nexport interface LintContext {\n source: string\n file: string\n /**\n * Whether the file lives inside `packages/<name>/src/` of the\n * `@forinda/kickjs-*` monorepo. First-party files are held to the\n * stricter `kick/` prefix; third-party adopter code is exempt.\n */\n firstParty: boolean\n}\n\nexport interface Rule {\n id: string\n description: string\n defaultSeverity: 'error' | 'warn'\n check(ctx: LintContext): Violation[]\n}\n\nconst SYMBOL_DECL_REGEX = /\\bexport\\s+const\\s+([A-Z_][A-Z0-9_]*)\\s*=\\s*Symbol\\s*\\(/g\nconst CREATE_TOKEN_LITERAL_REGEX = /createToken\\s*(?:<[^>]*>)?\\s*\\(\\s*['\"`]([^'\"`]+)['\"`]/g\n\nfunction lineOf(source: string, index: number): number {\n return source.slice(0, index).split('\\n').length\n}\n\n/**\n * Forbid `export const X = Symbol('...')` declarations in token-bearing\n * files. The §22 v4 migration replaced first-party DI tokens with\n * `createToken<T>()`; this rule blocks regression in framework code and\n * encourages adopters to follow the same pattern.\n *\n * Inline-disable: append `// kick-lint-disable di-token-symbol` to the\n * declaration line.\n */\nexport const diTokenSymbol: Rule = {\n id: 'di-token-symbol',\n description: 'DI tokens must use createToken<T>() instead of Symbol(...)',\n defaultSeverity: 'error',\n check({ source, file }) {\n const out: Violation[] = []\n const lines = source.split('\\n')\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]\n if (line.includes('// kick-lint-disable di-token-symbol')) continue\n SYMBOL_DECL_REGEX.lastIndex = 0\n const match = SYMBOL_DECL_REGEX.exec(line)\n if (!match) continue\n out.push({\n ruleId: diTokenSymbol.id,\n severity: diTokenSymbol.defaultSeverity,\n file,\n line: i + 1,\n message: `\\`${match[1]} = Symbol(...)\\` declares a DI token via Symbol`,\n suggestion: `Use \\`createToken<T>('kick/<area>/<key>')\\` -- see architecture.md section 22`,\n })\n }\n return out\n },\n}\n\n/**\n * For first-party files, every `createToken('literal')` literal must\n * start with the reserved `kick/` prefix. Third-party adopter code is\n * exempt -- they use their own scope (`mycorp/`, `acme/`, etc.).\n *\n * Allowed back-compat exception: literals starting with `kickjs.` or\n * `kickjs/` (the dotted convention pre-dates section 22 and gets\n * migrated alongside the symbol-to-string work).\n */\nexport const tokenKickPrefix: Rule = {\n id: 'token-kick-prefix',\n description: 'First-party DI tokens must start with the reserved `kick/` prefix',\n defaultSeverity: 'error',\n check({ source, file, firstParty }) {\n if (!firstParty) return []\n const out: Violation[] = []\n CREATE_TOKEN_LITERAL_REGEX.lastIndex = 0\n let match: RegExpExecArray | null\n while ((match = CREATE_TOKEN_LITERAL_REGEX.exec(source)) !== null) {\n const literal = match[1]\n if (literal.startsWith('kick/')) continue\n if (literal.startsWith('kickjs.') || literal.startsWith('kickjs/')) continue\n out.push({\n ruleId: tokenKickPrefix.id,\n severity: tokenKickPrefix.defaultSeverity,\n file,\n line: lineOf(source, match.index),\n message: `\\`createToken('${literal}')\\` is missing the reserved \\`kick/\\` prefix`,\n suggestion: `Rename to \\`'kick/${literal}'\\` -- first-party tokens own the \\`kick/\\` namespace`,\n })\n }\n return out\n },\n}\n\n/**\n * Third-party adopters must NOT squat the reserved `kick/` prefix --\n * mirror image of {@link tokenKickPrefix}. Runs only on non-first-party\n * code and warns rather than errors so the rule is informative without\n * blocking adopter installs.\n */\nexport const tokenReservedPrefix: Rule = {\n id: 'token-reserved-prefix',\n description: 'Third-party tokens must not start with the reserved `kick/` prefix',\n defaultSeverity: 'warn',\n check({ source, file, firstParty }) {\n if (firstParty) return []\n const out: Violation[] = []\n CREATE_TOKEN_LITERAL_REGEX.lastIndex = 0\n let match: RegExpExecArray | null\n while ((match = CREATE_TOKEN_LITERAL_REGEX.exec(source)) !== null) {\n const literal = match[1]\n if (!literal.startsWith('kick/')) continue\n out.push({\n ruleId: tokenReservedPrefix.id,\n severity: tokenReservedPrefix.defaultSeverity,\n file,\n line: lineOf(source, match.index),\n message: `\\`createToken('${literal}')\\` squats the reserved \\`kick/\\` prefix`,\n suggestion: `Pick an org-scoped prefix instead (e.g. \\`'mycorp/...'\\`)`,\n })\n }\n return out\n },\n}\n\n/** All rules shipped by this package, in run order. */\nexport const rules: readonly Rule[] = [diTokenSymbol, tokenKickPrefix, tokenReservedPrefix]\n"],"mappings":";;;;;;;;;;AAkCA,MAAM,kBAAoB,2DACpB,2BAA6B,yDAEnC,SAAS,OAAO,OAAgB,MAAuB,CACrD,OAAO,OAAO,MAAM,EAAG,MAAM,CAAC,MAAM;EAAK,CAAC,OAY5C,MAAa,cAAsB,CACjC,GAAI,kBACJ,YAAa,6DACb,gBAAiB,QACjB,MAAM,CAAE,OAAQ,MAAQ,CACtB,IAAM,IAAmB,EAAE,CACrB,MAAQ,OAAO,MAAM;EAAK,CAChC,IAAK,IAAI,EAAI,EAAG,EAAI,MAAM,OAAQ,IAAK,CACrC,IAAM,KAAO,MAAM,GACnB,GAAI,KAAK,SAAS,uCAAuC,CAAE,SAC3D,kBAAkB,UAAY,EAC9B,IAAM,MAAQ,kBAAkB,KAAK,KAAK,CACrC,OACL,IAAI,KAAK,CACP,OAAQ,cAAc,GACtB,SAAU,cAAc,gBACxB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.1",
4
4
  "description": "Lint rules for KickJS — DI token convention, plugin/adapter naming, and other framework conventions",
5
5
  "keywords": [
6
6
  "kickjs",