Skip to content

Commit d71c8b3

Browse files
authored
1 parent 5b0ce68 commit d71c8b3

17 files changed

+41
-25
lines changed

.eslintrc.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ module.exports = {
77
'not-an-aardvark/node',
88
'plugin:node/recommended',
99
'plugin:self/all',
10+
'plugin:unicorn/recommended',
1011
],
12+
parserOptions: {
13+
ecmaVersion: 2021,
14+
sourceType: 'script',
15+
},
1116
rules: {
1217
'comma-dangle': [
1318
'error',
@@ -22,6 +27,14 @@ module.exports = {
2227
'self/meta-property-ordering': 'off',
2328
'self/require-meta-docs-url': 'off',
2429
'self/report-message-format': ['error', '^[^a-z].*.$'],
30+
31+
'unicorn/consistent-function-scoping': 'off',
32+
'unicorn/no-array-callback-reference': 'off',
33+
'unicorn/no-array-for-each': 'off',
34+
'unicorn/no-array-reduce': 'off',
35+
'unicorn/no-null': 'off',
36+
'unicorn/prefer-module': 'off',
37+
'unicorn/prevent-abbreviations': 'off',
2538
},
2639
overrides: [
2740
{

lib/rules/consistent-output.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module.exports = {
3939
utils.getTestInfo(context, ast).forEach(testRun => {
4040
const readableCases = testRun.invalid.filter(testCase => testCase.type === 'ObjectExpression');
4141
const casesWithoutOutput = readableCases
42-
.filter(testCase => testCase.properties.map(utils.getKeyName).indexOf('output') === -1);
42+
.filter(testCase => !testCase.properties.map(utils.getKeyName).includes('output'));
4343

4444
if (
4545
(casesWithoutOutput.length < readableCases.length) ||

lib/rules/meta-property-ordering.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = {
5151
const violatingProps = props.filter(prop => {
5252
const curr = orderMap.has(getKeyName(prop))
5353
? orderMap.get(getKeyName(prop))
54-
: Infinity;
54+
: Number.POSITIVE_INFINITY;
5555
return last > (last = curr);
5656
});
5757

lib/rules/no-deprecated-context-methods.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module.exports = {
5555

5656
return {
5757
'Program:exit' () {
58-
Array.from(utils.getContextIdentifiers(context, sourceCode.ast))
58+
[...utils.getContextIdentifiers(context, sourceCode.ast)]
5959
.filter(
6060
contextId =>
6161
contextId.parent.type === 'MemberExpression' &&

lib/rules/no-identical-tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ module.exports = {
6060
propertiesSetA.add(code);
6161
});
6262

63-
for (let i = 0; i < propertiesB.length; i++) {
64-
const code = sourceCode.getText(propertiesB[i]);
63+
for (const element of propertiesB) {
64+
const code = sourceCode.getText(element);
6565
if (!propertiesSetA.has(code)) {
6666
return false;
6767
}

lib/rules/no-missing-placeholders.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module.exports = {
5656
) {
5757
// Same regex as the one ESLint uses
5858
// https://github.com/eslint/eslint/blob/e5446449d93668ccbdb79d78cc69f165ce4fde07/lib/eslint.js#L990
59-
const PLACEHOLDER_MATCHER = /\{\{\s*([^{}]+?)\s*\}\}/g;
59+
const PLACEHOLDER_MATCHER = /{{\s*([^{}]+?)\s*}}/g;
6060
let match;
6161

6262
while ((match = PLACEHOLDER_MATCHER.exec(reportInfo.message.value || messageStaticValue.value))) { // eslint-disable-line no-extra-parens

lib/rules/no-unused-placeholders.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ module.exports = {
5757
) {
5858
const message = reportInfo.message.value || messageStaticValue.value;
5959
// https://github.com/eslint/eslint/blob/2874d75ed8decf363006db25aac2d5f8991bd969/lib/linter.js#L986
60-
const PLACEHOLDER_MATCHER = /\{\{\s*([^{}]+?)\s*\}\}/g;
60+
const PLACEHOLDER_MATCHER = /{{\s*([^{}]+?)\s*}}/g;
6161
const placeholdersInMessage = new Set();
6262

6363
message.replace(PLACEHOLDER_MATCHER, (fullMatch, term) => {

lib/rules/no-useless-token-range.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ module.exports = {
103103

104104
return {
105105
'Program:exit' (ast) {
106-
Array.from(utils.getSourceCodeIdentifiers(context, ast))
106+
[...utils.getSourceCodeIdentifiers(context, ast)]
107107
.filter(identifier => identifier.parent.type === 'MemberExpression' &&
108108
identifier.parent.object === identifier &&
109109
identifier.parent.property.type === 'Identifier' &&

lib/rules/prefer-output-null.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module.exports = {
4343
function getTestInfo (key) {
4444
if (test.type === 'ObjectExpression') {
4545
const res = test.properties.filter(item => item.key.name === key);
46-
return res.length ? res[res.length - 1] : null;
46+
return res.length > 0 ? res[res.length - 1] : null;
4747
}
4848
return key === 'code' ? test : null;
4949
}

lib/rules/prefer-placeholders.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module.exports = {
7575
}
7676

7777
if (
78-
(messageNode.type === 'TemplateLiteral' && messageNode.expressions.length) ||
78+
(messageNode.type === 'TemplateLiteral' && messageNode.expressions.length > 0) ||
7979
(messageNode.type === 'BinaryExpression' && messageNode.operator === '+')
8080
) {
8181
context.report({

0 commit comments

Comments
 (0)