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

eslint-plugin-community

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-community - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

16

docs/rules/no-race-names.md

@@ -13,4 +13,13 @@ # Discourage using common inclusion/exclusion terms that may relate to race (no-race-names)

```js
// list inclusion/exclusion
let allowList = ["zelda", "link"];
let denyList = ["ganon", "ganondorf"];
// master/slave
let master = "server1";
let masterNode = "server1";
let _master = "server1";
let slave = "server2";
let slaveServer = "server2";
let slave_set = ["server2", "server3"];
```

@@ -21,4 +30,11 @@

```js
// list inclusion/exclusion
let whiteList = ["zelda", "link"];
let blackList = ["ganon", "ganondorf"];
// primary/replica
let primary = "server1";
let primaryNode = "server1";
let replica = "server2";
let replica_set = ["server2", "server3"];
```

@@ -25,0 +41,0 @@

39

lib/rules/no-race-names.js

@@ -13,3 +13,5 @@ 'use strict';

avoidWhitelist: 'Variable `{{ name }}` should not contain `whitelist`',
avoidBlacklist: 'Variable `{{ name }}` should not contain `blacklist`'
avoidBlacklist: 'Variable `{{ name }}` should not contain `blacklist`',
avoidMaster: 'Variable `{{ name }}` should not be `master`',
avoidSlave: 'Variable `{{ name }}` should not be `slave`'
},

@@ -53,2 +55,37 @@ fixable: 'code'

}
match = /^(_*)master((?:_*)(?:node|server|set|service|client))?(s?)$/i.exec(node.name);
if (match) {
const matchOffset = token.start + match.index;
context.report({
node,
messageId: 'avoidMaster',
data: { name: node.name },
fix: ({ replaceTextRange }) => {
const isPlural = !!match[3];
const prefix = match[1] || '';
const replacement = match[2]
? `${prefix}primary${match[2]}${match[3] || ''}`
: isPlural
? `${prefix}primaries`
: `${prefix}primary`;
return replaceTextRange([matchOffset, matchOffset + match[0].length], replacement);
}
});
}
match = /^(_*)slave((?:_*)(?:node|server|set|service|client))?(s?)$/i.exec(node.name);
if (match) {
const matchOffset = token.start + match.index;
context.report({
node,
messageId: 'avoidSlave',
data: { name: node.name },
fix: ({ replaceTextRange }) => {
return replaceTextRange(
[matchOffset, matchOffset + match[0].length],
`${match[1] || ''}replica${match[2] || ''}${match[3] || ''}`
);
}
});
}
}

@@ -55,0 +92,0 @@ };

{
"name": "eslint-plugin-community",
"version": "0.1.0",
"version": "0.1.1",
"description": "Rules that promote community and inclusiveness in code",
"keywords": ["eslint", "eslintplugin", "eslint-plugin"],
"author": "tzellman",
"keywords": [
"eslint",
"eslintplugin",
"eslint-plugin",
"community",
"inclusiveness"
],
"author": "tzellman <tzellman@gmail.com>",
"repository": "git@github.com:tzellman/eslint-plugin-community.git",
"main": "lib/index.js",

@@ -46,4 +53,15 @@ "scripts": {

"verbose": true,
"watchPlugins": ["jest-runner-eslint/watch-fix"]
"watchPlugins": ["jest-runner-eslint/watch-fix"],
"collectCoverage": true,
"coveragePathIgnorePatterns": ["/node_modules/", "/tests/"],
"coverageReporters": ["json", "lcov", "text", "text-summary"],
"coverageThreshold": {
"global": {
"branches": 100,
"functions": 100,
"lines": 100,
"statements": 100
}
}
}
}

@@ -18,3 +18,7 @@ 'use strict';

'var black = "000"',
'var banList = ["ganon", "ganondorf"]'
'var banList = ["ganon", "ganondorf"]',
'var primary',
'let replica',
'let masterOfTheUniverse',
'let slavesBandWebpage = "https://www.slavesband.com/"'
],

@@ -97,4 +101,99 @@

output: 'var denylist, allowlist'
},
{
code: 'var master',
errors: [{ messageId: 'avoidMaster' }],
output: 'var primary'
},
{
code: 'var _master',
errors: [{ messageId: 'avoidMaster' }],
output: 'var _primary'
},
{
code: 'var masters = []',
errors: [{ messageId: 'avoidMaster' }],
output: 'var primaries = []'
},
{
code: 'let masterNode = "server1"',
errors: [{ messageId: 'avoidMaster' }],
output: 'let primaryNode = "server1"'
},
{
code: 'let masterServer = "server1"',
errors: [{ messageId: 'avoidMaster' }],
output: 'let primaryServer = "server1"'
},
{
code: 'let master_server = "server1"',
errors: [{ messageId: 'avoidMaster' }],
output: 'let primary_server = "server1"'
},
{
code: 'let masterServers = []',
errors: [{ messageId: 'avoidMaster' }],
output: 'let primaryServers = []'
},
{
code: 'let masterSets = []',
errors: [{ messageId: 'avoidMaster' }],
output: 'let primarySets = []'
},
{
code: 'let master_sets = []',
errors: [{ messageId: 'avoidMaster' }],
output: 'let primary_sets = []'
},
{
code: 'let master___clients = []',
errors: [{ messageId: 'avoidMaster' }],
output: 'let primary___clients = []'
},
{
code: 'var slave',
errors: [{ messageId: 'avoidSlave' }],
output: 'var replica'
},
{
code: 'var __slave',
errors: [{ messageId: 'avoidSlave' }],
output: 'var __replica'
},
{
code: 'var slaves = []',
errors: [{ messageId: 'avoidSlave' }],
output: 'var replicas = []'
},
{
code: 'var slaveNodes = []',
errors: [{ messageId: 'avoidSlave' }],
output: 'var replicaNodes = []'
},
{
code: 'var slaveSet = []',
errors: [{ messageId: 'avoidSlave' }],
output: 'var replicaSet = []'
},
{
code: 'var slave_set = []',
errors: [{ messageId: 'avoidSlave' }],
output: 'var replica_set = []'
},
{
code: 'var slaveServers = []',
errors: [{ messageId: 'avoidSlave' }],
output: 'var replicaServers = []'
},
{
code: 'var slave_Servers = []',
errors: [{ messageId: 'avoidSlave' }],
output: 'var replica_Servers = []'
},
{
code: 'var slaveServices = []',
errors: [{ messageId: 'avoidSlave' }],
output: 'var replicaServices = []'
}
]
});
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