eslint-plugin-yml
Advanced tools
Comparing version 0.8.1 to 0.9.0
@@ -52,2 +52,16 @@ import type { RuleModule } from "./types"; | ||
}; | ||
prettier: { | ||
extends: string[]; | ||
rules: { | ||
"yml/block-mapping-question-indicator-newline": string; | ||
"yml/block-sequence-hyphen-indicator-newline": string; | ||
"yml/flow-mapping-curly-newline": string; | ||
"yml/flow-mapping-curly-spacing": string; | ||
"yml/flow-sequence-bracket-newline": string; | ||
"yml/flow-sequence-bracket-spacing": string; | ||
"yml/indent": string; | ||
"yml/key-spacing": string; | ||
"yml/quotes": string; | ||
}; | ||
}; | ||
}; | ||
@@ -54,0 +68,0 @@ rules: { |
@@ -9,2 +9,3 @@ "use strict"; | ||
const standard_1 = __importDefault(require("./configs/standard")); | ||
const prettier_1 = __importDefault(require("./configs/prettier")); | ||
const configs = { | ||
@@ -14,2 +15,3 @@ base: base_1.default, | ||
standard: standard_1.default, | ||
prettier: prettier_1.default, | ||
}; | ||
@@ -16,0 +18,0 @@ const rules = rules_1.rules.reduce((obj, r) => { |
@@ -11,2 +11,3 @@ "use strict"; | ||
extensionRule: false, | ||
layout: true, | ||
}, | ||
@@ -13,0 +14,0 @@ fixable: "whitespace", |
@@ -34,2 +34,3 @@ "use strict"; | ||
extensionRule: false, | ||
layout: false, | ||
}, | ||
@@ -36,0 +37,0 @@ fixable: "code", |
@@ -11,2 +11,3 @@ "use strict"; | ||
extensionRule: false, | ||
layout: true, | ||
}, | ||
@@ -13,0 +14,0 @@ fixable: "whitespace", |
@@ -34,2 +34,3 @@ "use strict"; | ||
extensionRule: false, | ||
layout: false, | ||
}, | ||
@@ -36,0 +37,0 @@ fixable: "code", |
@@ -65,2 +65,3 @@ "use strict"; | ||
extensionRule: "object-curly-newline", | ||
layout: true, | ||
}, | ||
@@ -67,0 +68,0 @@ fixable: "whitespace", |
@@ -11,2 +11,3 @@ "use strict"; | ||
extensionRule: "object-curly-spacing", | ||
layout: true, | ||
}, | ||
@@ -13,0 +14,0 @@ fixable: coreRule.meta.fixable, |
@@ -12,2 +12,3 @@ "use strict"; | ||
extensionRule: "array-bracket-newline", | ||
layout: true, | ||
}, | ||
@@ -14,0 +15,0 @@ fixable: "whitespace", |
@@ -11,2 +11,3 @@ "use strict"; | ||
extensionRule: "array-bracket-spacing", | ||
layout: true, | ||
}, | ||
@@ -13,0 +14,0 @@ fixable: coreRule.meta.fixable, |
@@ -15,2 +15,3 @@ "use strict"; | ||
extensionRule: false, | ||
layout: true, | ||
}, | ||
@@ -17,0 +18,0 @@ fixable: "whitespace", |
@@ -13,2 +13,3 @@ "use strict"; | ||
extensionRule: false, | ||
layout: false, | ||
}, | ||
@@ -54,3 +55,3 @@ schema: [ | ||
}, | ||
type: "layout", | ||
type: "suggestion", | ||
}, | ||
@@ -57,0 +58,0 @@ create(context) { |
@@ -109,2 +109,3 @@ "use strict"; | ||
extensionRule: "key-spacing", | ||
layout: true, | ||
}, | ||
@@ -111,0 +112,0 @@ fixable: "whitespace", |
@@ -10,2 +10,3 @@ "use strict"; | ||
extensionRule: false, | ||
layout: false, | ||
}, | ||
@@ -12,0 +13,0 @@ schema: [], |
@@ -10,2 +10,3 @@ "use strict"; | ||
extensionRule: false, | ||
layout: false, | ||
}, | ||
@@ -12,0 +13,0 @@ schema: [], |
@@ -10,2 +10,3 @@ "use strict"; | ||
extensionRule: false, | ||
layout: false, | ||
}, | ||
@@ -12,0 +13,0 @@ schema: [], |
@@ -11,2 +11,3 @@ "use strict"; | ||
extensionRule: false, | ||
layout: false, | ||
}, | ||
@@ -13,0 +14,0 @@ schema: [], |
@@ -13,2 +13,3 @@ "use strict"; | ||
extensionRule: "no-irregular-whitespace", | ||
layout: false, | ||
}, | ||
@@ -15,0 +16,0 @@ schema: [ |
@@ -10,2 +10,3 @@ "use strict"; | ||
extensionRule: false, | ||
layout: false, | ||
}, | ||
@@ -12,0 +13,0 @@ schema: [], |
@@ -22,2 +22,8 @@ "use strict"; | ||
]); | ||
function toRegExps(patterns) { | ||
return patterns.map((p) => new RegExp(p, "u")); | ||
} | ||
function isStringScalar(node) { | ||
return typeof node.value === "string"; | ||
} | ||
exports.default = utils_1.createRule("plain-scalar", { | ||
@@ -29,5 +35,18 @@ meta: { | ||
extensionRule: false, | ||
layout: false, | ||
}, | ||
fixable: "code", | ||
schema: [{ enum: ["always", "never"] }], | ||
schema: [ | ||
{ enum: ["always", "never"] }, | ||
{ | ||
type: "object", | ||
properties: { | ||
ignorePatterns: { | ||
type: "array", | ||
items: { type: "string" }, | ||
}, | ||
}, | ||
additionalProperties: false, | ||
}, | ||
], | ||
messages: { | ||
@@ -40,2 +59,3 @@ required: "Must use plain style scalar.", | ||
create(context) { | ||
var _a, _b; | ||
if (!context.parserServices.isYAML) { | ||
@@ -45,2 +65,7 @@ return {}; | ||
const option = context.options[0] || "always"; | ||
const ignorePatterns = toRegExps((_b = (_a = context.options[1]) === null || _a === void 0 ? void 0 : _a.ignorePatterns) !== null && _b !== void 0 ? _b : (option === "always" | ||
? [ | ||
String.raw `[\v\f\u0085\u00a0\u1680\u180e\u2000-\u200b\u2028\u2029\u202f\u205f\u3000\ufeff]`, | ||
] | ||
: [])); | ||
const sourceCode = context.getSourceCode(); | ||
@@ -114,3 +139,3 @@ function canToPlain(node) { | ||
function verifyNever(node) { | ||
if (node.style !== "plain" || typeof node.value !== "string") { | ||
if (node.style !== "plain") { | ||
return; | ||
@@ -130,5 +155,18 @@ } | ||
return { | ||
YAMLScalar: option === "always" ? verifyAlways : verifyNever, | ||
YAMLScalar(node) { | ||
if (!isStringScalar(node)) { | ||
return; | ||
} | ||
if (ignorePatterns.some((p) => p.test(node.value))) { | ||
return; | ||
} | ||
if (option === "always") { | ||
verifyAlways(node); | ||
} | ||
else { | ||
verifyNever(node); | ||
} | ||
}, | ||
}; | ||
}, | ||
}); |
@@ -10,2 +10,3 @@ "use strict"; | ||
extensionRule: false, | ||
layout: true, | ||
}, | ||
@@ -12,0 +13,0 @@ fixable: "code", |
@@ -10,2 +10,3 @@ "use strict"; | ||
extensionRule: false, | ||
layout: false, | ||
}, | ||
@@ -12,0 +13,0 @@ schema: [], |
@@ -137,2 +137,3 @@ "use strict"; | ||
extensionRule: "sort-keys", | ||
layout: false, | ||
}, | ||
@@ -139,0 +140,0 @@ fixable: "code", |
@@ -57,2 +57,3 @@ "use strict"; | ||
extensionRule: "spaced-comment", | ||
layout: false, | ||
}, | ||
@@ -59,0 +60,0 @@ fixable: "whitespace", |
@@ -10,2 +10,3 @@ "use strict"; | ||
extensionRule: false, | ||
layout: false, | ||
}, | ||
@@ -12,0 +13,0 @@ schema: [], |
@@ -43,2 +43,3 @@ import type { JSONSchema4 } from "json-schema"; | ||
extensionRule: string | false; | ||
layout: boolean; | ||
}; | ||
@@ -66,2 +67,3 @@ messages: { | ||
extensionRule: string | false; | ||
layout: boolean; | ||
}; | ||
@@ -68,0 +70,0 @@ messages: { |
{ | ||
"name": "eslint-plugin-yml", | ||
"version": "0.8.1", | ||
"version": "0.9.0", | ||
"description": "This ESLint plugin provides linting rules for YAML.", | ||
@@ -82,3 +82,3 @@ "main": "lib/index.js", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"eslint-plugin-regexp": "^0.4.0", | ||
"eslint-plugin-regexp": "^0.5.0", | ||
"eslint-plugin-vue": "^7.0.1", | ||
@@ -85,0 +85,0 @@ "eslint-plugin-yml": "^0.8.0", |
@@ -29,2 +29,15 @@ # Introduction | ||
## :question: How is it different from other YAML plugins? | ||
### Plugins that do not use AST | ||
e.g. [eslint-plugin-yaml](https://www.npmjs.com/package/eslint-plugin-yaml) | ||
These plugins use the processor to parse and return the results independently, without providing the ESLint engine with AST and source code text. | ||
Plugins don't provide AST, so you can't use directive comments (e.g. `# eslint-disable`). | ||
Plugins don't provide source code text, so you can't use it with plugins and rules that use text (e.g. [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier), [eol-last](https://eslint.org/docs/rules/eol-last)). | ||
**eslint-plugin-yml** works by providing AST and source code text to ESLint. | ||
<!--DOCS_IGNORE_START--> | ||
@@ -79,2 +92,3 @@ | ||
- `plugin:yml/standard` ... Above, plus rules to enforce the common stylistic conventions. | ||
- `plugin:yml/prettier` ... Turn off rules that may conflict with [Prettier](https://prettier.io/). | ||
@@ -162,4 +176,18 @@ See [the rule list](https://ota-meshi.github.io/eslint-plugin-yml/rules/) to get the `rules` that this plugin provides. | ||
## :rocket: To Do More Verification | ||
### Verify using JSON Schema | ||
You can verify using JSON Schema by checking and installing [eslint-plugin-json-schema-validator]. | ||
### Verify the [Vue I18n] message resource files | ||
You can verify the message files by checking and installing [@intlify/eslint-plugin-vue-i18n]. | ||
<!--DOCS_IGNORE_START--> | ||
<!-- ## :traffic_light: Semantic Versioning Policy | ||
**eslint-plugin-jsonc** follows [Semantic Versioning](http://semver.org/) and [ESLint's Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy). --> | ||
## :beers: Contributing | ||
@@ -196,1 +224,4 @@ | ||
[YAML]: https://yaml.org/ | ||
[eslint-plugin-json-schema-validator]: https://github.com/ota-meshi/eslint-plugin-json-schema-validator | ||
[@intlify/eslint-plugin-vue-i18n]: https://github.com/intlify/eslint-plugin-vue-i18n | ||
[Vue I18n]: https://github.com/intlify/vue-i18n-next |
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
207965
71
4997
224