new changes

This commit is contained in:
Niranjan
2026-04-07 05:05:28 +05:30
parent 7c070224bd
commit a18bba15f2
29975 changed files with 3247495 additions and 2761 deletions

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Yosuke Ota
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,108 @@
# yaml-eslint-parser
A YAML parser that produces output [compatible with ESLint](https://eslint.org/docs/developer-guide/working-with-custom-parsers#all-nodes).
_This parser is backed by excellent [yaml](https://github.com/eemeli/yaml) package and it is heavily inspired by [yaml-unist-parser](https://github.com/ikatyang/yaml-unist-parser) package._
[![NPM license](https://img.shields.io/npm/l/yaml-eslint-parser.svg)](https://www.npmjs.com/package/yaml-eslint-parser)
[![NPM version](https://img.shields.io/npm/v/yaml-eslint-parser.svg)](https://www.npmjs.com/package/yaml-eslint-parser)
[![NPM downloads](https://img.shields.io/badge/dynamic/json.svg?label=downloads&colorB=green&suffix=/day&query=$.downloads&uri=https://api.npmjs.org//downloads/point/last-day/yaml-eslint-parser&maxAge=3600)](http://www.npmtrends.com/yaml-eslint-parser)
[![NPM downloads](https://img.shields.io/npm/dw/yaml-eslint-parser.svg)](http://www.npmtrends.com/yaml-eslint-parser)
[![NPM downloads](https://img.shields.io/npm/dm/yaml-eslint-parser.svg)](http://www.npmtrends.com/yaml-eslint-parser)
[![NPM downloads](https://img.shields.io/npm/dy/yaml-eslint-parser.svg)](http://www.npmtrends.com/yaml-eslint-parser)
[![NPM downloads](https://img.shields.io/npm/dt/yaml-eslint-parser.svg)](http://www.npmtrends.com/yaml-eslint-parser)
[![Build Status](https://github.com/ota-meshi/yaml-eslint-parser/workflows/CI/badge.svg?branch=master)](https://github.com/ota-meshi/yaml-eslint-parser/actions?query=workflow%3ACI)
[![Coverage Status](https://coveralls.io/repos/github/ota-meshi/yaml-eslint-parser/badge.svg?branch=master)](https://coveralls.io/github/ota-meshi/yaml-eslint-parser?branch=master)
## Installation
```bash
npm install --save-dev yaml-eslint-parser
```
## Usage
### Configuration
Use `.eslintrc.*` file to configure parser. See also: [https://eslint.org/docs/user-guide/configuring](https://eslint.org/docs/user-guide/configuring).
Example **.eslintrc.js**:
```js
module.exports = {
overrides: [
{
files: ["*.yaml", "*.yml"],
parser: "yaml-eslint-parser",
},
],
};
```
### Advanced Configuration
The following additional configuration options are available by specifying them in [parserOptions](https://eslint.org/docs/latest/user-guide/configuring/language-options#specifying-parser-options) in your ESLint configuration file.
Example **.eslintrc.js**:
```js
module.exports = {
overrides: [
{
files: ["*.yaml", "*.yml"],
parser: "yaml-eslint-parser",
// Additional configuration options
parserOptions: {
defaultYAMLVersion: "1.2",
},
},
],
};
```
#### `parserOptions.defaultYAMLVersion`
Set to `"1.2"` or `"1.1"`. Select the YAML version used by documents without a `%YAML` directive.
If not specified, the [yaml](https://eemeli.org/yaml/)'s default `version` option (`"1.2"`) is used.
See <https://eemeli.org/yaml/#document-options> for details.
## Usage for Custom Rules / Plugins
- [AST.md](./docs/AST.md) is AST specification.
- [block-mapping.ts](https://github.com/ota-meshi/eslint-plugin-yml/blob/master/src/rules/block-mapping.ts) is an example.
- You can see the AST on the [Online DEMO](https://ota-meshi.github.io/yaml-eslint-parser/).
## Usage for Directly
Example:
```ts
import type { AST } from "yaml-eslint-parser";
import { parseYAML, getStaticYAMLValue } from "yaml-eslint-parser";
const code = `
american:
- Boston Red Sox
- Detroit Tigers
- New York Yankees
national:
- New York Mets
- Chicago Cubs
- Atlanta Braves
`;
const ast: AST.YAMLProgram = parseYAML(code);
console.log(ast);
const value = getStaticYAMLValue(ast);
console.log(value);
```
## Related Packages
- [eslint-plugin-jsonc](https://github.com/ota-meshi/eslint-plugin-jsonc) ... ESLint plugin for JSON, JSON with comments (JSONC) and JSON5.
- [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) ... ESLint plugin for YAML.
- [eslint-plugin-toml](https://github.com/ota-meshi/eslint-plugin-toml) ... ESLint plugin for TOML.
- [eslint-plugin-json-schema-validator](https://github.com/ota-meshi/eslint-plugin-json-schema-validator) ... ESLint plugin that validates data using JSON Schema Validator.
- [jsonc-eslint-parser](https://github.com/ota-meshi/jsonc-eslint-parser) ... JSON, JSONC and JSON5 parser for use with ESLint plugins.
- [toml-eslint-parser](https://github.com/ota-meshi/toml-eslint-parser) ... TOML parser for use with ESLint plugins.

View File

@@ -0,0 +1,156 @@
import type { YAMLVersion } from "./utils";
export type Range = [number, number];
export interface Locations {
loc: SourceLocation;
range: Range;
}
interface BaseYAMLNode extends Locations {
type: string;
}
export interface SourceLocation {
start: Position;
end: Position;
}
export interface Token extends BaseYAMLNode {
type: "Directive" | "Marker" | "Punctuator" | "Identifier" | "String" | "Boolean" | "Numeric" | "Null" | "BlockLiteral" | "BlockFolded";
value: string;
}
export interface Comment extends BaseYAMLNode {
type: "Line" | "Block";
value: string;
}
export interface Position {
/** >= 1 */
line: number;
/** >= 0 */
column: number;
}
export type YAMLNode = YAMLProgram | YAMLDocument | YAMLDirective | YAMLContent | YAMLPair | YAMLWithMeta | YAMLAnchor | YAMLTag;
export interface YAMLProgram extends BaseYAMLNode {
type: "Program";
body: YAMLDocument[];
sourceType: "module";
comments: Comment[];
tokens: Token[];
parent: null;
}
export interface YAMLDocument extends BaseYAMLNode {
type: "YAMLDocument";
directives: YAMLDirective[];
content: YAMLContent | YAMLWithMeta | null;
parent: YAMLProgram;
anchors: {
[key: string]: YAMLAnchor[];
};
version: YAMLVersion;
}
interface BaseYAMLDirective extends BaseYAMLNode {
type: "YAMLDirective";
value: string;
kind: "YAML" | "TAG" | null;
parent: YAMLDocument;
}
export interface YAMLDirectiveForYAML extends BaseYAMLDirective {
kind: "YAML";
version: string;
}
export interface YAMLDirectiveForTAG extends BaseYAMLDirective {
kind: "TAG";
handle: string;
prefix: string;
}
export interface YAMLDirectiveForUnknown extends BaseYAMLDirective {
kind: null;
}
export type YAMLDirective = YAMLDirectiveForYAML | YAMLDirectiveForTAG | YAMLDirectiveForUnknown;
export interface YAMLWithMeta extends BaseYAMLNode {
type: "YAMLWithMeta";
anchor: YAMLAnchor | null;
tag: YAMLTag | null;
value: Exclude<YAMLContent, YAMLAlias> | null;
parent: YAMLDocument | YAMLPair | YAMLSequence;
}
export interface YAMLAnchor extends BaseYAMLNode {
type: "YAMLAnchor";
name: string;
parent: YAMLWithMeta;
}
export interface YAMLTag extends BaseYAMLNode {
type: "YAMLTag";
tag: string;
raw: string;
parent: YAMLWithMeta;
}
interface BaseYAMLContentNode extends BaseYAMLNode {
parent: YAMLDocument | YAMLPair | YAMLSequence | YAMLWithMeta;
}
export type YAMLContent = YAMLMapping | YAMLSequence | YAMLScalar | YAMLAlias;
export type YAMLMapping = YAMLBlockMapping | YAMLFlowMapping;
export interface YAMLBlockMapping extends BaseYAMLContentNode {
type: "YAMLMapping";
style: "block";
pairs: YAMLPair[];
}
export interface YAMLFlowMapping extends BaseYAMLContentNode {
type: "YAMLMapping";
style: "flow";
pairs: YAMLPair[];
}
export interface YAMLPair extends BaseYAMLNode {
type: "YAMLPair";
key: YAMLContent | YAMLWithMeta | null;
value: YAMLContent | YAMLWithMeta | null;
parent: YAMLMapping;
}
export type YAMLSequence = YAMLBlockSequence | YAMLFlowSequence;
export interface YAMLBlockSequence extends BaseYAMLContentNode {
type: "YAMLSequence";
style: "block";
entries: (YAMLContent | YAMLWithMeta | null)[];
}
export interface YAMLFlowSequence extends BaseYAMLContentNode {
type: "YAMLSequence";
style: "flow";
entries: (YAMLContent | YAMLWithMeta)[];
}
export type YAMLScalar = YAMLPlainScalar | YAMLDoubleQuotedScalar | YAMLSingleQuotedScalar | YAMLBlockLiteralScalar | YAMLBlockFoldedScalar;
export interface YAMLPlainScalar extends BaseYAMLContentNode {
type: "YAMLScalar";
style: "plain";
strValue: string;
value: string | number | boolean | null;
raw: string;
}
export interface YAMLDoubleQuotedScalar extends BaseYAMLContentNode {
type: "YAMLScalar";
style: "double-quoted";
strValue: string;
value: string;
raw: string;
}
export interface YAMLSingleQuotedScalar extends BaseYAMLContentNode {
type: "YAMLScalar";
style: "single-quoted";
strValue: string;
value: string;
raw: string;
}
export interface YAMLBlockLiteralScalar extends BaseYAMLContentNode {
type: "YAMLScalar";
style: "literal";
chomping: "clip" | "keep" | "strip";
indent: null | number;
value: string;
}
export interface YAMLBlockFoldedScalar extends BaseYAMLContentNode {
type: "YAMLScalar";
style: "folded";
chomping: "clip" | "keep" | "strip";
indent: null | number;
value: string;
}
export interface YAMLAlias extends BaseYAMLContentNode {
type: "YAMLAlias";
name: string;
}
export {};

View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1,31 @@
import type { Comment, Locations, Range, Token } from "./ast";
import { type CST, type DocumentOptions, LineCounter } from "yaml";
import { ParseError } from ".";
export declare class Context {
readonly code: string;
readonly options: DocumentOptions;
readonly tokens: Token[];
readonly comments: Comment[];
readonly lineCounter: LineCounter;
private readonly locsMap;
constructor(origCode: string, parserOptions: any);
getLocFromIndex(index: number): {
line: number;
column: number;
};
/**
* Get the location information of the given range.
*/
getConvertLocation(start: number, end: number): Locations;
addComment(comment: Comment): void;
/**
* Add token to tokens
*/
addToken(type: Token["type"], range: Readonly<Range>): Token;
throwUnexpectedTokenError(cst: CST.Token | Token): ParseError;
throwError(message: string, cst: CST.Token | Token | number): ParseError;
/**
* Gets the last index with whitespace skipped.
*/
lastSkipSpaces(startIndex: number, endIndex: number): number;
}

View File

@@ -0,0 +1,78 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Context = void 0;
const yaml_1 = require("yaml");
const _1 = require(".");
const options_1 = require("./options");
class Context {
constructor(origCode, parserOptions) {
this.tokens = [];
this.comments = [];
this.locsMap = new Map();
this.options = (0, options_1.parserOptionsToYAMLOption)(parserOptions);
this.code = origCode;
this.lineCounter = new yaml_1.LineCounter();
}
getLocFromIndex(index) {
let loc = this.locsMap.get(index);
if (!loc) {
const { line, col } = this.lineCounter.linePos(index);
loc = { line, column: col - 1 };
this.locsMap.set(index, loc);
}
return {
line: loc.line,
column: loc.column,
};
}
/**
* Get the location information of the given range.
*/
getConvertLocation(start, end) {
return {
range: [start, end],
loc: {
start: this.getLocFromIndex(start),
end: this.getLocFromIndex(end),
},
};
}
addComment(comment) {
this.comments.push(comment);
}
/**
* Add token to tokens
*/
addToken(type, range) {
const token = Object.assign({ type, value: this.code.slice(...range) }, this.getConvertLocation(...range));
this.tokens.push(token);
return token;
}
/* istanbul ignore next */
throwUnexpectedTokenError(cst) {
const token = "source" in cst ? `'${cst.source}'` : cst.type;
throw this.throwError(`Unexpected token: ${token}`, cst);
}
throwError(message, cst) {
const offset = typeof cst === "number"
? cst
: "offset" in cst
? cst.offset
: cst.range[0];
const loc = this.getLocFromIndex(offset);
throw new _1.ParseError(message, offset, loc.line, loc.column);
}
/**
* Gets the last index with whitespace skipped.
*/
lastSkipSpaces(startIndex, endIndex) {
const str = this.code;
for (let index = endIndex - 1; index >= startIndex; index--) {
if (str[index].trim()) {
return index + 1;
}
}
return startIndex;
}
}
exports.Context = Context;

View File

@@ -0,0 +1,7 @@
import type { YAMLProgram } from "./ast";
import type { Context } from "./context";
import type { ParsedCSTDocs } from "./yaml-cst-parse";
/**
* Convert yaml root to YAMLProgram
*/
export declare function convertRoot(docs: ParsedCSTDocs, ctx: Context): YAMLProgram;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,16 @@
/**
* YAML parse errors.
*/
export declare class ParseError extends SyntaxError {
index: number;
lineNumber: number;
column: number;
/**
* Initialize this ParseError instance.
* @param message The error message.
* @param offset The offset number of this error.
* @param line The line number of this error.
* @param column The column number of this error.
*/
constructor(message: string, offset: number, line: number, column: number);
}

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParseError = void 0;
/**
* YAML parse errors.
*/
class ParseError extends SyntaxError {
/**
* Initialize this ParseError instance.
* @param message The error message.
* @param offset The offset number of this error.
* @param line The line number of this error.
* @param column The column number of this error.
*/
constructor(message, offset, line, column) {
super(message);
this.index = offset;
this.lineNumber = line;
this.column = column;
}
}
exports.ParseError = ParseError;

View File

@@ -0,0 +1,16 @@
import { parseForESLint } from "./parser";
import type * as AST from "./ast";
import { traverseNodes } from "./traverse";
import { getStaticYAMLValue } from "./utils";
import { ParseError } from "./errors";
export * as meta from "./meta";
export { name } from "./meta";
export type { AST };
export { ParseError };
export { parseForESLint };
export declare const VisitorKeys: import("eslint").SourceCode.VisitorKeys;
export { traverseNodes, getStaticYAMLValue };
/**
* Parse YAML source code
*/
export declare function parseYAML(code: string, options?: any): AST.YAMLProgram;

View File

@@ -0,0 +1,58 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStaticYAMLValue = exports.traverseNodes = exports.VisitorKeys = exports.parseForESLint = exports.ParseError = exports.name = exports.meta = void 0;
exports.parseYAML = parseYAML;
const parser_1 = require("./parser");
Object.defineProperty(exports, "parseForESLint", { enumerable: true, get: function () { return parser_1.parseForESLint; } });
const traverse_1 = require("./traverse");
Object.defineProperty(exports, "traverseNodes", { enumerable: true, get: function () { return traverse_1.traverseNodes; } });
const utils_1 = require("./utils");
Object.defineProperty(exports, "getStaticYAMLValue", { enumerable: true, get: function () { return utils_1.getStaticYAMLValue; } });
const visitor_keys_1 = require("./visitor-keys");
const errors_1 = require("./errors");
Object.defineProperty(exports, "ParseError", { enumerable: true, get: function () { return errors_1.ParseError; } });
exports.meta = __importStar(require("./meta"));
var meta_1 = require("./meta");
Object.defineProperty(exports, "name", { enumerable: true, get: function () { return meta_1.name; } });
// Keys
// eslint-disable-next-line @typescript-eslint/naming-convention -- ignore
exports.VisitorKeys = visitor_keys_1.KEYS;
/**
* Parse YAML source code
*/
function parseYAML(code, options) {
return (0, parser_1.parseForESLint)(code, options).ast;
}

View File

@@ -0,0 +1,2 @@
export declare const name: "yaml-eslint-parser";
export declare const version: "1.3.2";

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = exports.name = void 0;
// IMPORTANT!
// This file has been automatically generated,
// in order to update its content execute "npm run build:meta"
exports.name = "yaml-eslint-parser";
exports.version = "1.3.2";

View File

@@ -0,0 +1,5 @@
import type { DocumentOptions } from "yaml";
/**
* ESLint parserOptions to `yaml`'s Composer options.
*/
export declare function parserOptionsToYAMLOption(options: any): DocumentOptions;

View File

@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parserOptionsToYAMLOption = parserOptionsToYAMLOption;
/**
* ESLint parserOptions to `yaml`'s Composer options.
*/
function parserOptionsToYAMLOption(options) {
if (!options) {
return {};
}
const result = {};
const version = options.defaultYAMLVersion;
if (typeof version === "string" || typeof version === "number") {
const sVer = String(version);
if (sVer === "1.2" || sVer === "1.1") {
result.version = sVer;
}
else {
// Treat unknown versions as next.
result.version = "next";
}
}
return result;
}

View File

@@ -0,0 +1,12 @@
import type { SourceCode } from "eslint";
import type { YAMLProgram } from "./ast";
/**
* Parse source code
*/
export declare function parseForESLint(code: string, options?: any): {
ast: YAMLProgram;
visitorKeys: SourceCode.VisitorKeys;
services: {
isYAML: boolean;
};
};

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseForESLint = parseForESLint;
const visitor_keys_1 = require("./visitor-keys");
const convert_1 = require("./convert");
const context_1 = require("./context");
const yaml_cst_parse_1 = require("./yaml-cst-parse");
/**
* Parse source code
*/
function parseForESLint(code, options) {
const ctx = new context_1.Context(code, options);
const docs = (0, yaml_cst_parse_1.parseAllDocsToCST)(ctx);
const ast = (0, convert_1.convertRoot)(docs, ctx);
return {
ast,
visitorKeys: visitor_keys_1.KEYS,
services: {
isYAML: true,
},
};
}

View File

@@ -0,0 +1,11 @@
import type { YAMLAlias, YAMLContent } from "../ast";
export type TagResolver<T> = {
tag: string;
testString: (str: string) => boolean;
resolveString: (str: string) => T;
};
export type TagNodeResolver<T> = {
tag: string;
testNode: (node: Exclude<YAMLContent, YAMLAlias>) => boolean;
resolveNode: (node: Exclude<YAMLContent, YAMLAlias>) => T;
};

View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1,10 @@
export declare const tagResolvers: {
next: (import("./commons").TagResolver<null> | import("./commons").TagResolver<true> | import("./commons").TagResolver<false> | import("./commons").TagResolver<number> | import("./commons").TagResolver<string>)[];
"1.2": (import("./commons").TagResolver<null> | import("./commons").TagResolver<true> | import("./commons").TagResolver<false> | import("./commons").TagResolver<number> | import("./commons").TagResolver<string>)[];
"1.1": (import("./commons").TagResolver<null> | import("./commons").TagResolver<true> | import("./commons").TagResolver<false> | import("./commons").TagResolver<number> | import("./commons").TagResolver<string>)[];
};
export declare const tagNodeResolvers: {
next: (import("./commons").TagNodeResolver<Record<any, any>> | import("./commons").TagNodeResolver<any[]>)[];
"1.2": (import("./commons").TagNodeResolver<Record<any, any>> | import("./commons").TagNodeResolver<any[]>)[];
"1.1": (import("./commons").TagNodeResolver<Record<any, any>> | import("./commons").TagNodeResolver<any[]>)[];
};

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tagNodeResolvers = exports.tagResolvers = void 0;
const tags1_2_1 = require("./tags1.2");
const tags1_1_1 = require("./tags1.1");
exports.tagResolvers = {
next: tags1_2_1.tagResolvers,
"1.2": tags1_2_1.tagResolvers,
"1.1": tags1_1_1.tagResolvers,
};
exports.tagNodeResolvers = {
next: tags1_2_1.tagNodeResolvers,
"1.2": tags1_2_1.tagNodeResolvers,
"1.1": tags1_1_1.tagNodeResolvers,
};

View File

@@ -0,0 +1,2 @@
import type { TagNodeResolver } from "./commons";
export declare const OMAP: TagNodeResolver<Record<any, any>>;

View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OMAP = void 0;
const utils_1 = require("../utils");
exports.OMAP = {
// see https://yaml.org/type/omap.html
tag: "tag:yaml.org,2002:omap",
testNode(node) {
return (node.type === "YAMLSequence" &&
node.entries.every((e) => (e === null || e === void 0 ? void 0 : e.type) === "YAMLMapping" && e.pairs.length === 1));
},
resolveNode(node) {
const seq = node;
const result = {};
for (const e of seq.entries) {
const map = e;
for (const p of map.pairs) {
const key = p.key ? (0, utils_1.getStaticYAMLValue)(p.key) : p.key;
const value = p.value ? (0, utils_1.getStaticYAMLValue)(p.value) : p.value;
result[key] = value;
}
}
return result;
},
};

View File

@@ -0,0 +1,2 @@
import type { TagNodeResolver } from "./commons";
export declare const SET: TagNodeResolver<any[]>;

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SET = void 0;
const utils_1 = require("../utils");
exports.SET = {
// see https://yaml.org/type/set.html
tag: "tag:yaml.org,2002:set",
testNode(node) {
return (node.type === "YAMLMapping" &&
node.pairs.every((p) => p.key != null && p.value == null));
},
resolveNode(node) {
const map = node;
const result = [];
for (const p of map.pairs) {
result.push((0, utils_1.getStaticYAMLValue)(p.key));
}
return result;
},
};

View File

@@ -0,0 +1,16 @@
import type { TagResolver } from "./commons";
export declare const NULL: TagResolver<null>;
export declare const TRUE: TagResolver<true>;
export declare const FALSE: TagResolver<false>;
export declare const INT: TagResolver<number>;
export declare const INT_BASE2: TagResolver<number>;
export declare const INT_BASE8: TagResolver<number>;
export declare const INT_BASE16: TagResolver<number>;
export declare const INT_BASE60: TagResolver<number>;
export declare const FLOAT: TagResolver<number>;
export declare const FLOAT_BASE60: TagResolver<number>;
export declare const INFINITY: TagResolver<number>;
export declare const NAN: TagResolver<number>;
export declare const STR: TagResolver<string>;
export declare const tagResolvers: (TagResolver<null> | TagResolver<true> | TagResolver<false> | TagResolver<number> | TagResolver<string>)[];
export declare const tagNodeResolvers: (import("./commons").TagNodeResolver<Record<any, any>> | import("./commons").TagNodeResolver<any[]>)[];

View File

@@ -0,0 +1,197 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.tagNodeResolvers = exports.tagResolvers = exports.STR = exports.NAN = exports.INFINITY = exports.FLOAT_BASE60 = exports.FLOAT = exports.INT_BASE60 = exports.INT_BASE16 = exports.INT_BASE8 = exports.INT_BASE2 = exports.INT = exports.FALSE = exports.TRUE = exports.NULL = void 0;
const omap_1 = require("./omap");
const set_1 = require("./set");
const Tags1_2 = __importStar(require("./tags1.2"));
// https://yaml.org/type/
// see https://yaml.org/type/null.html
exports.NULL = Tags1_2.NULL;
exports.TRUE = {
// see https://yaml.org/type/bool.html
tag: "tag:yaml.org,2002:bool",
testString(str) {
// see https://yaml.org/type/bool.html
return /^(?:y|Y|yes|Yes|YES|true|True|TRUE|on|On|ON)$/u.test(str);
},
resolveString() {
return true;
},
};
exports.FALSE = {
// see https://yaml.org/type/bool.html
tag: "tag:yaml.org,2002:bool",
testString(str) {
// see https://yaml.org/type/bool.html
return /^(?:n|N|no|No|NO|false|False|FALSE|off|Off|OFF)$/u.test(str);
},
resolveString() {
return false;
},
};
exports.INT = {
// see https://yaml.org/type/int.html
tag: "tag:yaml.org,2002:int",
testString(str) {
// see https://yaml.org/type/int.html
return /^[+-]?(?:0|[1-9][\d_]*)$/u.test(str);
},
resolveString(str) {
return resolveInt(str, 0, 10);
},
};
exports.INT_BASE2 = {
// see https://yaml.org/type/int.html
tag: "tag:yaml.org,2002:int",
testString(str) {
// see https://yaml.org/type/int.html
return /^[+-]?0b[01_]+$/u.test(str);
},
resolveString(str) {
return resolveInt(str, 2, 2);
},
};
exports.INT_BASE8 = {
// see https://yaml.org/type/int.html
tag: "tag:yaml.org,2002:int",
testString(str) {
// see https://yaml.org/type/int.html
return /^[+-]?0[0-7_]+$/u.test(str);
},
resolveString(str) {
return resolveInt(str, 1, 8);
},
};
exports.INT_BASE16 = {
// see https://yaml.org/type/int.html
tag: "tag:yaml.org,2002:int",
testString(str) {
// see https://yaml.org/type/int.html
return /^[+-]?0x[\dA-F_a-f]+$/u.test(str);
},
resolveString(str) {
return resolveInt(str, 2, 16);
},
};
exports.INT_BASE60 = {
// see https://yaml.org/type/int.html
tag: "tag:yaml.org,2002:int",
testString(str) {
// see https://yaml.org/type/int.html
return /^[+-]?[1-9][\d_]*(?::[0-5]?\d)+$/u.test(str);
},
resolveString(str) {
return resolveBase60(str.split(/:/u), true);
},
};
exports.FLOAT = {
// see https://yaml.org/type/float.html
tag: "tag:yaml.org,2002:float",
testString(str) {
// see https://yaml.org/type/float.html
return (/^[+-]?(?:\d[\d_]*)?\.[\d_]*(?:e[+-]?\d+)?$/iu.test(str) ||
// The previous regexp cannot handle "e" without dot. spec bug?
/^[+-]?(?:\d[\d_]*)?(?:e[+-]?\d+)?$/iu.test(str));
},
resolveString(str) {
return parseFloat(str.replace(/_/gu, ""));
},
};
exports.FLOAT_BASE60 = {
// see https://yaml.org/type/float.html
tag: "tag:yaml.org,2002:float",
testString(str) {
// see https://yaml.org/type/float.html
return /^[+-]?\d[\d_]*(?::[0-5]?\d)+\.[\d_]*$/u.test(str);
},
resolveString(str) {
return resolveBase60(str.split(/:/u), false);
},
};
// see https://yaml.org/type/float.html
exports.INFINITY = Tags1_2.INFINITY;
// see https://yaml.org/type/float.html
exports.NAN = Tags1_2.NAN;
// see https://yaml.org/type/str.html
exports.STR = Tags1_2.STR;
// !!Currently, timestamps are not supported as they affect the type definition.
// If the user needs timestamps, we will consider supporting it in the major version.
// https://yaml.org/type/timestamp.html
exports.tagResolvers = [
exports.NULL,
exports.TRUE,
exports.FALSE,
exports.INT_BASE8,
exports.INT,
exports.INT_BASE2,
exports.INT_BASE16,
exports.INT_BASE60,
exports.FLOAT,
exports.FLOAT_BASE60,
exports.INFINITY,
exports.NAN,
exports.STR,
];
exports.tagNodeResolvers = [omap_1.OMAP, set_1.SET];
/**
* Resolve int value
*/
function resolveInt(value, skip, radix) {
if (value.startsWith("-") || value.startsWith("+")) {
return parseInt(value[0] + value.slice(skip + 1).replace(/_/gu, ""), radix);
}
return parseInt(value.slice(skip).replace(/_/gu, ""), radix);
}
/**
* Resolve base 60 number value
*/
function resolveBase60(values, isInt) {
let first = values.shift().replace(/_/gu, "");
const last = values.pop().replace(/_/gu, "");
let minus = false;
if (first.startsWith("-") || first.startsWith("+")) {
minus = first.startsWith("-");
first = first.slice(1);
}
let value = parseInt(first, 10);
while (values.length) {
value *= 60;
value += parseInt(values.shift().replace(/_/gu, ""), 10);
}
value *= 60;
value += isInt ? parseInt(last, 10) : parseFloat(last);
return minus ? -value : value;
}

View File

@@ -0,0 +1,13 @@
import type { TagResolver } from "./commons";
export declare const NULL: TagResolver<null>;
export declare const TRUE: TagResolver<true>;
export declare const FALSE: TagResolver<false>;
export declare const INT: TagResolver<number>;
export declare const INT_BASE8: TagResolver<number>;
export declare const INT_BASE16: TagResolver<number>;
export declare const FLOAT: TagResolver<number>;
export declare const INFINITY: TagResolver<number>;
export declare const NAN: TagResolver<number>;
export declare const STR: TagResolver<string>;
export declare const tagResolvers: (TagResolver<null> | TagResolver<true> | TagResolver<false> | TagResolver<number> | TagResolver<string>)[];
export declare const tagNodeResolvers: (import("./commons").TagNodeResolver<Record<any, any>> | import("./commons").TagNodeResolver<any[]>)[];

View File

@@ -0,0 +1,131 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tagNodeResolvers = exports.tagResolvers = exports.STR = exports.NAN = exports.INFINITY = exports.FLOAT = exports.INT_BASE16 = exports.INT_BASE8 = exports.INT = exports.FALSE = exports.TRUE = exports.NULL = void 0;
const omap_1 = require("./omap");
const set_1 = require("./set");
exports.NULL = {
// see https://yaml.org/spec/1.2/spec.html#id2803311
tag: "tag:yaml.org,2002:null",
testString(str) {
return (!str || // empty
// see https://yaml.org/spec/1.2/spec.html#id2805071
str === "null" ||
str === "Null" ||
str === "NULL" ||
str === "~");
},
resolveString() {
return null;
},
};
exports.TRUE = {
// see https://yaml.org/spec/1.2/spec.html#id2803311
tag: "tag:yaml.org,2002:bool",
testString(str) {
// see https://yaml.org/spec/1.2/spec.html#id2805071
return str === "true" || str === "True" || str === "TRUE";
},
resolveString() {
return true;
},
};
exports.FALSE = {
// see https://yaml.org/spec/1.2/spec.html#id2803311
tag: "tag:yaml.org,2002:bool",
testString(str) {
// see https://yaml.org/spec/1.2/spec.html#id2805071
return str === "false" || str === "False" || str === "FALSE";
},
resolveString() {
return false;
},
};
exports.INT = {
// see https://yaml.org/spec/1.2/spec.html#id2803311
tag: "tag:yaml.org,2002:int",
testString(str) {
// see https://yaml.org/spec/1.2/spec.html#id2805071
return /^[+-]?\d+$/u.test(str);
},
resolveString(str) {
return parseInt(str, 10);
},
};
exports.INT_BASE8 = {
// see https://yaml.org/spec/1.2/spec.html#id2803311
tag: "tag:yaml.org,2002:int",
testString(str) {
// see https://yaml.org/spec/1.2/spec.html#id2805071
return /^0o[0-7]+$/u.test(str);
},
resolveString(str) {
return parseInt(str.slice(2), 8);
},
};
exports.INT_BASE16 = {
// see https://yaml.org/spec/1.2/spec.html#id2803311
tag: "tag:yaml.org,2002:int",
testString(str) {
// see https://yaml.org/spec/1.2/spec.html#id2805071
return /^0x[\dA-Fa-f]+$/u.test(str);
},
resolveString(str) {
return parseInt(str.slice(2), 16);
},
};
exports.FLOAT = {
// see https://yaml.org/spec/1.2/spec.html#id2803311
tag: "tag:yaml.org,2002:float",
testString(str) {
// see https://yaml.org/spec/1.2/spec.html#id2805071
return /^[+-]?(?:\.\d+|\d+(?:\.\d*)?)(?:e[+-]?\d+)?$/iu.test(str);
},
resolveString(str) {
return parseFloat(str);
},
};
exports.INFINITY = {
// see https://yaml.org/spec/1.2/spec.html#id2803311
tag: "tag:yaml.org,2002:float",
testString(str) {
// see https://yaml.org/spec/1.2/spec.html#id2805071
return /^[+-]?(?:\.inf|\.Inf|\.INF)$/u.test(str);
},
resolveString(str) {
return str.startsWith("-") ? -Infinity : Infinity;
},
};
exports.NAN = {
// see https://yaml.org/spec/1.2/spec.html#id2803311
tag: "tag:yaml.org,2002:float",
testString(str) {
// see https://yaml.org/spec/1.2/spec.html#id2805071
return str === ".NaN" || str === ".nan" || str === ".NAN";
},
resolveString() {
return NaN;
},
};
exports.STR = {
// see https://yaml.org/spec/1.2/spec.html#id2803311
tag: "tag:yaml.org,2002:str",
testString() {
return true;
},
resolveString(str) {
return str;
},
};
exports.tagResolvers = [
exports.NULL,
exports.TRUE,
exports.FALSE,
exports.INT,
exports.INT_BASE8,
exports.INT_BASE16,
exports.FLOAT,
exports.INFINITY,
exports.NAN,
exports.STR,
];
exports.tagNodeResolvers = [omap_1.OMAP, set_1.SET];

View File

@@ -0,0 +1,25 @@
import type { VisitorKeys } from "eslint-visitor-keys";
import type { YAMLNode } from "./ast";
/**
* Get the keys of the given node to traverse it.
* @param node The node to get.
* @returns The keys to traverse.
*/
export declare function getFallbackKeys(node: any): string[];
/**
* Get the keys of the given node to traverse it.
* @param node The node to get.
* @returns The keys to traverse.
*/
export declare function getKeys(node: any, visitorKeys?: VisitorKeys): string[];
/**
* Get the nodes of the given node.
* @param node The node to get.
*/
export declare function getNodes(node: any, key: string): IterableIterator<YAMLNode>;
export interface Visitor<N> {
visitorKeys?: VisitorKeys;
enterNode(node: N, parent: N | null): void;
leaveNode(node: N, parent: N | null): void;
}
export declare function traverseNodes(node: YAMLNode, visitor: Visitor<YAMLNode>): void;

View File

@@ -0,0 +1,92 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFallbackKeys = getFallbackKeys;
exports.getKeys = getKeys;
exports.getNodes = getNodes;
exports.traverseNodes = traverseNodes;
const visitor_keys_1 = require("./visitor-keys");
/**
* Check that the given key should be traversed or not.
* @this {Traversable}
* @param key The key to check.
* @returns `true` if the key should be traversed.
*/
function fallbackKeysFilter(key) {
let value = null;
return (key !== "comments" &&
key !== "leadingComments" &&
key !== "loc" &&
key !== "parent" &&
key !== "range" &&
key !== "tokens" &&
key !== "trailingComments" &&
(value = this[key]) !== null &&
typeof value === "object" &&
(typeof value.type === "string" || Array.isArray(value)));
}
/**
* Get the keys of the given node to traverse it.
* @param node The node to get.
* @returns The keys to traverse.
*/
function getFallbackKeys(node) {
return Object.keys(node).filter(fallbackKeysFilter, node);
}
/**
* Get the keys of the given node to traverse it.
* @param node The node to get.
* @returns The keys to traverse.
*/
function getKeys(node, visitorKeys) {
const keys = (visitorKeys || visitor_keys_1.KEYS)[node.type] || getFallbackKeys(node);
return keys.filter((key) => !getNodes(node, key).next().done);
}
/**
* Get the nodes of the given node.
* @param node The node to get.
*/
function* getNodes(node, key) {
const child = node[key];
if (Array.isArray(child)) {
for (const c of child) {
if (isNode(c)) {
yield c;
}
}
}
else if (isNode(child)) {
yield child;
}
}
/**
* Check whether a given value is a node.
* @param x The value to check.
* @returns `true` if the value is a node.
*/
function isNode(x) {
return x !== null && typeof x === "object" && typeof x.type === "string";
}
/**
* Traverse the given node.
* @param node The node to traverse.
* @param parent The parent node.
* @param visitor The node visitor.
*/
function traverse(node, parent, visitor) {
visitor.enterNode(node, parent);
const keys = getKeys(node, visitor.visitorKeys);
for (const key of keys) {
for (const child of getNodes(node, key)) {
traverse(child, node, visitor);
}
}
visitor.leaveNode(node, parent);
}
/**
* Traverse the given AST tree.
* @param node Root node to traverse.
* @param visitor Visitor.
*/
function traverseNodes(node, visitor) {
traverse(node, null, visitor);
}

View File

@@ -0,0 +1,12 @@
import { type DocumentOptions } from "yaml";
import type { YAMLProgram, YAMLContent, YAMLDocument, YAMLMapping, YAMLSequence, YAMLScalar, YAMLAlias, YAMLPair, YAMLWithMeta } from "./ast";
export type YAMLVersion = NonNullable<DocumentOptions["version"]>;
export type YAMLContentValue = string | number | boolean | null | YAMLContentValue[] | YAMLMappingValue;
export type YAMLMappingValue = {
[key: string]: YAMLContentValue;
[key: number]: YAMLContentValue;
};
export declare function getStaticYAMLValue(node: YAMLMapping | YAMLPair): YAMLMappingValue;
export declare function getStaticYAMLValue(node: YAMLSequence): YAMLContentValue[];
export declare function getStaticYAMLValue(node: YAMLScalar): string | number | boolean | null;
export declare function getStaticYAMLValue(node: YAMLAlias | YAMLProgram | YAMLDocument | YAMLContent | YAMLPair | YAMLWithMeta): YAMLContentValue;

View File

@@ -0,0 +1,136 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStaticYAMLValue = getStaticYAMLValue;
const yaml_1 = require("yaml");
const tags_1 = require("./tags");
/**
* Gets the static value for the given node.
*/
function getStaticYAMLValue(node) {
return getValue(node, null);
}
/**
* Gets the static value for the given node with YAML version.
*/
function getValue(node, version) {
return resolver[node.type](node, version);
}
const resolver = {
Program(node) {
return node.body.length === 0
? null
: node.body.length === 1
? // eslint-disable-next-line new-cap -- traverse key
resolver.YAMLDocument(node.body[0])
: // eslint-disable-next-line new-cap -- traverse key
node.body.map((n) => resolver.YAMLDocument(n));
},
YAMLDocument(node) {
return node.content ? getValue(node.content, node.version) : null;
},
YAMLMapping(node, version) {
const result = {};
for (const pair of node.pairs) {
Object.assign(result, getValue(pair, version));
}
return result;
},
YAMLPair(node, version) {
const result = {};
let key = node.key ? getValue(node.key, version) : null;
if (typeof key !== "string" && typeof key !== "number") {
key = String(key);
}
result[key] = node.value ? getValue(node.value, version) : null;
return result;
},
YAMLSequence(node, version) {
const result = [];
for (const entry of node.entries) {
result.push(entry ? getValue(entry, version) : null);
}
return result;
},
YAMLScalar(node) {
return node.value;
},
YAMLAlias(node, version) {
const anchor = findAnchor(node);
return anchor ? getValue(anchor.parent, version) : null;
},
YAMLWithMeta(node, version) {
if (node.tag) {
const value = node.value;
if (value == null) {
return getTaggedValue(node.tag, "", "", version);
}
if (value.type === "YAMLScalar") {
if (value.style === "plain") {
return getTaggedValue(node.tag, value.strValue, value.strValue, version);
}
if (value.style === "double-quoted" ||
value.style === "single-quoted") {
return getTaggedValue(node.tag, value.raw, value.strValue, version);
}
}
for (const tagResolver of tags_1.tagNodeResolvers[version || "1.2"]) {
if (tagResolver.tag === node.tag.tag && tagResolver.testNode(value)) {
return tagResolver.resolveNode(value);
}
}
}
if (node.value == null) {
return null;
}
return getValue(node.value, version);
},
};
/**
* Find Anchor
*/
function findAnchor(node) {
let p = node.parent;
let doc = null;
while (p) {
if (p.type === "YAMLDocument") {
doc = p;
break;
}
p = p.parent;
}
const anchors = doc.anchors[node.name];
if (!anchors) {
return null;
}
let target = {
anchor: null,
distance: Infinity,
};
for (const anchor of anchors) {
if (anchor.range[0] < node.range[0]) {
const distance = node.range[0] - anchor.range[0];
if (target.distance >= distance) {
target = {
anchor,
distance,
};
}
}
}
return target.anchor;
}
/**
* Get tagged value
*/
function getTaggedValue(tag, text, str, version) {
for (const tagResolver of tags_1.tagResolvers[version || "1.2"]) {
if (tagResolver.tag === tag.tag && tagResolver.testString(str)) {
return tagResolver.resolveString(str);
}
}
const tagText = tag.tag.startsWith("!") ? tag.tag : `!<${tag.tag}>`;
const value = (0, yaml_1.parseDocument)(`${version ? `%YAML ${version}` : ""}
---
${tagText} ${text}`).toJSON();
return value;
}

View File

@@ -0,0 +1,2 @@
import type { SourceCode } from "eslint";
export declare const KEYS: SourceCode.VisitorKeys;

View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KEYS = void 0;
const eslint_visitor_keys_1 = require("eslint-visitor-keys");
const yamlKeys = {
Program: ["body"],
YAMLDocument: ["directives", "content"],
YAMLDirective: [],
YAMLMapping: ["pairs"],
YAMLPair: ["key", "value"],
YAMLSequence: ["entries"],
YAMLWithMeta: ["anchor", "tag", "value"],
YAMLScalar: [],
YAMLAlias: [],
YAMLAnchor: [],
YAMLTag: [],
};
exports.KEYS = (0, eslint_visitor_keys_1.unionWith)(yamlKeys);

View File

@@ -0,0 +1,10 @@
import type { CST, Document } from "yaml";
import { Composer } from "yaml";
import type { Context } from "./context";
export type ParsedCSTDocs = {
cstNodes: CST.Token[];
nodes: Document.Parsed[];
streamInfo: ReturnType<Composer["streamInfo"]>;
};
/** Parse yaml to CST */
export declare function parseAllDocsToCST(ctx: Context): ParsedCSTDocs;

View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseAllDocsToCST = parseAllDocsToCST;
const yaml_1 = require("yaml");
/** Parse yaml to CST */
function parseAllDocsToCST(ctx) {
const { lineCounter } = ctx;
const parser = new yaml_1.Parser(lineCounter.addNewLine);
const composer = new yaml_1.Composer(Object.assign(Object.assign({}, ctx.options), { keepSourceTokens: true, lineCounter }));
const cstNodes = [];
const nodes = [];
/**
* Process for Document
*/
function processDoc(node) {
for (const error of node.errors) {
throw ctx.throwError(error.message, error.pos[0]);
}
// ignore warns
// for (const error of doc.warnings) {
// throw ctx.throwError(error.message, error.pos[0])
// }
nodes.push(node);
}
for (const cst of parser.parse(ctx.code)) {
cstNodes.push(cst);
for (const doc of composer.next(cst)) {
processDoc(doc);
}
}
for (const doc of composer.end()) {
processDoc(doc);
}
return { nodes, cstNodes, streamInfo: composer.streamInfo() };
}

View File

@@ -0,0 +1,90 @@
{
"name": "yaml-eslint-parser",
"version": "1.3.2",
"description": "A YAML parser that produces output compatible with ESLint",
"main": "lib/index.js",
"files": [
"lib"
],
"engines": {
"node": "^14.17.0 || >=16.0.0"
},
"scripts": {
"prebuild": "npm run -s clean",
"build": "npm run build:meta && npm run build:tsc",
"build:meta": "ts-node --transpile-only ./tools/update-meta.ts",
"build:tsc": "tsc --project ./tsconfig.build.json",
"clean": "rimraf .nyc_output lib coverage",
"lint": "eslint .",
"eslint-fix": "npm run lint -- --fix",
"test": "mocha --require ts-node/register \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
"cover": "nyc --reporter=lcov npm run test",
"debug": "mocha --require ts-node/register/transpile-only \"tests/src/**/*.ts\" --reporter dot",
"preversion": "npm run lint && npm test",
"update-fixtures": "ts-node ./tools/update-fixtures.ts",
"benchmark": "ts-node --transpile-only benchmark/index.ts",
"prerelease": "npm run clean && npm run build",
"release": "changeset publish",
"version:ci": "env-cmd -e version-ci -- npm run build:meta && changeset version",
"strict-type-check": "tsc --project ./tsconfig.build.json --noEmit --module esnext --moduleResolution bundler"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ota-meshi/yaml-eslint-parser.git"
},
"keywords": [
"yaml",
"eslint",
"parser"
],
"author": "Yosuke Ota",
"funding": "https://github.com/sponsors/ota-meshi",
"license": "MIT",
"bugs": {
"url": "https://github.com/ota-meshi/yaml-eslint-parser/issues"
},
"homepage": "https://github.com/ota-meshi/yaml-eslint-parser#readme",
"dependencies": {
"eslint-visitor-keys": "^3.0.0",
"yaml": "^2.0.0"
},
"devDependencies": {
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.24.2",
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
"@ota-meshi/eslint-plugin": "^0.18.0",
"@types/benchmark": "^2.1.1",
"@types/eslint": "^9.0.0",
"@types/eslint-visitor-keys": "^3.0.0",
"@types/mocha": "^10.0.0",
"@types/node": "^24.0.0",
"@types/semver": "^7.3.10",
"@typescript-eslint/eslint-plugin": "^8.16.0",
"@typescript-eslint/parser": "^8.16.0",
"benchmark": "^2.1.4",
"env-cmd": "^11.0.0",
"eslint": "^9.15.0",
"eslint-config-prettier": "^10.0.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-jsdoc": "^61.0.0",
"eslint-plugin-json-schema-validator": "^5.0.0",
"eslint-plugin-jsonc": "^2.0.0",
"eslint-plugin-n": "^17.0.0",
"eslint-plugin-node-dependencies": "^1.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-regexp": "^2.0.0",
"eslint-plugin-vue": "^10.0.0",
"mocha": "^11.0.0",
"nyc": "^17.0.0",
"prettier": "^3.0.0",
"semver": "^7.3.7",
"ts-node": "^10.0.0",
"typescript": "^5.0.0",
"typescript-eslint": "^8.16.0",
"vue-eslint-parser": "^10.0.0",
"yaml-test-suite": "^0.1.0"
},
"publishConfig": {
"access": "public"
}
}