eslint-plugin-youzan
Advanced tools
Comparing version 0.2.0 to 0.3.0-beta1
@@ -19,4 +19,18 @@ # youzan standard words (youzan-standard-words) | ||
## Options | ||
This rule has an object option: | ||
+ `ignore(string[])` does not check the keyword of the list. Accept regex. | ||
### ignore | ||
Examples of correct code for this rule with the allow option: | ||
```js | ||
/*"youzan/youzan-standard-words": ["error", { "ignore": ["登陆"] }]*/ | ||
const a = "登陆" | ||
``` | ||
## Link | ||
[有赞标准词汇库](https://design.youzan.com/strategy/standard-library.html) |
@@ -120,3 +120,11 @@ /** | ||
schema: [ | ||
// fill in your schema | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"ignore": { | ||
"type": "array" | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
] | ||
@@ -128,3 +136,12 @@ }, | ||
// variables should be defined here | ||
const defaultOptions = { | ||
ignore: [], | ||
} | ||
const options = Object.assign(defaultOptions, context.options[0]) | ||
const ignore = | ||
options.ignore.map(entry => ({ | ||
name: entry, | ||
regex: new RegExp(entry), | ||
})) || []; | ||
//---------------------------------------------------------------------- | ||
@@ -139,6 +156,16 @@ // Helpers | ||
//---------------------------------------------------------------------- | ||
function isIgnored(name) { | ||
return ( | ||
ignore.findIndex( | ||
entry => name === entry.name || entry.regex.test(name), | ||
) !== -1 | ||
); | ||
} | ||
function checkIsWrongWord(node) { | ||
for (let i = 0; i < wrongWords.length; i++) { | ||
if (typeof node.value === 'string' && wrong2RightWordsMap[wrongWords[i]].regexp.test(node.value)) { | ||
return wrongWords[i]; | ||
const wrongWord = wrongWords[i]; | ||
const regexp = wrong2RightWordsMap[wrongWord].regexp; | ||
if (typeof node.value === 'string' && !isIgnored(wrongWord) && regexp.test(node.value)) { | ||
return wrongWord; | ||
} | ||
@@ -145,0 +172,0 @@ } |
{ | ||
"name": "eslint-plugin-youzan", | ||
"version": "0.2.0", | ||
"version": "0.3.0-beta1", | ||
"description": "Eslint plugin for youzan", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -46,3 +46,3 @@ # eslint-plugin-youzan | ||
* [youzan/wsc-standard-words](https://github.com/youzan/eslint-plugin-youzan/blob/master/docs/rules/wsc-standard-words.md) | ||
* [youzan/wsc-standard-words](https://github.com/youzan/eslint-plugin-youzan/blob/master/docs/rules/youzan-standard-words.md) | ||
@@ -49,0 +49,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
51979
7
1559
2