eslint-plugin-yml
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -68,2 +68,3 @@ "use strict"; | ||
const sourceCode = context.getSourceCode(); | ||
let currentDocument; | ||
function canToPlain(node) { | ||
@@ -119,3 +120,5 @@ if (node.value !== node.value.trim()) { | ||
try { | ||
const result = (0, yaml_eslint_parser_1.parseForESLint)(node.value); | ||
const result = (0, yaml_eslint_parser_1.parseForESLint)(node.value, { | ||
defaultYAMLVersion: currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.version, | ||
}); | ||
if ((0, yaml_eslint_parser_1.getStaticYAMLValue)(result.ast) !== node.value) { | ||
@@ -152,2 +155,5 @@ return; | ||
return { | ||
YAMLDocument(node) { | ||
currentDocument = node; | ||
}, | ||
YAMLScalar(node) { | ||
@@ -154,0 +160,0 @@ if (!isStringScalar(node)) { |
214
package.json
{ | ||
"name": "eslint-plugin-yml", | ||
"version": "1.0.0", | ||
"description": "This ESLint plugin provides linting rules for YAML.", | ||
"main": "lib/index.js", | ||
"files": [ | ||
"lib" | ||
], | ||
"engines": { | ||
"node": "^14.17.0 || >=16.0.0" | ||
}, | ||
"scripts": { | ||
"prebuild": "npm run -s clean", | ||
"build": "npm run build:ts", | ||
"build:ts": "tsc --project ./tsconfig.build.json", | ||
"clean": "rimraf .nyc_output dist coverage", | ||
"lint": "eslint . --ext .js,.vue,.ts,.json,.md,.yml,.yaml", | ||
"eslint-fix": "eslint . --ext .js,.vue,.ts,.json,.md,.yml,.yaml --fix", | ||
"pretest:base": "cross-env DEBUG=eslint-plugin-yml*", | ||
"test:base": "mocha --require ts-node/register \"tests/src/**/*.ts\" --reporter dot --timeout 60000", | ||
"test": "npm run test:base", | ||
"cover": "nyc --reporter=lcov npm run test:base", | ||
"test:debug": "mocha --require ts-node/register/transpile-only \"tests/src/**/*.ts\" --reporter dot", | ||
"update": "node --require ts-node/register ./tools/update.ts && npm run eslint-fix && npm run cover", | ||
"new": "ts-node ./tools/new-rule.ts", | ||
"predocs:watch": "npm run build:ts", | ||
"docs:watch": "vuepress dev --debug docs", | ||
"docs:build": "npm run build:ts && vuepress build docs --no-cache", | ||
"preversion": "npm test && git add .", | ||
"version": "env-cmd -e version npm run update && git add .", | ||
"update-fixtures": "ts-node ./tools/update-fixtures.ts && npm run eslint-fix" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/ota-meshi/eslint-plugin-yml.git" | ||
}, | ||
"keywords": [ | ||
"eslint", | ||
"eslintplugin", | ||
"eslint-plugin", | ||
"yaml", | ||
"yml" | ||
], | ||
"author": "Yosuke Ota", | ||
"funding": "https://github.com/sponsors/ota-meshi", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/ota-meshi/eslint-plugin-yml/issues" | ||
}, | ||
"homepage": "https://ota-meshi.github.io/eslint-plugin-yml/", | ||
"dependencies": { | ||
"debug": "^4.3.2", | ||
"lodash": "^4.17.21", | ||
"natural-compare": "^1.4.0", | ||
"yaml-eslint-parser": "^1.0.0" | ||
}, | ||
"peerDependencies": { | ||
"eslint": ">=6.0.0" | ||
}, | ||
"devDependencies": { | ||
"@ota-meshi/eslint-plugin": "^0.10.0", | ||
"@types/debug": "^4.1.5", | ||
"@types/eslint": "^8.0.0", | ||
"@types/eslint-scope": "^3.7.0", | ||
"@types/eslint-visitor-keys": "^1.0.0", | ||
"@types/estree": "^0.0.51", | ||
"@types/lodash": "^4.14.158", | ||
"@types/mocha": "^9.0.0", | ||
"@types/natural-compare": "^1.4.0", | ||
"@types/node": "^16.11.3", | ||
"@types/semver": "^7.3.1", | ||
"@typescript-eslint/eslint-plugin": "^5.0.0", | ||
"@typescript-eslint/parser": "^5.0.0", | ||
"cross-env": "^7.0.2", | ||
"env-cmd": "^10.1.0", | ||
"eslint": "^8.0.0", | ||
"eslint-config-prettier": "^8.0.0", | ||
"eslint-plugin-eslint-comments": "^3.2.0", | ||
"eslint-plugin-eslint-plugin": "^4.0.0", | ||
"eslint-plugin-json-schema-validator": "^2.0.0", | ||
"eslint-plugin-jsonc": "^2.0.0", | ||
"eslint-plugin-markdown": "^2.0.0-0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-node-dependencies": "^0.8.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-regexp": "^1.0.0", | ||
"eslint-plugin-vue": "^9.0.0", | ||
"eslint-plugin-yml": "^0.15.0", | ||
"eslint4b": "^7.3.1", | ||
"espree": "^9.0.0", | ||
"mocha": "^10.0.0", | ||
"monaco-editor": "^0.33.0", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.2.1", | ||
"raw-loader": "^4.0.1", | ||
"semver": "^7.3.2", | ||
"stylelint": "^14.0.0", | ||
"stylelint-config-recommended-vue": "^1.0.0", | ||
"stylelint-config-standard": "^25.0.0", | ||
"stylelint-plugin-stylus": "^0.13.0", | ||
"ts-node": "^10.0.0", | ||
"typescript": "~4.6.0", | ||
"vue-eslint-editor": "^1.1.0", | ||
"vue-eslint-parser": "^9.0.0", | ||
"vuepress": "^1.5.2" | ||
} | ||
"name": "eslint-plugin-yml", | ||
"version": "1.1.0", | ||
"description": "This ESLint plugin provides linting rules for YAML.", | ||
"main": "lib/index.js", | ||
"files": [ | ||
"lib" | ||
], | ||
"engines": { | ||
"node": "^14.17.0 || >=16.0.0" | ||
}, | ||
"scripts": { | ||
"prebuild": "npm run -s clean", | ||
"build": "npm run build:ts", | ||
"build:ts": "tsc --project ./tsconfig.build.json", | ||
"clean": "rimraf .nyc_output dist coverage", | ||
"lint": "eslint . --ext .js,.vue,.ts,.json,.md,.yml,.yaml", | ||
"eslint-fix": "eslint . --ext .js,.vue,.ts,.json,.md,.yml,.yaml --fix", | ||
"pretest:base": "cross-env DEBUG=eslint-plugin-yml*", | ||
"test:base": "npm run mocha -- \"tests/src/**/*.ts\" --reporter dot --timeout 60000", | ||
"test": "npm run test:base", | ||
"cover": "nyc --reporter=lcov npm run test:base", | ||
"test:debug": "npm run mocha -- \"tests/src/**/*.ts\" --reporter dot", | ||
"update": "npm run ts -- ./tools/update.ts && npm run eslint-fix && npm run cover", | ||
"new": "npm run ts -- ./tools/new-rule.ts", | ||
"predocs:watch": "npm run build:ts", | ||
"docs:watch": "export NODE_OPTIONS=--openssl-legacy-provider && vuepress dev --debug docs", | ||
"docs:build": "export NODE_OPTIONS=--openssl-legacy-provider && npm run build:ts && vuepress build docs --no-cache", | ||
"preversion": "npm test && git add .", | ||
"version": "env-cmd -e version npm run update && git add .", | ||
"update-fixtures": "npm run ts -- ./tools/update-fixtures.ts && npm run eslint-fix", | ||
"ts": "node -r esbuild-register", | ||
"mocha": "npm run ts -- ./node_modules/mocha/bin/mocha.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/ota-meshi/eslint-plugin-yml.git" | ||
}, | ||
"keywords": [ | ||
"eslint", | ||
"eslintplugin", | ||
"eslint-plugin", | ||
"yaml", | ||
"yml" | ||
], | ||
"author": "Yosuke Ota", | ||
"funding": "https://github.com/sponsors/ota-meshi", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/ota-meshi/eslint-plugin-yml/issues" | ||
}, | ||
"homepage": "https://ota-meshi.github.io/eslint-plugin-yml/", | ||
"dependencies": { | ||
"debug": "^4.3.2", | ||
"lodash": "^4.17.21", | ||
"natural-compare": "^1.4.0", | ||
"yaml-eslint-parser": "^1.1.0" | ||
}, | ||
"peerDependencies": { | ||
"eslint": ">=6.0.0" | ||
}, | ||
"devDependencies": { | ||
"@ota-meshi/eslint-plugin": "^0.11.0", | ||
"@types/debug": "^4.1.5", | ||
"@types/eslint": "^8.0.0", | ||
"@types/eslint-scope": "^3.7.0", | ||
"@types/eslint-visitor-keys": "^1.0.0", | ||
"@types/estree": "^1.0.0", | ||
"@types/lodash": "^4.14.158", | ||
"@types/mocha": "^9.0.0", | ||
"@types/natural-compare": "^1.4.0", | ||
"@types/node": "^16.11.3", | ||
"@types/semver": "^7.3.1", | ||
"@typescript-eslint/eslint-plugin": "^5.0.0", | ||
"@typescript-eslint/parser": "^5.0.0", | ||
"cross-env": "^7.0.2", | ||
"env-cmd": "^10.1.0", | ||
"esbuild": "^0.14.1", | ||
"esbuild-register": "^3.2.0", | ||
"eslint": "^8.0.0", | ||
"eslint-config-prettier": "^8.0.0", | ||
"eslint-plugin-eslint-comments": "^3.2.0", | ||
"eslint-plugin-eslint-plugin": "^5.0.0", | ||
"eslint-plugin-json-schema-validator": "^4.0.0", | ||
"eslint-plugin-jsonc": "^2.0.0", | ||
"eslint-plugin-markdown": "^3.0.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-node-dependencies": "^0.9.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-regexp": "^1.0.0", | ||
"eslint-plugin-vue": "^9.0.0", | ||
"eslint-plugin-yml": "^1.0.0", | ||
"eslint4b": "^7.3.1", | ||
"espree": "^9.0.0", | ||
"mocha": "^10.0.0", | ||
"monaco-editor": "^0.33.0", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.2.1", | ||
"raw-loader": "^4.0.1", | ||
"semver": "^7.3.2", | ||
"stylelint": "^14.9.1", | ||
"stylelint-config-recommended-vue": "^1.0.0", | ||
"stylelint-config-standard": "^26.0.0", | ||
"stylelint-stylus": "^0.16.1", | ||
"typescript": "~4.7.0", | ||
"vue-eslint-editor": "^1.1.0", | ||
"vue-eslint-parser": "^9.0.0", | ||
"vuepress": "^1.5.2", | ||
"yaml": "^2.1.1" | ||
} | ||
} |
@@ -38,3 +38,3 @@ # Introduction | ||
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)). | ||
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)). | ||
@@ -78,3 +78,3 @@ **eslint-plugin-yml** works by providing AST and source code text to ESLint. | ||
// 'eslint:recommended', | ||
'plugin:yml/standard' | ||
"plugin:yml/standard", | ||
], | ||
@@ -84,4 +84,4 @@ rules: { | ||
// 'yml/rule-name': 'error' | ||
} | ||
} | ||
}, | ||
}; | ||
``` | ||
@@ -121,2 +121,25 @@ | ||
#### Parser Options | ||
The following parser options for `yaml-eslint-parser` are available by specifying them in [parserOptions](https://eslint.org/docs/latest/user-guide/configuring/language-options#specifying-parser-options) in the ESLint configuration file. | ||
```js | ||
module.exports = { | ||
// ... | ||
overrides: [ | ||
{ | ||
files: ["*.yaml", "*.yml"], | ||
parser: "yaml-eslint-parser", | ||
// Options used with yaml-eslint-parser. | ||
parserOptions: { | ||
defaultYAMLVersion: "1.2", | ||
}, | ||
}, | ||
], | ||
// ... | ||
}; | ||
``` | ||
See also [https://github.com/ota-meshi/yaml-eslint-parser#readme](https://github.com/ota-meshi/yaml-eslint-parser#readme). | ||
### Running ESLint from the command line | ||
@@ -145,7 +168,3 @@ | ||
{ | ||
"eslint.validate": [ | ||
"javascript", | ||
"javascriptreact", | ||
"yaml" | ||
] | ||
"eslint.validate": ["javascript", "javascriptreact", "yaml"] | ||
} | ||
@@ -161,2 +180,3 @@ ``` | ||
2. In the **Run for files** field, update the pattern that defines the set of files to be linted to include YAML files as well: | ||
``` | ||
@@ -241,4 +261,4 @@ {**/*,*}.{js,ts,jsx,tsx,html,vue,yaml,yml} | ||
- `npm test` runs tests and measures coverage. | ||
- `npm run update` runs in order to update readme and recommended configuration. | ||
- `npm test` runs tests and measures coverage. | ||
- `npm run update` runs in order to update readme and recommended configuration. | ||
@@ -264,5 +284,5 @@ ### Working With Rules | ||
[YAML]: https://yaml.org/ | ||
[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 | ||
[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
239574
5743
281
47
Updatedyaml-eslint-parser@^1.1.0