Skip to content

Commit 91e60d0

Browse files
authored
no-keyword-prefix: Rename blacklist option to disallowedPrefixes (#1180)
1 parent de2602e commit 91e60d0

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

docs/rules/no-keyword-prefix.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ const fooNew = 'foo';
2222

2323
## Options
2424

25-
### `blacklist`
25+
### `disallowedPrefixes`
2626

27-
If you want a custom list of forbidden prefixes you can set them with `blacklist`:
27+
If you want a custom list of forbidden prefixes you can set them with `disallowedPrefixes`:
2828

2929
```js
30-
// eslint unicorn/no-keyword-prefix: ["error", {"blacklist": ["new", "for"]}]
30+
// eslint unicorn/no-keyword-prefix: ["error", {"disallowedPrefixes": ["new", "for"]}]
3131
const classFoo = "a"; // pass
3232

33-
// eslint unicorn/no-keyword-prefix: ["error", {"blacklist": ["new", "for"]}]
33+
// eslint unicorn/no-keyword-prefix: ["error", {"disallowedPrefixes": ["new", "for"]}]
3434
const forFoo = "a"; // fail
3535
```
3636

rules/no-keyword-prefix.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ const messages = {
88
};
99

1010
const prepareOptions = ({
11-
blacklist,
11+
disallowedPrefixes,
1212
checkProperties = true,
1313
onlyCamelCase = true
1414
} = {}) => {
1515
return {
16-
blacklist: (blacklist || [
16+
disallowedPrefixes: (disallowedPrefixes || [
1717
'new',
1818
'class'
1919
]),
@@ -23,7 +23,7 @@ const prepareOptions = ({
2323
};
2424

2525
function findKeywordPrefix(name, options) {
26-
return options.blacklist.find(keyword => {
26+
return options.disallowedPrefixes.find(keyword => {
2727
const suffix = options.onlyCamelCase ? '[A-Z]' : '.';
2828
const regex = new RegExp(`^${keyword}${suffix}`);
2929
return name.match(regex);
@@ -170,7 +170,7 @@ const schema = [
170170
{
171171
type: 'object',
172172
properties: {
173-
blacklist: {
173+
disallowedPrefixes: {
174174
type: 'array',
175175
items: [
176176
{

test/no-keyword-prefix.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ test({
8787
},
8888
{
8989
code: 'const newFoo = "foo"',
90-
options: [{blacklist: ['old']}]
90+
options: [{disallowedPrefixes: ['old']}]
9191
},
9292
outdent`
9393
function Foo() {
@@ -262,7 +262,7 @@ test({
262262
},
263263
{
264264
code: 'const oldFoo = "foo"',
265-
options: [{blacklist: ['old']}],
265+
options: [{disallowedPrefixes: ['old']}],
266266
errors: [errorIgnoreList]
267267
},
268268
{

0 commit comments

Comments
 (0)