Skip to content

Commit d9a2a37

Browse files
committed
style: apply auto fixes
1 parent 0bf7612 commit d9a2a37

18 files changed

+50
-40
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"ajv": "^8.6.3",
2323
"babel-plugin-add-module-exports": "^1.0.4",
2424
"eslint": "^8.1.0",
25-
"eslint-config-canonical": "^32.1.1",
25+
"eslint-config-canonical": "^32.6.0",
2626
"eslint-plugin-eslint-plugin": "^4.0.1",
2727
"gitdown": "^3.1.4",
2828
"glob": "^7.2.0",

src/bin/addAssertions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ const formatCodeSnippet = (setup) => {
2323
paragraphs.push(setup.code);
2424

2525
if (setup.errors) {
26-
setup.errors.forEach((message) => {
26+
for (const message of setup.errors) {
2727
paragraphs.push('// Message: ' + message.message);
28-
});
28+
}
2929
}
3030

3131
if (setup.rules) {

src/bin/checkTests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
const getTestIndexRules = () => {
1111
const content = fs.readFileSync(path.resolve(__dirname, '../../tests/rules/index.js'), 'utf-8');
1212

13+
// eslint-disable-next-line unicorn/no-array-reduce
1314
const result = content.split('\n').reduce((acc, line) => {
1415
if (acc.inRulesArray) {
1516
if (line === '];') {

src/rules/defineFlowType.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ const create = (context) => {
6868
globalScope = context.getScope();
6969
},
7070
TypeParameterDeclaration (node) {
71-
node.params.forEach((param) => {
71+
for (const param of node.params) {
7272
makeDefined(param);
73-
});
73+
}
7474
},
7575
};
7676
};

src/rules/noDupeKeys.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const create = (context) => {
6868
// filter out complex object types, like ObjectTypeSpreadProperty
6969
const identifierNodes = _.filter(node.properties, {type: 'ObjectTypeProperty'});
7070

71-
_.forEach(identifierNodes, (identifierNode) => {
71+
for (const identifierNode of identifierNodes) {
7272
const needle = {name: getParameterName(identifierNode, context)};
7373

7474
if (identifierNode.value.type === 'FunctionTypeAnnotation') {
@@ -86,7 +86,7 @@ const create = (context) => {
8686
} else {
8787
haystack.push(needle);
8888
}
89-
});
89+
}
9090
};
9191

9292
return {

src/rules/noFlowFixMeComments.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const create = (context) => {
2525
const handleComment = function (comment) {
2626
const value = comment.value.trim();
2727

28-
if (value.match(/\$FlowFixMe/u) && !passesExtraRegex(value)) {
28+
if (/\$FlowFixMe/u.test(value) && !passesExtraRegex(value)) {
2929
context.report(comment, message + extraMessage);
3030
}
3131
};
@@ -41,13 +41,14 @@ const create = (context) => {
4141
},
4242

4343
Program () {
44-
context
44+
for (const comment of context
4545
.getSourceCode()
4646
.getAllComments()
47-
.filter((comment) => {
48-
return comment.type === 'Block' || comment.type === 'Line';
49-
})
50-
.forEach(handleComment);
47+
.filter((node) => {
48+
return node.type === 'Block' || node.type === 'Line';
49+
})) {
50+
handleComment(comment);
51+
}
5152
},
5253
};
5354
};

src/rules/requireInexactType.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const create = (context) => {
1212
ObjectTypeAnnotation (node) {
1313
const {inexact, exact} = node;
1414

15-
if (!node.hasOwnProperty('inexact')) {
15+
if (!Object.prototype.hasOwnProperty.call(node, 'inexact')) {
1616
return;
1717
}
1818

src/rules/requireParameterType.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const create = iterateFunctionNodes((context) => {
3838
return;
3939
}
4040

41+
// eslint-disable-next-line unicorn/no-array-for-each
4142
_.forEach(functionNode.params, (identifierNode) => {
4243
const parameterName = getParameterName(identifierNode, context);
4344

src/rules/requireReturnType.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ const create = (context) => {
4848
const annotateUndefined = _.get(context, 'options[1].annotateUndefined') || 'never';
4949
const skipArrows = _.get(context, 'options[1].excludeArrowFunctions') || false;
5050

51+
// eslint-disable-next-line unicorn/no-array-callback-reference
5152
const excludeMatching = _.get(context, 'options[1].excludeMatching', []).map(makeRegExp);
53+
// eslint-disable-next-line unicorn/no-array-callback-reference
5254
const includeOnlyMatching = _.get(context, 'options[1].includeOnlyMatching', []).map(makeRegExp);
5355

5456
const targetNodes = [];

src/rules/requireVariableType.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const create = (context) => {
4949
return;
5050
}
5151

52+
// eslint-disable-next-line unicorn/no-array-for-each
5253
_.forEach(variableDeclaration.declarations, (variableDeclarator) => {
5354
const identifierNode = _.get(variableDeclarator, 'id');
5455
const identifierName = _.get(identifierNode, 'name');

0 commit comments

Comments
 (0)