eslint-plugin-yml
Advanced tools
Comparing version 0.0.2 to 0.1.0
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const object_curly_spacing_1 = __importDefault(require("eslint/lib/rules/object-curly-spacing")); | ||
const utils_1 = require("../utils"); | ||
const coreRule = utils_1.getCoreRule("object-curly-spacing"); | ||
exports.default = utils_1.createRule("flow-mapping-curly-spacing", { | ||
@@ -15,6 +12,6 @@ meta: { | ||
}, | ||
fixable: object_curly_spacing_1.default.meta.fixable, | ||
schema: object_curly_spacing_1.default.meta.schema, | ||
messages: object_curly_spacing_1.default.meta.messages, | ||
type: object_curly_spacing_1.default.meta.type, | ||
fixable: coreRule.meta.fixable, | ||
schema: coreRule.meta.schema, | ||
messages: coreRule.meta.messages, | ||
type: coreRule.meta.type, | ||
}, | ||
@@ -25,3 +22,3 @@ create(context) { | ||
} | ||
return utils_1.defineWrapperListener(object_curly_spacing_1.default, context, { | ||
return utils_1.defineWrapperListener(coreRule, context, { | ||
options: context.options, | ||
@@ -28,0 +25,0 @@ createListenerProxy(listener) { |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const array_bracket_spacing_1 = __importDefault(require("eslint/lib/rules/array-bracket-spacing")); | ||
const utils_1 = require("../utils"); | ||
const coreRule = utils_1.getCoreRule("array-bracket-spacing"); | ||
exports.default = utils_1.createRule("flow-sequence-bracket-spacing", { | ||
@@ -15,6 +12,6 @@ meta: { | ||
}, | ||
fixable: array_bracket_spacing_1.default.meta.fixable, | ||
schema: array_bracket_spacing_1.default.meta.schema, | ||
messages: array_bracket_spacing_1.default.meta.messages, | ||
type: array_bracket_spacing_1.default.meta.type, | ||
fixable: coreRule.meta.fixable, | ||
schema: coreRule.meta.schema, | ||
messages: coreRule.meta.messages, | ||
type: coreRule.meta.type, | ||
}, | ||
@@ -25,3 +22,3 @@ create(context) { | ||
} | ||
return utils_1.defineWrapperListener(array_bracket_spacing_1.default, context, { | ||
return utils_1.defineWrapperListener(coreRule, context, { | ||
options: context.options, | ||
@@ -28,0 +25,0 @@ createListenerProxy(listener) { |
@@ -117,3 +117,3 @@ import type { JSONSchema4 } from "json-schema"; | ||
getLocFromIndex(index: number): AST.Position; | ||
getIndexFromLoc(location: AST.Position): number; | ||
getIndexFromLoc(loc: AST.Position): number; | ||
getTokenByRangeStart(offset: number, options?: { | ||
@@ -120,0 +120,0 @@ includeComments?: boolean; |
import type { YAMLToken } from "../types"; | ||
export declare function isCommentToken(token: YAMLToken | null): boolean | null; | ||
export declare function isCommentToken(token: YAMLToken | null): boolean; | ||
export declare function isTokenOnSameLine(left: YAMLToken, right: YAMLToken): boolean; | ||
@@ -4,0 +4,0 @@ export declare function isQuestion(token: YAMLToken | null): token is YAMLToken; |
@@ -5,3 +5,3 @@ "use strict"; | ||
function isCommentToken(token) { | ||
return token && (token.type === "Block" || token.type === "Line"); | ||
return Boolean(token && (token.type === "Block" || token.type === "Line")); | ||
} | ||
@@ -8,0 +8,0 @@ exports.isCommentToken = isCommentToken; |
@@ -14,2 +14,3 @@ import type { RuleListener, RuleModule, PartialRuleModule, RuleContext } from "../types"; | ||
export declare function isNode(data: any): boolean; | ||
export declare function getCoreRule(ruleName: string): Rule.RuleModule; | ||
export {}; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isNode = exports.getProxyNode = exports.defineWrapperListener = exports.createRule = void 0; | ||
exports.getCoreRule = exports.isNode = exports.getProxyNode = exports.defineWrapperListener = exports.createRule = void 0; | ||
const debug_1 = __importDefault(require("debug")); | ||
@@ -13,3 +13,5 @@ const log = debug_1.default("eslint-plugin-yml:utils/index"); | ||
meta: Object.assign(Object.assign({}, rule.meta), { docs: Object.assign(Object.assign({}, rule.meta.docs), { url: `https://ota-meshi.github.io/eslint-plugin-yml/rules/${ruleName}.html`, ruleId: `yml/${ruleName}`, ruleName }) }), | ||
create: rule.create, | ||
create(ctx) { | ||
return rule.create(ctx); | ||
}, | ||
}; | ||
@@ -62,1 +64,13 @@ } | ||
exports.isNode = isNode; | ||
let ruleMap = null; | ||
function getCoreRule(ruleName) { | ||
let map; | ||
if (ruleMap) { | ||
map = ruleMap; | ||
} | ||
else { | ||
ruleMap = map = new (require("eslint").Linter)().getRules(); | ||
} | ||
return map.get(ruleName); | ||
} | ||
exports.getCoreRule = getCoreRule; |
@@ -13,3 +13,3 @@ import type { AST } from "yaml-eslint-parser"; | ||
export declare function isKeyNode(node: AST.YAMLContent | AST.YAMLWithMeta): boolean; | ||
export declare function unwrapMeta(node: AST.YAMLContent | AST.YAMLWithMeta | null): AST.YAMLBlockMapping | AST.YAMLFlowMapping | AST.YAMLBlockSequence | AST.YAMLFlowSequence | AST.YAMLPlainScalar | AST.YAMLDoubleQuotedScalar | AST.YAMLSingleQuotedScalar | AST.YAMLBlockLiteralScalar | AST.YAMLBlockFoldedScalar | AST.YAMLAlias | AST.YAMLWithMeta | null; | ||
export declare function unwrapMeta(node: AST.YAMLContent | AST.YAMLWithMeta | null): AST.YAMLContent | null; | ||
export declare function processIndentFix(fixer: RuleFixer, baseIndent: string, targetNode: AST.YAMLContent | AST.YAMLWithMeta | AST.YAMLPair, context: RuleContext): IterableIterator<Fix>; |
@@ -18,11 +18,11 @@ "use strict"; | ||
const sourceCode = context.getSourceCode(); | ||
let parent = mapping.parent; | ||
if (parent.type === "YAMLWithMeta") { | ||
const before = sourceCode.getTokenBefore(parent); | ||
if (before == null || before.loc.end.line < parent.loc.start.line) { | ||
return calcExpectIndentFromBaseNode(parent, mapping.pairs[0], context); | ||
let parentNode = mapping.parent; | ||
if (parentNode.type === "YAMLWithMeta") { | ||
const before = sourceCode.getTokenBefore(parentNode); | ||
if (before == null || before.loc.end.line < parentNode.loc.start.line) { | ||
return calcExpectIndentFromBaseNode(parentNode, mapping.pairs[0], context); | ||
} | ||
parent = parent.parent; | ||
parentNode = parentNode.parent; | ||
} | ||
if (parent.type === "YAMLDocument") { | ||
if (parentNode.type === "YAMLDocument") { | ||
const mappingIndent = getActualIndent(mapping, context); | ||
@@ -39,3 +39,3 @@ const firstPairIndent = getActualIndent(mapping.pairs[0], context); | ||
} | ||
if (parent.type === "YAMLSequence") { | ||
if (parentNode.type === "YAMLSequence") { | ||
const hyphen = sourceCode.getTokenBefore(mapping); | ||
@@ -55,6 +55,6 @@ if ((hyphen === null || hyphen === void 0 ? void 0 : hyphen.value) !== "-") { | ||
} | ||
if (parent.type !== "YAMLPair") { | ||
if (parentNode.type !== "YAMLPair") { | ||
return null; | ||
} | ||
return calcExpectIndentFromBaseNode(parent, mapping.pairs[0], context); | ||
return calcExpectIndentFromBaseNode(parentNode, mapping.pairs[0], context); | ||
} | ||
@@ -64,11 +64,11 @@ exports.calcExpectIndentForPairs = calcExpectIndentForPairs; | ||
const sourceCode = context.getSourceCode(); | ||
let parent = sequence.parent; | ||
if (parent.type === "YAMLWithMeta") { | ||
const before = sourceCode.getTokenBefore(parent); | ||
if (before == null || before.loc.end.line < parent.loc.start.line) { | ||
return calcExpectIndentFromBaseNode(parent, sequence.entries[0], context); | ||
let parentNode = sequence.parent; | ||
if (parentNode.type === "YAMLWithMeta") { | ||
const before = sourceCode.getTokenBefore(parentNode); | ||
if (before == null || before.loc.end.line < parentNode.loc.start.line) { | ||
return calcExpectIndentFromBaseNode(parentNode, sequence.entries[0], context); | ||
} | ||
parent = parent.parent; | ||
parentNode = parentNode.parent; | ||
} | ||
if (parent.type === "YAMLDocument") { | ||
if (parentNode.type === "YAMLDocument") { | ||
const sequenceIndent = getActualIndent(sequence, context); | ||
@@ -85,3 +85,3 @@ const firstPairIndent = getActualIndent(sequence.entries[0], context); | ||
} | ||
if (parent.type === "YAMLSequence") { | ||
if (parentNode.type === "YAMLSequence") { | ||
const hyphen = sourceCode.getTokenBefore(sequence); | ||
@@ -101,6 +101,6 @@ if ((hyphen === null || hyphen === void 0 ? void 0 : hyphen.value) !== "-") { | ||
} | ||
if (parent.type !== "YAMLPair") { | ||
if (parentNode.type !== "YAMLPair") { | ||
return null; | ||
} | ||
return calcExpectIndentFromBaseNode(parent, sequence.entries[0], context); | ||
return calcExpectIndentFromBaseNode(parentNode, sequence.entries[0], context); | ||
} | ||
@@ -173,3 +173,6 @@ exports.calcExpectIndentForEntries = calcExpectIndentForEntries; | ||
function unwrapMeta(node) { | ||
if ((node === null || node === void 0 ? void 0 : node.type) === "YAMLWithMeta") { | ||
if (!node) { | ||
return node; | ||
} | ||
if (node.type === "YAMLWithMeta") { | ||
return node.value; | ||
@@ -176,0 +179,0 @@ } |
{ | ||
"name": "eslint-plugin-yml", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "This ESLint plugin provides linting rules for YAML.", | ||
@@ -10,3 +10,3 @@ "main": "lib/index.js", | ||
"scripts": { | ||
"prebuild": "npm run -s clean && npm run setup-types", | ||
"prebuild": "npm run -s clean", | ||
"build": "npm run build:ts", | ||
@@ -17,3 +17,2 @@ "build:ts": "tsc --project ./tsconfig.build.json", | ||
"eslint-fix": "eslint \"tests\" \"src\" \"docs/.vuepress\" --ext .js,.vue,.ts,.json --fix", | ||
"pretest": "npm run setup-types", | ||
"pretest:base": "cross-env DEBUG=eslint-plugin-yml*", | ||
@@ -24,3 +23,3 @@ "test:base": "mocha --require ts-node/register \"tests/src/**/*.ts\" --reporter dot --timeout 60000", | ||
"test:debug": "mocha --require ts-node/register --inspect \"tests/src/**/*.ts\" --reporter dot", | ||
"update": "ts-node ./tools/update.ts && npm run eslint-fix && npm run cover", | ||
"update": "node --require ts-node/register ./tools/update.ts && npm run eslint-fix && npm run cover", | ||
"new": "ts-node ./tools/new-rule.ts", | ||
@@ -35,3 +34,2 @@ "predocs:watch": "npm run build:ts", | ||
"version": "npm run eslint-fix && git add .", | ||
"setup-types": "node ./tools/setup-eslint-rule-types.js", | ||
"update-fixtures": "ts-node ./tools/update-fixtures.ts && npm run eslint-fix" | ||
@@ -65,6 +63,6 @@ }, | ||
"devDependencies": { | ||
"@mysticatea/eslint-plugin": "^13.0.0", | ||
"@ota-meshi/eslint-plugin": "^0.0.6", | ||
"@types/debug": "^4.1.5", | ||
"@types/eslint": "^7.2.0", | ||
"@types/estree": "^0.0.44", | ||
"@types/estree": "^0.0.45", | ||
"@types/lodash": "^4.14.158", | ||
@@ -74,6 +72,14 @@ "@types/mocha": "^7.0.2", | ||
"@types/semver": "^7.3.1", | ||
"@typescript-eslint/eslint-plugin": "^4.4.1", | ||
"@typescript-eslint/parser": "^4.4.1", | ||
"babel-eslint": "^10.1.0", | ||
"cross-env": "^7.0.2", | ||
"eslint": "^7.3.0", | ||
"eslint-config-prettier": "^6.13.0", | ||
"eslint-plugin-eslint-comments": "^3.2.0", | ||
"eslint-plugin-eslint-plugin": "^2.3.0", | ||
"eslint-plugin-jsonc": "^0.3.1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"eslint-plugin-vue": "^7.0.1", | ||
"eslint4b": "^7.3.1", | ||
@@ -92,4 +98,5 @@ "espree": "^7.1.0", | ||
"vue-eslint-editor": "^1.1.0", | ||
"vue-eslint-parser": "^7.1.1", | ||
"vuepress": "^1.5.2" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2648
113670
35