Skip to content

Commit

Permalink
no-keyword-prefix: Rename blacklist option to disallowedPrefixes (
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Apr 14, 2021
1 parent de2602e commit 91e60d0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions docs/rules/no-keyword-prefix.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ const fooNew = 'foo';

## Options

### `blacklist`
### `disallowedPrefixes`

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

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

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

Expand Down
8 changes: 4 additions & 4 deletions rules/no-keyword-prefix.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ const messages = {
};

const prepareOptions = ({
blacklist,
disallowedPrefixes,
checkProperties = true,
onlyCamelCase = true
} = {}) => {
return {
blacklist: (blacklist || [
disallowedPrefixes: (disallowedPrefixes || [
'new',
'class'
]),
Expand All @@ -23,7 +23,7 @@ const prepareOptions = ({
};

function findKeywordPrefix(name, options) {
return options.blacklist.find(keyword => {
return options.disallowedPrefixes.find(keyword => {
const suffix = options.onlyCamelCase ? '[A-Z]' : '.';
const regex = new RegExp(`^${keyword}${suffix}`);
return name.match(regex);
Expand Down Expand Up @@ -170,7 +170,7 @@ const schema = [
{
type: 'object',
properties: {
blacklist: {
disallowedPrefixes: {
type: 'array',
items: [
{
Expand Down
4 changes: 2 additions & 2 deletions test/no-keyword-prefix.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ test({
},
{
code: 'const newFoo = "foo"',
options: [{blacklist: ['old']}]
options: [{disallowedPrefixes: ['old']}]
},
outdent`
function Foo() {
Expand Down Expand Up @@ -262,7 +262,7 @@ test({
},
{
code: 'const oldFoo = "foo"',
options: [{blacklist: ['old']}],
options: [{disallowedPrefixes: ['old']}],
errors: [errorIgnoreList]
},
{
Expand Down

0 comments on commit 91e60d0

Please sign in to comment.