Skip to content

Commit e703984

Browse files
committed
fix: apply style fixes
1 parent d9a2a37 commit e703984

26 files changed

+123
-101
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"ajv": "^8.6.3",
2323
"babel-plugin-add-module-exports": "^1.0.4",
2424
"eslint": "^8.1.0",
25-
"eslint-config-canonical": "^32.6.0",
26-
"eslint-plugin-eslint-plugin": "^4.0.1",
25+
"eslint-config-canonical": "^32.10.0",
26+
"eslint-plugin-eslint-plugin": "^4.0.2",
2727
"gitdown": "^3.1.4",
2828
"glob": "^7.2.0",
2929
"husky": "^7.0.4",

src/bin/checkDocs.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ const getDocIndexRules = () => {
2727

2828
if (match === null) {
2929
return null;
30-
} else {
31-
return match[1].replace('./rules/', '').replace('.md', '');
3230
}
33-
}).filter((rule) => {
34-
return rule !== null;
35-
});
31+
32+
return match[1].replace('./rules/', '').replace('.md', '');
33+
})
34+
.filter((rule) => {
35+
return rule !== null;
36+
});
3637

3738
if (rules.length === 0) {
3839
throw new Error('Docs checker is broken - it could not extract rules from docs index file.');
@@ -48,9 +49,9 @@ const hasCorrectAssertions = (docPath, name) => {
4849

4950
if (match === null) {
5051
return false;
51-
} else {
52-
return match[1] === name;
5352
}
53+
54+
return match[1] === name;
5455
};
5556

5657
/**

src/bin/checkTests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const getTestIndexRules = () => {
2828
rules: [],
2929
});
3030

31-
const rules = result.rules;
31+
const {rules} = result;
3232

3333
if (rules.length === 0) {
3434
throw new Error('Tests checker is broken - it could not extract rules from test index file.');

src/rules/arrayStyle/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ const inlineType = (type) => {
1313

1414
if (inlined.length <= 50) {
1515
return inlined;
16-
} else {
17-
return 'Type';
1816
}
17+
18+
return 'Type';
1919
};
2020

2121
export default (defaultConfig, simpleType) => {
@@ -64,9 +64,9 @@ export default (defaultConfig, simpleType) => {
6464
fix (fixer) {
6565
if (needWrap(elementTypeNode)) {
6666
return fixer.replaceText(node, '(' + rawElementType + ')[]');
67-
} else {
68-
return fixer.replaceText(node, rawElementType + '[]');
6967
}
68+
69+
return fixer.replaceText(node, rawElementType + '[]');
7070
},
7171
message: 'Use "{{ wrappedType }}[]", not "Array<{{ type }}>"',
7272
node,

src/rules/interfaceIdMatch.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ const create = (context) => {
1111
const interfaceIdentifierName = interfaceDeclarationNode.id.name;
1212

1313
if (!pattern.test(interfaceIdentifierName)) {
14-
context.report(interfaceDeclarationNode, 'Interface identifier \'{{name}}\' does not match pattern \'{{pattern}}\'.', {
14+
context.report({data: {
1515
name: interfaceIdentifierName,
1616
pattern: pattern.toString(),
17-
});
17+
},
18+
message: 'Interface identifier \'{{name}}\' does not match pattern \'{{pattern}}\'.',
19+
node: interfaceDeclarationNode});
1820
}
1921
};
2022

src/rules/newlineAfterFlowAnnotation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ const create = (context) => {
2222
const sourceCode = context.getSourceCode();
2323

2424
const potentialFlowFileAnnotation = _.find(
25-
context.getAllComments(),
25+
context.getSourceCode().getAllComments(),
2626
(comment) => {
2727
return looksLikeFlowFileAnnotation(comment.value);
2828
},
2929
);
3030

3131
if (potentialFlowFileAnnotation) {
32-
const line = potentialFlowFileAnnotation.loc.end.line;
32+
const {line} = potentialFlowFileAnnotation.loc.end;
3333
const nextLineIsEmpty = sourceCode.lines[line] === '';
3434

3535
if (!never && !nextLineIsEmpty) {

src/rules/noFlowFixMeComments.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ const create = (context) => {
2626
const value = comment.value.trim();
2727

2828
if (/\$FlowFixMe/u.test(value) && !passesExtraRegex(value)) {
29-
context.report(comment, message + extraMessage);
29+
context.report({
30+
message: message + extraMessage,
31+
node: comment,
32+
});
3033
}
3134
};
3235

src/rules/noMutableArray.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ const isEmptyArrayLiteral = (node) => {
1111
const isEmptyArrayInstance = (node) => {
1212
if (_.get(node, 'init.type') === 'NewExpression' || _.get(node, 'init.type') === 'CallExpression') {
1313
return _.get(node, 'init.callee.name') === 'Array' && _.get(node, 'init.arguments.length') === 0;
14-
} else {
15-
return false;
1614
}
15+
16+
return false;
1717
};
1818

1919
const isAnnotationOfEmptyArrayInit = (node) => {
@@ -22,9 +22,9 @@ const isAnnotationOfEmptyArrayInit = (node) => {
2222
const isVariableDeclaration = _.get(parent, 'type') === 'VariableDeclarator';
2323

2424
return isVariableDeclaration && (isEmptyArrayLiteral(parent) || isEmptyArrayInstance(parent));
25-
} else {
26-
return false;
2725
}
26+
27+
return false;
2828
};
2929

3030
const create = (context) => {

src/rules/noTypesMissingFileAnnotation.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const create = (context) => {
3333
if (node.importKind === 'type') {
3434
reporter(node, 'imports');
3535
}
36+
3637
if (node.importKind === 'value' &&
3738
node.specifiers.some((specifier) => {
3839
return specifier.importKind === 'type';

src/rules/noUnusedExpressions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77

88
const noUnusedExpressionsRule = getBuiltinRule('no-unused-expressions');
99

10-
const meta = noUnusedExpressionsRule.meta;
10+
const {meta} = noUnusedExpressionsRule;
1111

1212
const create = (context) => {
1313
const coreChecks = noUnusedExpressionsRule.create(context);
@@ -20,6 +20,7 @@ const create = (context) => {
2020
) {
2121
return;
2222
}
23+
2324
// eslint-disable-next-line @babel/new-cap
2425
coreChecks.ExpressionStatement(node);
2526
},

0 commit comments

Comments
 (0)