Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-youzan

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-youzan - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0-beta1

package-lock.json

14

docs/rules/youzan-standard-words.md

@@ -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)

33

lib/rules/youzan-standard-words.js

@@ -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 @@ }

2

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc