routie dev init since i didn't adhere to any proper guidance up until now

This commit is contained in:
2026-04-29 22:27:29 -06:00
commit e1dabb71e2
15301 changed files with 3562618 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
//#region \0rolldown/runtime.js
var __defProp = Object.defineProperty;
var __exportAll = (all, no_symbols) => {
let target = {};
for (var name in all) {
__defProp(target, name, {
get: all[name],
enumerable: true
});
}
if (!no_symbols) {
__defProp(target, Symbol.toStringTag, { value: "Module" });
}
return target;
};
//#endregion
export { __exportAll as t };
@@ -0,0 +1 @@
export { };
@@ -0,0 +1,10 @@
import { runAsWorker } from "synckit";
import { ESLint } from "eslint";
//#region lib/utils/get-auto-jsonc-rules-config/get-auto-jsonc-rules-config-worker.ts
runAsWorker(async (cwd, fileName) => {
return { rules: (await new ESLint({ cwd }).calculateConfigForFile(fileName)).rules };
});
//#endregion
export { };
+62
View File
@@ -0,0 +1,62 @@
import { a as JSONCSourceCode, i as JSONCComment, n as JSONCLanguage, o as JSONCToken, r as JSONCLanguageOptions, t as RuleModule } from "./types-DS229oMx.mjs";
import { Linter } from "eslint";
//#region lib/meta.d.ts
declare namespace meta_d_exports {
export { name, version };
}
declare const name: "eslint-plugin-jsonc";
declare const version: "3.1.2";
//#endregion
//#region lib/index.d.ts
declare const configs: {
base: Linter.Config[];
"recommended-with-json": Linter.Config[];
"recommended-with-jsonc": Linter.Config[];
"recommended-with-json5": Linter.Config[];
prettier: Linter.Config[];
all: Linter.Config[];
"flat/base": Linter.Config[];
"flat/recommended-with-json": Linter.Config[];
"flat/recommended-with-jsonc": Linter.Config[];
"flat/recommended-with-json5": Linter.Config[];
"flat/prettier": Linter.Config[];
"flat/all": Linter.Config[];
};
declare const rules: {
[key: string]: RuleModule<unknown[]>;
};
declare const languages: {
json: JSONCLanguage;
jsonc: JSONCLanguage;
json5: JSONCLanguage;
x: JSONCLanguage;
};
declare const _default: {
meta: typeof meta_d_exports;
configs: {
base: Linter.Config[];
"recommended-with-json": Linter.Config[];
"recommended-with-jsonc": Linter.Config[];
"recommended-with-json5": Linter.Config[];
prettier: Linter.Config[];
all: Linter.Config[];
"flat/base": Linter.Config[];
"flat/recommended-with-json": Linter.Config[];
"flat/recommended-with-jsonc": Linter.Config[];
"flat/recommended-with-json5": Linter.Config[];
"flat/prettier": Linter.Config[];
"flat/all": Linter.Config[];
};
rules: {
[key: string]: RuleModule<unknown[]>;
};
languages: {
json: JSONCLanguage;
jsonc: JSONCLanguage;
json5: JSONCLanguage;
x: JSONCLanguage;
};
};
//#endregion
export { type JSONCComment, type JSONCLanguageOptions, type JSONCSourceCode, type JSONCToken, configs, _default as default, languages, meta_d_exports as meta, rules };
+587
View File
@@ -0,0 +1,587 @@
import { t as __exportAll } from "./chunk-DQk6qfdC.mjs";
import "./no-parsing-error-B9_Ixkn3.mjs";
import { getRules } from "./rules.mjs";
import { VisitorKeys, parseForESLint, traverseNodes } from "jsonc-eslint-parser";
import { CallMethodStep, ConfigCommentParser, Directive, TextSourceCodeBase, VisitNodeStep } from "@eslint/plugin-kit";
import { TokenStore } from "@ota-meshi/ast-token-store";
//#region lib/configs/flat/base.ts
var base_default = [{ plugins: { get jsonc() {
return lib_default;
} } }, {
files: [
"*.json",
"**/*.json",
"*.json5",
"**/*.json5",
"*.jsonc",
"**/*.jsonc"
],
language: "jsonc/x",
rules: {
strict: "off",
"no-unused-expressions": "off",
"no-unused-vars": "off"
}
}];
//#endregion
//#region lib/configs/flat/recommended-with-json.ts
var recommended_with_json_default = [...base_default, { rules: {
"jsonc/comma-dangle": "error",
"jsonc/no-bigint-literals": "error",
"jsonc/no-binary-expression": "error",
"jsonc/no-binary-numeric-literals": "error",
"jsonc/no-comments": "error",
"jsonc/no-dupe-keys": "error",
"jsonc/no-escape-sequence-in-identifier": "error",
"jsonc/no-floating-decimal": "error",
"jsonc/no-hexadecimal-numeric-literals": "error",
"jsonc/no-infinity": "error",
"jsonc/no-irregular-whitespace": "error",
"jsonc/no-multi-str": "error",
"jsonc/no-nan": "error",
"jsonc/no-number-props": "error",
"jsonc/no-numeric-separators": "error",
"jsonc/no-octal-numeric-literals": "error",
"jsonc/no-octal": "error",
"jsonc/no-parenthesized": "error",
"jsonc/no-plus-sign": "error",
"jsonc/no-regexp-literals": "error",
"jsonc/no-sparse-arrays": "error",
"jsonc/no-template-literals": "error",
"jsonc/no-undefined-value": "error",
"jsonc/no-unicode-codepoint-escapes": "error",
"jsonc/no-useless-escape": "error",
"jsonc/quote-props": "error",
"jsonc/quotes": "error",
"jsonc/space-unary-ops": "error",
"jsonc/valid-json-number": "error",
"jsonc/vue-custom-block/no-parsing-error": "error"
} }];
//#endregion
//#region lib/configs/flat/recommended-with-jsonc.ts
var recommended_with_jsonc_default = [...base_default, { rules: {
"jsonc/no-bigint-literals": "error",
"jsonc/no-binary-expression": "error",
"jsonc/no-binary-numeric-literals": "error",
"jsonc/no-dupe-keys": "error",
"jsonc/no-escape-sequence-in-identifier": "error",
"jsonc/no-floating-decimal": "error",
"jsonc/no-hexadecimal-numeric-literals": "error",
"jsonc/no-infinity": "error",
"jsonc/no-irregular-whitespace": "error",
"jsonc/no-multi-str": "error",
"jsonc/no-nan": "error",
"jsonc/no-number-props": "error",
"jsonc/no-numeric-separators": "error",
"jsonc/no-octal-numeric-literals": "error",
"jsonc/no-octal": "error",
"jsonc/no-parenthesized": "error",
"jsonc/no-plus-sign": "error",
"jsonc/no-regexp-literals": "error",
"jsonc/no-sparse-arrays": "error",
"jsonc/no-template-literals": "error",
"jsonc/no-undefined-value": "error",
"jsonc/no-unicode-codepoint-escapes": "error",
"jsonc/no-useless-escape": "error",
"jsonc/quote-props": "error",
"jsonc/quotes": "error",
"jsonc/space-unary-ops": "error",
"jsonc/valid-json-number": "error",
"jsonc/vue-custom-block/no-parsing-error": "error"
} }];
//#endregion
//#region lib/configs/flat/recommended-with-json5.ts
var recommended_with_json5_default = [...base_default, { rules: {
"jsonc/no-bigint-literals": "error",
"jsonc/no-binary-expression": "error",
"jsonc/no-binary-numeric-literals": "error",
"jsonc/no-dupe-keys": "error",
"jsonc/no-escape-sequence-in-identifier": "error",
"jsonc/no-irregular-whitespace": "error",
"jsonc/no-number-props": "error",
"jsonc/no-numeric-separators": "error",
"jsonc/no-octal-numeric-literals": "error",
"jsonc/no-octal": "error",
"jsonc/no-parenthesized": "error",
"jsonc/no-regexp-literals": "error",
"jsonc/no-sparse-arrays": "error",
"jsonc/no-template-literals": "error",
"jsonc/no-undefined-value": "error",
"jsonc/no-unicode-codepoint-escapes": "error",
"jsonc/no-useless-escape": "error",
"jsonc/space-unary-ops": "error",
"jsonc/vue-custom-block/no-parsing-error": "error"
} }];
//#endregion
//#region lib/configs/flat/prettier.ts
var prettier_default = [...base_default, { rules: {
"jsonc/array-bracket-newline": "off",
"jsonc/array-bracket-spacing": "off",
"jsonc/array-element-newline": "off",
"jsonc/comma-dangle": "off",
"jsonc/comma-style": "off",
"jsonc/indent": "off",
"jsonc/key-spacing": "off",
"jsonc/no-floating-decimal": "off",
"jsonc/object-curly-newline": "off",
"jsonc/object-curly-spacing": "off",
"jsonc/object-property-newline": "off",
"jsonc/quote-props": "off",
"jsonc/quotes": "off",
"jsonc/space-unary-ops": "off"
} }];
//#endregion
//#region lib/configs/flat/all.ts
const all = {};
for (const rule of getRules()) {
if (rule.meta.docs.ruleId === "jsonc/sort-array-values") continue;
all[rule.meta.docs.ruleId] = "error";
}
const config = [...base_default, { rules: { ...all } }];
//#endregion
//#region lib/meta.ts
var meta_exports = /* @__PURE__ */ __exportAll({
name: () => name,
version: () => version
});
const name = "eslint-plugin-jsonc";
const version = "3.1.2";
//#endregion
//#region lib/language/jsonc-source-code.ts
/**
* @fileoverview The JSONCSourceCode class.
*/
const commentParser = new ConfigCommentParser();
/**
* Pattern to match ESLint inline configuration comments in JSONC.
* Matches: eslint, eslint-disable, eslint-enable, eslint-disable-line, eslint-disable-next-line
*/
const INLINE_CONFIG = /^\s*eslint(?:-enable|-disable(?:(?:-next)?-line)?)?(?:\s|$)/u;
/**
* JSONC Source Code Object
*/
var JSONCSourceCode = class extends TextSourceCodeBase {
hasBOM;
parserServices;
visitorKeys;
tokenStore;
#steps = null;
#cacheTokensAndComments = null;
#inlineConfigComments = null;
/**
* Creates a new instance.
*/
constructor(config) {
super({
ast: config.ast,
text: config.text
});
this.hasBOM = Boolean(config.hasBOM);
this.parserServices = config.parserServices;
this.visitorKeys = config.visitorKeys || VisitorKeys;
this.tokenStore = new TokenStore({
tokens: [...config.ast.tokens, ...config.ast.comments],
isComment: (token) => token.type === "Block" || token.type === "Line"
});
}
traverse() {
if (this.#steps != null) return this.#steps;
const steps = [];
this.#steps = steps;
const root = this.ast;
steps.push(new CallMethodStep({
target: "onCodePathStart",
args: [{}, root]
}));
traverseNodes(root, {
enterNode(n) {
steps.push(new VisitNodeStep({
target: n,
phase: 1,
args: [n]
}));
},
leaveNode(n) {
steps.push(new VisitNodeStep({
target: n,
phase: 2,
args: [n]
}));
}
});
steps.push(new CallMethodStep({
target: "onCodePathEnd",
args: [{}, root]
}));
return steps;
}
/**
* Gets all tokens and comments.
*/
get tokensAndComments() {
return this.#cacheTokensAndComments ??= [...this.ast.tokens, ...this.ast.comments].sort((a, b) => a.range[0] - b.range[0]);
}
getLines() {
return this.lines;
}
getAllComments() {
return this.tokenStore.getAllComments();
}
/**
* Returns an array of all inline configuration nodes found in the source code.
* This includes eslint-disable, eslint-enable, eslint-disable-line,
* eslint-disable-next-line, and eslint (for inline config) comments.
*/
getInlineConfigNodes() {
if (!this.#inlineConfigComments) this.#inlineConfigComments = this.ast.comments.filter((comment) => INLINE_CONFIG.test(comment.value));
return this.#inlineConfigComments;
}
/**
* Returns directives that enable or disable rules along with any problems
* encountered while parsing the directives.
*/
getDisableDirectives() {
const problems = [];
const directives = [];
this.getInlineConfigNodes().forEach((comment) => {
const directive = commentParser.parseDirective(comment.value);
if (!directive) return;
const { label, value, justification } = directive;
if (label === "eslint-disable-line" && comment.loc.start.line !== comment.loc.end.line) {
const message = `${label} comment should not span multiple lines.`;
problems.push({
ruleId: null,
message,
loc: comment.loc
});
return;
}
switch (label) {
case "eslint-disable":
case "eslint-enable":
case "eslint-disable-next-line":
case "eslint-disable-line": {
const directiveType = label.slice(7);
directives.push(new Directive({
type: directiveType,
node: comment,
value,
justification
}));
break;
}
}
});
return {
problems,
directives
};
}
/**
* Returns inline rule configurations along with any problems
* encountered while parsing the configurations.
*/
applyInlineConfig() {
const problems = [];
const configs = [];
this.getInlineConfigNodes().forEach((comment) => {
const directive = commentParser.parseDirective(comment.value);
if (!directive) return;
const { label, value } = directive;
if (label === "eslint") {
const parseResult = commentParser.parseJSONLikeConfig(value);
if (parseResult.ok) configs.push({
config: { rules: parseResult.config },
loc: comment.loc
});
else problems.push({
ruleId: null,
message: parseResult.error.message,
loc: comment.loc
});
}
});
return {
configs,
problems
};
}
/**
* Gets the source text for the given node or the entire source if no node is provided.
*/
getText(node, beforeCount, afterCount) {
if (!node) return this.text;
const range = node.range;
const start = range[0] - (beforeCount ?? 0);
const end = range[1] + (afterCount ?? 0);
return this.text.slice(Math.max(0, start), Math.min(this.text.length, end));
}
getNodeByRangeIndex(index) {
let node = find([this.ast]);
if (!node) return null;
while (true) {
const child = find(this._getChildren(node));
if (!child) return node;
node = child;
}
/**
* Finds a node that contains the given index.
*/
function find(nodes) {
for (const node of nodes) if (node.range[0] <= index && index < node.range[1]) return node;
return null;
}
}
getFirstToken(node, options) {
return this.tokenStore.getFirstToken(node, options);
}
getFirstTokens(node, options) {
return this.tokenStore.getFirstTokens(node, options);
}
getLastToken(node, options) {
return this.tokenStore.getLastToken(node, options);
}
getLastTokens(node, options) {
return this.tokenStore.getLastTokens(node, options);
}
getTokenBefore(node, options) {
return this.tokenStore.getTokenBefore(node, options);
}
getTokensBefore(node, options) {
return this.tokenStore.getTokensBefore(node, options);
}
getTokenAfter(node, options) {
return this.tokenStore.getTokenAfter(node, options);
}
getTokensAfter(node, options) {
return this.tokenStore.getTokensAfter(node, options);
}
getFirstTokenBetween(left, right, options) {
return this.tokenStore.getFirstTokenBetween(left, right, options);
}
getFirstTokensBetween(left, right, options) {
return this.tokenStore.getFirstTokensBetween(left, right, options);
}
getLastTokenBetween(left, right, options) {
return this.tokenStore.getLastTokenBetween(left, right, options);
}
getLastTokensBetween(left, right, options) {
return this.tokenStore.getLastTokensBetween(left, right, options);
}
getTokens(node, options) {
return this.tokenStore.getTokens(node, options);
}
getTokensBetween(left, right, options) {
return this.tokenStore.getTokensBetween(left, right, options);
}
getCommentsInside(nodeOrToken) {
return this.tokenStore.getCommentsInside(nodeOrToken);
}
getCommentsBefore(nodeOrToken) {
return this.tokenStore.getCommentsBefore(nodeOrToken);
}
getCommentsAfter(nodeOrToken) {
return this.tokenStore.getCommentsAfter(nodeOrToken);
}
commentsExistBetween(first, second) {
return this.tokenStore.commentsExistBetween(first, second);
}
isSpaceBetween(first, second) {
const [left, right] = first.range[1] <= second.range[0] ? [first, second] : [second, first];
return this.tokenStore.isSpaceBetween(left, right);
}
/**
* Compatibility for ESLint's SourceCode API
* @deprecated JSONC does not have scopes
*/
getScope(node) {
if (node?.type !== "Program") return null;
return createFakeGlobalScope(this.ast);
}
/**
* Compatibility for ESLint's SourceCode API
* @deprecated JSONC does not have scopes
*/
get scopeManager() {
return {
scopes: [],
globalScope: createFakeGlobalScope(this.ast),
acquire: (node) => {
if (node.type === "Program") return createFakeGlobalScope(this.ast);
return null;
},
getDeclaredVariables: () => [],
addGlobals: () => {}
};
}
/**
* Compatibility for ESLint's SourceCode API
* @deprecated
*/
isSpaceBetweenTokens(first, second) {
return this.isSpaceBetween(first, second);
}
_getChildren(node) {
const keys = this.visitorKeys[node.type] || [];
const children = [];
for (const key of keys) {
const value = node[key];
if (Array.isArray(value)) {
for (const element of value) if (isNode(element)) children.push(element);
} else if (isNode(value)) children.push(value);
}
return children;
}
};
/**
* Determines whether the given value is a JSONC AST node.
*/
function isNode(value) {
return typeof value === "object" && value !== null && typeof value.type === "string" && Array.isArray(value.range) && Boolean(value.loc) && typeof value.loc === "object";
}
/**
* Creates a fake global scope for JSONC files.
* @deprecated JSONC does not have scopes
*/
function createFakeGlobalScope(node) {
const fakeGlobalScope = {
type: "global",
block: node,
set: /* @__PURE__ */ new Map(),
through: [],
childScopes: [],
variableScope: null,
variables: [],
references: [],
functionExpressionScope: false,
isStrict: false,
upper: null,
implicit: {
variables: [],
set: /* @__PURE__ */ new Map()
}
};
fakeGlobalScope.variableScope = fakeGlobalScope;
return fakeGlobalScope;
}
//#endregion
//#region lib/language/jsonc-language.ts
/**
* The JSONC language implementation for ESLint.
*/
var JSONCLanguage = class {
/**
* The type of file to read.
*/
fileType = "text";
/**
* The line number at which the parser starts counting.
*/
lineStart = 1;
/**
* The column number at which the parser starts counting.
*/
columnStart = 0;
/**
* The name of the key that holds the type of the node.
*/
nodeTypeKey = "type";
_mode;
constructor(options) {
this._mode = options?.mode ?? "EXTENDED";
}
/**
* Validates the language options.
*/
validateLanguageOptions(_languageOptions) {}
normalizeLanguageOptions(languageOptions) {
return {
ecmaVersion: "latest",
...languageOptions,
parserOptions: {
...this._mode !== "EXTENDED" ? { jsonSyntax: this._mode } : {},
...languageOptions.parserOptions
}
};
}
/**
* Parses the given file into an AST.
*/
parse(file, context) {
const text = file.body;
try {
return {
ok: true,
ast: parseForESLint(text, { jsonSyntax: context.languageOptions?.parserOptions?.jsonSyntax ?? (this._mode !== "EXTENDED" ? this._mode : void 0) }).ast
};
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
const parseError = error;
return {
ok: false,
errors: [{
message,
line: parseError.lineNumber ?? 1,
column: parseError.column ?? 1
}]
};
}
}
/**
* Creates a new SourceCode object for the given file and parse result.
*/
createSourceCode(file, parseResult) {
return new JSONCSourceCode({
text: file.body,
ast: parseResult.ast,
hasBOM: file.bom,
parserServices: { isJSON: true },
visitorKeys: VisitorKeys
});
}
};
//#endregion
//#region lib/index.ts
const configs = {
base: base_default,
"recommended-with-json": recommended_with_json_default,
"recommended-with-jsonc": recommended_with_jsonc_default,
"recommended-with-json5": recommended_with_json5_default,
prettier: prettier_default,
all: config,
"flat/base": base_default,
"flat/recommended-with-json": recommended_with_json_default,
"flat/recommended-with-jsonc": recommended_with_jsonc_default,
"flat/recommended-with-json5": recommended_with_json5_default,
"flat/prettier": prettier_default,
"flat/all": config
};
const rules = getRules().reduce((obj, r) => {
obj[r.meta.docs.ruleName] = r;
return obj;
}, {});
const languages = {
json: new JSONCLanguage({ mode: "JSON" }),
jsonc: new JSONCLanguage({ mode: "JSONC" }),
json5: new JSONCLanguage({ mode: "JSON5" }),
x: new JSONCLanguage({ mode: "EXTENDED" })
};
var lib_default = {
meta: meta_exports,
configs,
rules,
languages
};
//#endregion
export { configs, lib_default as default, languages, meta_exports as meta, rules };
File diff suppressed because it is too large Load Diff
+9
View File
@@ -0,0 +1,9 @@
import { t as RuleModule } from "./types-DS229oMx.mjs";
//#region lib/utils/rules.d.ts
/**
*
*/
declare function getRules(): RuleModule[];
//#endregion
export { getRules };
+60
View File
@@ -0,0 +1,60 @@
import { A as no_escape_sequence_in_identifier_default, B as comma_dangle_default, C as no_number_props_default, D as no_infinity_default, E as no_irregular_whitespace_default, F as no_bigint_literals_default, H as array_element_newline_default, I as key_spacing_default, L as key_name_casing_default, M as no_comments_default, N as no_binary_numeric_literals_default, O as no_hexadecimal_numeric_literals_default, P as no_binary_expression_default, R as indent_default, S as no_numeric_separators_default, T as no_multi_str_default, U as array_bracket_spacing_default, V as auto_default, W as array_bracket_newline_default, _ as no_plus_sign_default, a as sort_array_values_default, b as no_octal_numeric_literals_default, c as object_property_newline_default, d as no_useless_escape_default, f as no_unicode_codepoint_escapes_default, g as no_regexp_literals_default, h as no_sparse_arrays_default, i as sort_keys_default, j as no_dupe_keys_default, k as no_floating_decimal_default, l as object_curly_spacing_default, m as no_template_literals_default, n as valid_json_number_default, o as quotes_default, p as no_undefined_value_default, r as space_unary_ops_default, s as quote_props_default, t as no_parsing_error_default, u as object_curly_newline_default, v as no_parenthesized_default, w as no_nan_default, x as no_octal_escape_default, y as no_octal_default, z as comma_style_default } from "./no-parsing-error-B9_Ixkn3.mjs";
//#region lib/utils/rules.ts
let rules = null;
/**
*
*/
function getRules() {
if (rules) return rules;
rules = [
array_bracket_newline_default,
array_bracket_spacing_default,
array_element_newline_default,
auto_default,
comma_dangle_default,
comma_style_default,
indent_default,
key_name_casing_default,
key_spacing_default,
no_bigint_literals_default,
no_binary_expression_default,
no_binary_numeric_literals_default,
no_comments_default,
no_dupe_keys_default,
no_escape_sequence_in_identifier_default,
no_floating_decimal_default,
no_hexadecimal_numeric_literals_default,
no_infinity_default,
no_irregular_whitespace_default,
no_multi_str_default,
no_nan_default,
no_number_props_default,
no_numeric_separators_default,
no_octal_escape_default,
no_octal_numeric_literals_default,
no_octal_default,
no_parenthesized_default,
no_plus_sign_default,
no_regexp_literals_default,
no_sparse_arrays_default,
no_template_literals_default,
no_undefined_value_default,
no_unicode_codepoint_escapes_default,
no_useless_escape_default,
object_curly_newline_default,
object_curly_spacing_default,
object_property_newline_default,
quote_props_default,
quotes_default,
sort_array_values_default,
sort_keys_default,
space_unary_ops_default,
valid_json_number_default,
no_parsing_error_default
];
return rules;
}
//#endregion
export { getRules };
+375
View File
@@ -0,0 +1,375 @@
import { AST, JSONParserOptions, RuleListener } from "jsonc-eslint-parser";
import { IDirective, TextSourceCodeBase, TraversalStep } from "@eslint/plugin-kit";
import { CursorWithCountOptionsWithComment, CursorWithCountOptionsWithFilter, CursorWithCountOptionsWithoutFilter, CursorWithSkipOptionsWithComment, CursorWithSkipOptionsWithFilter, CursorWithSkipOptionsWithoutFilter } from "@ota-meshi/ast-token-store";
import { AST as AST$1, Scope } from "eslint";
import * as core from "@eslint/core";
import { File, FileProblem, Language, NotOkParseResult, OkParseResult, RulesConfig } from "@eslint/core";
import { Comment } from "estree";
//#region lib/language/jsonc-source-code.d.ts
/**
* A comment token with required range and loc.
*/
type JSONCComment = Comment & {
range: [number, number];
loc: AST.SourceLocation;
};
/**
* JSONC-specific syntax element type
*/
type JSONCSyntaxElement = AST.JSONNode | JSONCTokenOrComment;
type JSONCToken = AST$1.Token;
type JSONCTokenOrComment = JSONCToken | JSONCComment;
/**
* JSONC Source Code Object
*/
declare class JSONCSourceCode extends TextSourceCodeBase<{
LangOptions: Record<never, never>;
RootNode: AST.JSONProgram;
SyntaxElementWithLoc: JSONCSyntaxElement;
ConfigNode: JSONCComment;
}> {
#private;
readonly hasBOM: boolean;
readonly parserServices: {
isJSON?: boolean;
parseError?: unknown;
};
readonly visitorKeys: Record<string, string[]>;
private readonly tokenStore;
/**
* Creates a new instance.
*/
constructor(config: {
text: string;
ast: AST.JSONProgram;
hasBOM: boolean;
parserServices: {
isJSON: boolean;
parseError?: unknown;
};
visitorKeys?: Record<string, string[]> | null | undefined;
});
traverse(): Iterable<TraversalStep>;
/**
* Gets all tokens and comments.
*/
get tokensAndComments(): JSONCTokenOrComment[];
getLines(): string[];
getAllComments(): JSONCComment[];
/**
* Returns an array of all inline configuration nodes found in the source code.
* This includes eslint-disable, eslint-enable, eslint-disable-line,
* eslint-disable-next-line, and eslint (for inline config) comments.
*/
getInlineConfigNodes(): JSONCComment[];
/**
* Returns directives that enable or disable rules along with any problems
* encountered while parsing the directives.
*/
getDisableDirectives(): {
directives: IDirective[];
problems: FileProblem[];
};
/**
* Returns inline rule configurations along with any problems
* encountered while parsing the configurations.
*/
applyInlineConfig(): {
configs: {
config: {
rules: RulesConfig;
};
loc: AST.SourceLocation;
}[];
problems: FileProblem[];
};
/**
* Gets the source text for the given node or the entire source if no node is provided.
*/
getText(node?: JSONCSyntaxElement, beforeCount?: number, afterCount?: number): string;
getNodeByRangeIndex(index: number): AST.JSONNode | null;
/**
* Gets the first token of the given node.
*/
getFirstToken(node: JSONCSyntaxElement): JSONCToken;
/**
* Gets the first token of the given node with options.
*/
getFirstToken(node: JSONCSyntaxElement, options: CursorWithSkipOptionsWithoutFilter): JSONCToken | null;
/**
* Gets the first token of the given node with filter options.
*/
getFirstToken<R extends JSONCToken>(node: JSONCSyntaxElement, options: CursorWithSkipOptionsWithFilter<JSONCToken, R>): R | null;
/**
* Gets the first token of the given node with comment options.
*/
getFirstToken<R extends JSONCToken | JSONCComment>(node: JSONCSyntaxElement, options: CursorWithSkipOptionsWithComment<JSONCToken, JSONCComment, R>): R | null;
/**
* Gets the first tokens of the given node.
*/
getFirstTokens(node: JSONCSyntaxElement, options?: CursorWithCountOptionsWithoutFilter): JSONCToken[];
/**
* Gets the first tokens of the given node with filter options.
*/
getFirstTokens<R extends JSONCToken>(node: JSONCSyntaxElement, options: CursorWithCountOptionsWithFilter<JSONCToken, R>): R[];
/**
* Gets the first tokens of the given node with comment options.
*/
getFirstTokens<R extends JSONCToken | JSONCComment>(node: JSONCSyntaxElement, options: CursorWithCountOptionsWithComment<JSONCToken, JSONCComment, R>): R[];
/**
* Gets the last token of the given node.
*/
getLastToken(node: JSONCSyntaxElement): JSONCToken;
/**
* Gets the last token of the given node with options.
*/
getLastToken(node: JSONCSyntaxElement, options: CursorWithSkipOptionsWithoutFilter): JSONCToken | null;
/**
* Gets the last token of the given node with filter options.
*/
getLastToken<R extends JSONCToken>(node: JSONCSyntaxElement, options: CursorWithSkipOptionsWithFilter<JSONCToken, R>): R | null;
/**
* Gets the last token of the given node with comment options.
*/
getLastToken<R extends JSONCToken | JSONCComment>(node: JSONCSyntaxElement, options: CursorWithSkipOptionsWithComment<JSONCToken, JSONCComment, R>): R | null;
/**
* Get the last tokens of the given node.
*/
getLastTokens(node: JSONCSyntaxElement, options?: CursorWithCountOptionsWithoutFilter): JSONCToken[];
/**
* Get the last tokens of the given node with filter options.
*/
getLastTokens<R extends JSONCToken>(node: JSONCSyntaxElement, options: CursorWithCountOptionsWithFilter<JSONCToken, R>): R[];
/**
* Get the last tokens of the given node with comment options.
*/
getLastTokens<R extends JSONCToken | JSONCComment>(node: JSONCSyntaxElement, options: CursorWithCountOptionsWithComment<JSONCToken, JSONCComment, R>): R[];
/**
* Gets the token that precedes a given node or token.
*/
getTokenBefore(node: JSONCSyntaxElement, options?: CursorWithSkipOptionsWithoutFilter): JSONCToken | null;
/**
* Gets the token that precedes a given node or token with filter options.
*/
getTokenBefore<R extends JSONCToken>(node: JSONCSyntaxElement, options: CursorWithSkipOptionsWithFilter<JSONCToken, R>): R | null;
/**
* Gets the token that precedes a given node or token with comment options.
*/
getTokenBefore<R extends JSONCToken | JSONCComment>(node: JSONCSyntaxElement, options: CursorWithSkipOptionsWithComment<JSONCToken, JSONCComment, R>): R | null;
/**
* Gets the `count` tokens that precedes a given node or token.
*/
getTokensBefore(node: JSONCSyntaxElement, options?: CursorWithCountOptionsWithoutFilter): JSONCToken[];
/**
* Gets the `count` tokens that precedes a given node or token with filter options.
*/
getTokensBefore<R extends JSONCToken>(node: JSONCSyntaxElement, options: CursorWithCountOptionsWithFilter<JSONCToken, R>): R[];
/**
* Gets the `count` tokens that precedes a given node or token with comment options.
*/
getTokensBefore<R extends JSONCToken | JSONCComment>(node: JSONCSyntaxElement, options: CursorWithCountOptionsWithComment<JSONCToken, JSONCComment, R>): R[];
/**
* Gets the token that follows a given node or token.
*/
getTokenAfter(node: JSONCSyntaxElement, options?: CursorWithSkipOptionsWithoutFilter): JSONCToken | null;
/**
* Gets the token that follows a given node or token with filter options.
*/
getTokenAfter<R extends JSONCToken>(node: JSONCSyntaxElement, options: CursorWithSkipOptionsWithFilter<JSONCToken, R>): R | null;
/**
* Gets the token that follows a given node or token with comment options.
*/
getTokenAfter<R extends JSONCToken | JSONCComment>(node: JSONCSyntaxElement, options: CursorWithSkipOptionsWithComment<JSONCToken, JSONCComment, R>): R | null;
/**
* Gets the `count` tokens that follows a given node or token.
*/
getTokensAfter(node: JSONCSyntaxElement, options?: CursorWithCountOptionsWithoutFilter): JSONCToken[];
/**
* Gets the `count` tokens that follows a given node or token with filter options.
*/
getTokensAfter<R extends JSONCToken>(node: JSONCSyntaxElement, options: CursorWithCountOptionsWithFilter<JSONCToken, R>): R[];
/**
* Gets the `count` tokens that follows a given node or token with comment options.
*/
getTokensAfter<R extends JSONCToken | JSONCComment>(node: JSONCSyntaxElement, options: CursorWithCountOptionsWithComment<JSONCToken, JSONCComment, R>): R[];
/**
* Gets the first token between two non-overlapping nodes.
*/
getFirstTokenBetween(left: JSONCSyntaxElement, right: JSONCSyntaxElement, options?: CursorWithSkipOptionsWithoutFilter): JSONCToken | null;
/**
* Gets the first token between two non-overlapping nodes with filter options.
*/
getFirstTokenBetween<R extends JSONCToken>(left: JSONCSyntaxElement, right: JSONCSyntaxElement, options: CursorWithSkipOptionsWithFilter<JSONCToken, R>): R | null;
/**
* Gets the first token between two non-overlapping nodes with comment options.
*/
getFirstTokenBetween<R extends JSONCToken | JSONCComment>(left: JSONCSyntaxElement, right: JSONCSyntaxElement, options: CursorWithSkipOptionsWithComment<JSONCToken, JSONCComment, R>): R | null;
/**
* Gets the first tokens between two non-overlapping nodes.
*/
getFirstTokensBetween(left: JSONCSyntaxElement, right: JSONCSyntaxElement, options?: CursorWithCountOptionsWithoutFilter): JSONCToken[];
/**
* Gets the first tokens between two non-overlapping nodes with filter options.
*/
getFirstTokensBetween<R extends JSONCToken>(left: JSONCSyntaxElement, right: JSONCSyntaxElement, options: CursorWithCountOptionsWithFilter<JSONCToken, R>): R[];
/**
* Gets the first tokens between two non-overlapping nodes with comment options.
*/
getFirstTokensBetween<R extends JSONCToken | JSONCComment>(left: JSONCSyntaxElement, right: JSONCSyntaxElement, options: CursorWithCountOptionsWithComment<JSONCToken, JSONCComment, R>): R[];
/**
* Gets the last token between two non-overlapping nodes.
*/
getLastTokenBetween(left: JSONCSyntaxElement, right: JSONCSyntaxElement, options?: CursorWithSkipOptionsWithoutFilter): JSONCToken | null;
/**
* Gets the last token between two non-overlapping nodes with filter options.
*/
getLastTokenBetween<R extends JSONCToken>(left: JSONCSyntaxElement, right: JSONCSyntaxElement, options: CursorWithSkipOptionsWithFilter<JSONCToken, R>): R | null;
/**
* Gets the last token between two non-overlapping nodes with comment options.
*/
getLastTokenBetween<R extends JSONCToken | JSONCComment>(left: JSONCSyntaxElement, right: JSONCSyntaxElement, options: CursorWithSkipOptionsWithComment<JSONCToken, JSONCComment, R>): R | null;
/**
* Gets the last tokens between two non-overlapping nodes.
*/
getLastTokensBetween(left: JSONCSyntaxElement, right: JSONCSyntaxElement, options?: CursorWithCountOptionsWithoutFilter): JSONCToken[];
/**
* Gets the last tokens between two non-overlapping nodes with filter options.
*/
getLastTokensBetween<R extends JSONCToken>(left: JSONCSyntaxElement, right: JSONCSyntaxElement, options: CursorWithCountOptionsWithFilter<JSONCToken, R>): R[];
/**
* Gets the last tokens between two non-overlapping nodes with comment options.
*/
getLastTokensBetween<R extends JSONCToken | JSONCComment>(left: JSONCSyntaxElement, right: JSONCSyntaxElement, options: CursorWithCountOptionsWithComment<JSONCToken, JSONCComment, R>): R[];
/**
* Gets all tokens that are related to the given node.
*/
getTokens(node: JSONCSyntaxElement, options?: CursorWithCountOptionsWithoutFilter): JSONCToken[];
/**
* Gets all tokens that are related to the given node with filter options.
*/
getTokens<R extends JSONCToken>(node: JSONCSyntaxElement, options: CursorWithCountOptionsWithFilter<JSONCToken, R>): R[];
/**
* Gets all tokens that are related to the given node with comment options.
*/
getTokens<R extends JSONCToken | JSONCComment>(node: JSONCSyntaxElement, options: CursorWithCountOptionsWithComment<JSONCToken, JSONCComment, R>): R[];
/**
* Gets all of the tokens between two non-overlapping nodes.
*/
getTokensBetween(left: JSONCSyntaxElement, right: JSONCSyntaxElement, options?: CursorWithCountOptionsWithoutFilter): JSONCToken[];
/**
* Gets all of the tokens between two non-overlapping nodes with filter options.
*/
getTokensBetween<R extends JSONCToken>(left: JSONCSyntaxElement, right: JSONCSyntaxElement, options: CursorWithCountOptionsWithFilter<JSONCToken, R>): R[];
/**
* Gets all of the tokens between two non-overlapping nodes with comment options.
*/
getTokensBetween<R extends JSONCToken | JSONCComment>(left: JSONCSyntaxElement, right: JSONCSyntaxElement, options: CursorWithCountOptionsWithComment<JSONCToken, JSONCComment, R>): R[];
getCommentsInside(nodeOrToken: JSONCSyntaxElement): JSONCComment[];
getCommentsBefore(nodeOrToken: JSONCSyntaxElement): JSONCComment[];
getCommentsAfter(nodeOrToken: JSONCSyntaxElement): JSONCComment[];
commentsExistBetween(first: JSONCSyntaxElement, second: JSONCSyntaxElement): boolean;
isSpaceBetween(first: JSONCToken | JSONCComment, second: JSONCToken | JSONCComment): boolean;
/**
* Compatibility for ESLint's SourceCode API
* @deprecated JSONC does not have scopes
*/
getScope(node?: AST.JSONNode): Scope.Scope | null;
/**
* Compatibility for ESLint's SourceCode API
* @deprecated JSONC does not have scopes
*/
get scopeManager(): Scope.ScopeManager | null;
/**
* Compatibility for ESLint's SourceCode API
* @deprecated
*/
isSpaceBetweenTokens(first: JSONCTokenOrComment, second: JSONCTokenOrComment): boolean;
private _getChildren;
}
//#endregion
//#region lib/language/jsonc-language.d.ts
/**
* Language options for JSONC.
*/
type JSONCLanguageOptions = {
parserOptions?: JSONParserOptions;
};
type ParserMode = "JSON" | "JSONC" | "JSON5" | "EXTENDED";
type JSONCLanguageInstanceOptions = {
mode?: ParserMode;
};
/**
* The JSONC language implementation for ESLint.
*/
declare class JSONCLanguage implements Language<{
LangOptions: JSONCLanguageOptions;
Code: JSONCSourceCode;
RootNode: AST.JSONProgram;
Node: AST.JSONNode;
}> {
/**
* The type of file to read.
*/
fileType: "text";
/**
* The line number at which the parser starts counting.
*/
lineStart: 1;
/**
* The column number at which the parser starts counting.
*/
columnStart: 0;
/**
* The name of the key that holds the type of the node.
*/
nodeTypeKey: "type";
private readonly _mode;
constructor(options?: JSONCLanguageInstanceOptions);
/**
* Validates the language options.
*/
validateLanguageOptions(_languageOptions: JSONCLanguageOptions): void;
normalizeLanguageOptions(languageOptions: JSONCLanguageOptions): JSONCLanguageOptions;
/**
* Parses the given file into an AST.
*/
parse(file: File, context: {
languageOptions?: JSONCLanguageOptions;
}): OkParseResult<AST.JSONProgram> | NotOkParseResult;
/**
* Creates a new SourceCode object for the given file and parse result.
*/
createSourceCode(file: File, parseResult: OkParseResult<AST.JSONProgram>): JSONCSourceCode;
}
//#endregion
//#region lib/types.d.ts
interface RuleModule<RuleOptions extends unknown[] = unknown[]> extends core.RuleDefinition<{
LangOptions: JSONCLanguageOptions;
Code: JSONCSourceCode;
RuleOptions: RuleOptions;
Visitor: RuleListener;
Node: AST.JSONNode;
MessageIds: string;
ExtRuleDocs: RuleMetaDocs;
}> {
meta: RuleMetaData<RuleOptions>;
}
type RuleMetaDocs = {
description: string;
recommended: ("json" | "jsonc" | "json5")[] | null;
url: string;
ruleId: string;
ruleName: string;
default?: "error" | "warn";
extensionRule: boolean | string | {
plugin: string;
url: string;
};
layout: boolean;
};
interface RuleMetaData<RuleOptions extends unknown[] = unknown[]> extends core.RulesMeta<string, RuleOptions, RuleMetaDocs> {
docs: RuleMetaDocs;
}
//#endregion
export { JSONCSourceCode as a, JSONCComment as i, JSONCLanguage as n, JSONCToken as o, JSONCLanguageOptions as r, RuleModule as t };