Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed May 7, 2024
1 parent b4e901e commit fc1f19a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions rules/prefer-array-flat.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const arrayFlatMap = {
},
getArrayNode: node => node.callee.object,
description: 'Array#flatMap()',
recommended: true,
recommended: true,
};

// `array.reduce((a, b) => a.concat(b), [])`
Expand Down Expand Up @@ -100,7 +100,7 @@ const arrayReduce = {
},
getArrayNode: node => node.callee.object,
description: 'Array#reduce()',
recommended: true,
recommended: true,
};

// `[].concat(maybeArray)`
Expand All @@ -121,7 +121,7 @@ const emptyArrayConcat = {
return argumentNode.type === 'SpreadElement' ? argumentNode.argument : argumentNode;
},
description: '[].concat()',
recommended: true,
recommended: true,
shouldSwitchToArray: node => node.arguments[0].type !== 'SpreadElement',
};

Expand Down Expand Up @@ -157,7 +157,7 @@ const arrayPrototypeConcat = {
return argumentNode.type === 'SpreadElement' ? argumentNode.argument : argumentNode;
},
description: 'Array.prototype.concat()',
recommended: true,
recommended: true,
shouldSwitchToArray: node => node.arguments[1].type !== 'SpreadElement' && node.callee.property.name === 'call',
};

Expand Down
2 changes: 1 addition & 1 deletion rules/prefer-modern-math-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const create = context => {
data: {
replacement: `Math.${replacementMethod}(…)`,
description: 'Math.sqrt(…)',
recommended: true,
recommended: true,
},
* fix(fixer) {
const {sourceCode} = context;
Expand Down
2 changes: 1 addition & 1 deletion rules/prefer-structured-clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const create = context => {
messageId: MESSAGE_ID_ERROR,
data: {
description: 'JSON.parse(JSON.stringify(…))',
recommended: true,
recommended: true,
},
suggest: [
{
Expand Down
8 changes: 4 additions & 4 deletions test/package.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,20 @@ test('flat configs', t => {
);
});

test('rule.meta.docs.recommended should be synchronized with presets', (t) => {
test('rule.meta.docs.recommended should be synchronized with presets', t => {
for (const [name, rule] of Object.entries(eslintPluginUnicorn.rules)) {
if (deprecatedRules.includes(name)) {
continue;
}

const recommended = rule.meta.docs.recommended;
const {recommended} = rule.meta.docs;
t.is(typeof recommended, 'boolean', `meta.docs.recommended in '${name}' rule should be a boolean.`);

const severity = eslintPluginUnicorn.configs.recommended.rules[`unicorn/${name}`];
if (recommended) {
t.is(severity, 'error', `'${name}' rule should set to 'error'.`)
t.is(severity, 'error', `'${name}' rule should set to 'error'.`);
} else {
t.is(severity, 'off', `'${name}' rule should set to 'off'.`)
t.is(severity, 'off', `'${name}' rule should set to 'off'.`);
}
}
});

0 comments on commit fc1f19a

Please sign in to comment.