Skip to content

Commit b392497

Browse files
committed
Fix of production code with decreased coverage
1 parent e2c3497 commit b392497

File tree

5 files changed

+7
-18
lines changed

5 files changed

+7
-18
lines changed

lib/rules/jsx-curly-spacing.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,9 @@ module.exports = {
373373

374374
const sourceCode = context.getSourceCode();
375375
// @ts-expect-error The types differ between ASTNode and ESTree.Node.
376-
const first = sourceCode.getFirstToken(node);
376+
const first = /** @type {import("eslint").AST.Token} */(sourceCode.getFirstToken(node));
377377
// @ts-expect-error The types differ between ASTNode and ESTree.Node.
378-
const last = sourceCode.getLastToken(node);
378+
const last = /** @type {import("eslint").AST.Token} */(sourceCode.getLastToken(node));
379379
let second = sourceCode.getTokenAfter(first, { includeComments: true });
380380
let penultimate = sourceCode.getTokenBefore(last, { includeComments: true });
381381

@@ -389,9 +389,6 @@ module.exports = {
389389
const trailingComments = sourceCode.getNodeByRangeIndex(penultimate.range[0]).trailingComments;
390390
penultimate = trailingComments ? trailingComments[trailingComments.length - 1] : penultimate;
391391
}
392-
if (first.type !== 'Punctuator' || last.type !== 'Punctuator') {
393-
return;
394-
}
395392

396393
const isObjectLiteral = first.value === second.value;
397394
const spacing = isObjectLiteral ? config.objectLiteralSpaces : config.when;

lib/rules/jsx-equals-spacing.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ module.exports = {
6161
}
6262

6363
const sourceCode = context.getSourceCode();
64-
const equalToken = sourceCode.getTokenAfter(attrNode.name);
65-
if (equalToken.type !== 'Punctuator') {
66-
return;
67-
}
64+
const equalToken = /** @type {import("eslint").AST.Token} */ (sourceCode.getTokenAfter(attrNode.name));
6865
const spacedBefore = sourceCode.isSpaceBetweenTokens(attrNode.name, equalToken);
6966
const spacedAfter = sourceCode.isSpaceBetweenTokens(equalToken, attrNode.value);
7067

lib/rules/jsx-space-before-closing.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,12 @@ module.exports = {
5858
const sourceCode = context.getSourceCode();
5959

6060
const leftToken = getTokenBeforeClosingBracket(node);
61-
const closingSlash = sourceCode.getTokenAfter(leftToken);
61+
const closingSlash = /** @type {import("eslint").AST.Token} */ (sourceCode.getTokenAfter(leftToken));
6262

6363
if (leftToken.loc.end.line !== closingSlash.loc.start.line) {
6464
return;
6565
}
6666

67-
if (closingSlash.type !== 'Punctuator') {
68-
return;
69-
}
70-
7167
if (configuration === 'always' && !sourceCode.isSpaceBetweenTokens(leftToken, closingSlash)) {
7268
report(context, messages.needSpaceBeforeClose, 'needSpaceBeforeClose', {
7369
loc: closingSlash.loc.start,

lib/rules/no-deprecated.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ module.exports = {
226226
if (!isReactImport) {
227227
return;
228228
}
229-
node.specifiers.filter(((s) => s.type === 'ImportSpecifier' && s.imported)).forEach((specifier) => {
230-
if (specifier.type !== 'ImportSpecifier') {
229+
node.specifiers.forEach((specifier) => {
230+
if (specifier.type !== 'ImportSpecifier' || !specifier.imported) {
231231
return;
232232
}
233233
checkDeprecation(node, `${MODULES[node.source.value][0]}.${specifier.imported.name}`, specifier);

lib/rules/no-unused-class-component-methods.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,8 @@ module.exports = {
247247
// detect `{ foo, bar: baz } = this`
248248
if (node.init && isThisExpression(node.init) && node.id.type === 'ObjectPattern') {
249249
node.id.properties
250-
.filter((prop) => prop.type === 'Property' && isKeyLiteralLike(prop, prop.key))
251250
.forEach((prop) => {
252-
if (prop.type === 'RestElement') {
251+
if (prop.type === 'RestElement' || !isKeyLiteralLike(prop, prop.key)) {
253252
return;
254253
}
255254
addUsedProperty(prop.key);

0 commit comments

Comments
 (0)