Skip to content

Commit

Permalink
Fix of production code with decreased coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
y-hsgw committed Apr 13, 2024
1 parent e2c3497 commit b392497
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 18 deletions.
7 changes: 2 additions & 5 deletions lib/rules/jsx-curly-spacing.js
Expand Up @@ -373,9 +373,9 @@ module.exports = {

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

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

const isObjectLiteral = first.value === second.value;
const spacing = isObjectLiteral ? config.objectLiteralSpaces : config.when;
Expand Down
5 changes: 1 addition & 4 deletions lib/rules/jsx-equals-spacing.js
Expand Up @@ -61,10 +61,7 @@ module.exports = {
}

const sourceCode = context.getSourceCode();
const equalToken = sourceCode.getTokenAfter(attrNode.name);
if (equalToken.type !== 'Punctuator') {
return;
}
const equalToken = /** @type {import("eslint").AST.Token} */ (sourceCode.getTokenAfter(attrNode.name));
const spacedBefore = sourceCode.isSpaceBetweenTokens(attrNode.name, equalToken);
const spacedAfter = sourceCode.isSpaceBetweenTokens(equalToken, attrNode.value);

Expand Down
6 changes: 1 addition & 5 deletions lib/rules/jsx-space-before-closing.js
Expand Up @@ -58,16 +58,12 @@ module.exports = {
const sourceCode = context.getSourceCode();

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

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

if (closingSlash.type !== 'Punctuator') {
return;
}

if (configuration === 'always' && !sourceCode.isSpaceBetweenTokens(leftToken, closingSlash)) {
report(context, messages.needSpaceBeforeClose, 'needSpaceBeforeClose', {
loc: closingSlash.loc.start,
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-deprecated.js
Expand Up @@ -226,8 +226,8 @@ module.exports = {
if (!isReactImport) {
return;
}
node.specifiers.filter(((s) => s.type === 'ImportSpecifier' && s.imported)).forEach((specifier) => {
if (specifier.type !== 'ImportSpecifier') {
node.specifiers.forEach((specifier) => {
if (specifier.type !== 'ImportSpecifier' || !specifier.imported) {
return;
}
checkDeprecation(node, `${MODULES[node.source.value][0]}.${specifier.imported.name}`, specifier);
Expand Down
3 changes: 1 addition & 2 deletions lib/rules/no-unused-class-component-methods.js
Expand Up @@ -247,9 +247,8 @@ module.exports = {
// detect `{ foo, bar: baz } = this`
if (node.init && isThisExpression(node.init) && node.id.type === 'ObjectPattern') {
node.id.properties
.filter((prop) => prop.type === 'Property' && isKeyLiteralLike(prop, prop.key))
.forEach((prop) => {
if (prop.type === 'RestElement') {
if (prop.type === 'RestElement' || !isKeyLiteralLike(prop, prop.key)) {
return;
}
addUsedProperty(prop.key);
Expand Down

0 comments on commit b392497

Please sign in to comment.