Skip to content

Commit

Permalink
Delete Spaces and fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
y-hsgw committed Apr 10, 2024
1 parent 32d4165 commit 9018532
Show file tree
Hide file tree
Showing 30 changed files with 86 additions and 86 deletions.
6 changes: 3 additions & 3 deletions lib/rules/button-has-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const messages = {
forbiddenValue: '"{{value}}" is an invalid value for button type attribute',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down Expand Up @@ -151,10 +151,10 @@ module.exports = {

const props = node.arguments[1].properties;
const typeProp = props.find(
(prop) => prop.type === "Property" && prop.key && prop.key.type === "PrivateIdentifier" && prop.key.name === 'type'
(prop) => prop.type === 'Property' && prop.key && prop.key.type === 'PrivateIdentifier' && prop.key.name === 'type'
);

if (typeProp.type !== "Property") {
if (typeProp.type !== 'Property') {
reportMissing(node);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/checked-requires-onchange-or-readonly.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function extractTargetProps(properties, keyName) {
);
}

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/forbid-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const messages = {
forbiddenElement_message: '<{{element}}> is forbidden, {{message}}',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/forbid-foreign-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const messages = {
forbiddenPropType: 'Using propTypes from another component is not safe because they may be removed in production builds',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down Expand Up @@ -123,7 +123,7 @@ module.exports = {

ObjectPattern(node) {
const propTypesNode = node.properties.find(
(property) => property.type === 'Property' && property.key.type === "PrivateIdentifier" && property.key.name === 'propTypes'
(property) => property.type === 'Property' && property.key.type === 'PrivateIdentifier' && property.key.name === 'propTypes'
);

if (propTypesNode) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/forbid-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const messages = {
forbiddenPropType: 'Prop type "{{target}}" is forbidden',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/hook-use-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const messages = {
suggestMemo: 'Replace useState call with useMemo',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-closing-bracket-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const messages = {
bracketLocation: 'The closing bracket must be {{location}}{{details}}',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-curly-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const messages = {
spaceNeededBefore: 'A space is required before \'{{token}}\'',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-equals-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const messages = {
needSpaceAfter: 'A space is required after \'=\'',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-fragments.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const messages = {
preferFragment: 'Prefer fragment shorthand over {{react}}.{{fragment}}',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down Expand Up @@ -172,7 +172,7 @@ module.exports = {
ImportDeclaration(node) {
if (node.source && node.source.value === 'react') {
node.specifiers.forEach((spec) => {
if (spec.type === "ImportSpecifier" && spec.imported && spec.imported.name === fragmentPragma) {
if (spec.type === 'ImportSpecifier' && spec.imported && spec.imported.name === fragmentPragma) {
if (spec.local) {
fragmentNames.add(spec.local.name);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-indent-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const messages = {
wrongIndent: 'Expected indentation of {{needed}} {{type}} {{characters}} but found {{gotten}}.',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const messages = {
wrongIndent: 'Expected indentation of {{needed}} {{type}} {{characters}} but found {{gotten}}.',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-no-bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const messages = {
func: 'JSX props should not use functions',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down Expand Up @@ -175,7 +175,7 @@ module.exports = {
if (
blockAncestors.length > 0
&& variableViolationType
&& node.parent.type === "VariableDeclaration"
&& node.parent.type === 'VariableDeclaration'
&& node.parent.kind === 'const' // only support const right now
&& node.id.type === 'Identifier'
) {
Expand Down
10 changes: 5 additions & 5 deletions lib/rules/jsx-sort-default-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const messages = {
propsNotSorted: 'Default prop types declarations should be sorted alphabetically',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
deprecated: true,
Expand Down Expand Up @@ -174,11 +174,11 @@ module.exports = {
}

if (
node.parent.type !== "BinaryExpression"
&& node.parent.type !== "AssignmentExpression"
&& node.parent.type !== "LogicalExpression"
node.parent.type !== 'BinaryExpression'
&& node.parent.type !== 'AssignmentExpression'
&& node.parent.type !== 'LogicalExpression'
) {
return
return;
}

checkNode(node.parent.right);
Expand Down
24 changes: 12 additions & 12 deletions lib/rules/jsx-space-before-closing.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const messages = {
needSpaceBeforeClose: 'A space is required before closing bracket',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
deprecated: true,
Expand Down Expand Up @@ -65,18 +65,18 @@ module.exports = {
}

if (
closingSlash.type !== "Boolean"
&& closingSlash.type !== "Null"
&& closingSlash.type !== "Identifier"
&& closingSlash.type !== "Keyword"
&& closingSlash.type !== "Punctuator"
&& closingSlash.type !== "JSXIdentifier"
&& closingSlash.type !== "JSXText"
&& closingSlash.type !== "Numeric"
&& closingSlash.type !== "String"
&& closingSlash.type !== "RegularExpression"
closingSlash.type !== 'Boolean'
&& closingSlash.type !== 'Null'
&& closingSlash.type !== 'Identifier'
&& closingSlash.type !== 'Keyword'
&& closingSlash.type !== 'Punctuator'
&& closingSlash.type !== 'JSXIdentifier'
&& closingSlash.type !== 'JSXText'
&& closingSlash.type !== 'Numeric'
&& closingSlash.type !== 'String'
&& closingSlash.type !== 'RegularExpression'
) {
return
return;
}

if (configuration === 'always' && !sourceCode.isSpaceBetweenTokens(leftToken, closingSlash)) {
Expand Down
14 changes: 7 additions & 7 deletions lib/rules/no-access-state-in-setstate.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const messages = {
useCallback: 'Use callback in setState when referencing the previous state.',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down Expand Up @@ -65,10 +65,10 @@ module.exports = {
// Appends all the methods that are calling another
// method containing this.state to the methods array
methods.forEach((method) => {
if (node.callee.type === "Identifier" && node.callee.name === method.methodName) {
if (node.callee.type === 'Identifier' && node.callee.name === method.methodName) {
let current = node.parent;
while (current.type !== 'Program') {
if (current.type === 'MethodDefinition' && current.key.type === "PrivateIdentifier") {
if (current.type === 'MethodDefinition' && current.key.type === 'Identifier') {
methods.push({
methodName: current.key.name,
node: method.node,
Expand All @@ -84,7 +84,7 @@ module.exports = {
// to further check if they contains this.state
let current = node.parent;
while (current.type !== 'Program') {
if (isFirstArgumentInSetStateCall(current, node) && node.callee.type === "Identifier") {
if (isFirstArgumentInSetStateCall(current, node) && node.callee.type === 'Identifier') {
const methodName = node.callee.name;
methods.forEach((method) => {
if (method.methodName === methodName) {
Expand All @@ -102,7 +102,7 @@ module.exports = {

MemberExpression(node) {
if (
node.property.type === "PrivateIdentifier"
node.property.type === 'PrivateIdentifier'
&& node.property.name === 'state'
&& node.object.type === 'ThisExpression'
&& isClassComponent()
Expand Down Expand Up @@ -186,9 +186,9 @@ module.exports = {
},

ObjectPattern(node) {
const isDerivedFromThis = (node.parent.type === "ForStatement" || node.parent.type === "VariableDeclarator") && node.parent.init && node.parent.init.type === 'ThisExpression';
const isDerivedFromThis = (node.parent.type === 'ForStatement' || node.parent.type === 'VariableDeclarator') && node.parent.init && node.parent.init.type === 'ThisExpression';
node.properties.forEach((property) => {
if (property.type === "Property" && (property.key.type === "PrivateIdentifier" || property.key.type === "Identifier") && property.key.name === 'state' && isDerivedFromThis) {
if (property.type === 'Property' && (property.key.type === 'PrivateIdentifier' || property.key.type === 'Identifier') && property.key.name === 'state' && isDerivedFromThis) {
vars.push({
node: property.key,
scope: context.getScope(),
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/no-adjacent-inline-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const messages = {
inlineElement: 'Child elements which render as inline HTML elements should be separated by a space or wrapped in block level elements.',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down Expand Up @@ -118,8 +118,8 @@ module.exports = {
if (node.arguments.length < 2 || !node.arguments[2]) {
return;
}
if(node.arguments[2].type !== "ArrayExpression") {
return
if (node.arguments[2].type !== 'ArrayExpression') {
return;
}
const children = node.arguments[2].elements;
validate(node, children);
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/no-children-prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const messages = {
passFunctionAsArgs: 'Do not pass a function as an additional argument to React.createElement. Instead, pass it as a prop.',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down Expand Up @@ -83,16 +83,16 @@ module.exports = {
});
},
CallExpression(node) {
if (!isCreateElementWithProps(node, context) || node.arguments[1].type !== "ObjectExpression") {
if (!isCreateElementWithProps(node, context) || node.arguments[1].type !== 'ObjectExpression') {
return;
}

const props = node.arguments[1].properties;
const childrenProp = props.find(
(prop) => prop.type === "Property" && (prop.key.type === "PrivateIdentifier" || prop.key.type === "Identifier") && prop.key.name === 'children'
(prop) => prop.type === 'Property' && (prop.key.type === 'PrivateIdentifier' || prop.key.type === 'Identifier') && prop.key.name === 'children'
);

if (childrenProp.type === "Property") {
if (childrenProp.type === 'Property') {
if (childrenProp.value && !isFunction(childrenProp.value)) {
report(context, messages.passChildrenAsArgs, 'passChildrenAsArgs', {
node,
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-danger-with-children.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const messages = {
dangerWithChildren: 'Only set one of `children` or `props.dangerouslySetInnerHTML`',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down Expand Up @@ -120,7 +120,7 @@ module.exports = {
if (
node.callee
&& node.callee.type === 'MemberExpression'
&& node.callee.property.type === "Identifier"
&& node.callee.property.type === 'Identifier'
&& node.callee.property.name === 'createElement'
&& node.arguments.length > 1
) {
Expand Down
20 changes: 10 additions & 10 deletions lib/rules/no-deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const messages = {
deprecated: '{{oldMethod}} is deprecated since React {{version}}{{newMethod}}{{refs}}',
};

/** @type { import('eslint').Rule.RuleModule } */
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
docs: {
Expand Down Expand Up @@ -226,9 +226,9 @@ module.exports = {
if (!isReactImport) {
return;
}
node.specifiers.filter(((s) => s.type === "ImportSpecifier" && s.imported)).forEach((specifier) => {
if(specifier.type !== "ImportSpecifier") {
return
node.specifiers.filter(((s) => s.type === 'ImportSpecifier' && s.imported)).forEach((specifier) => {
if (specifier.type !== 'ImportSpecifier') {
return;
}
checkDeprecation(node, `${MODULES[node.source.value][0]}.${specifier.imported.name}`, specifier);
});
Expand All @@ -253,15 +253,15 @@ module.exports = {
) {
return;
}
if(node.id.type !== "ObjectPattern") {
return
if (node.id.type !== 'ObjectPattern') {
return;
}
node.id.properties.filter((p) => p.type !== 'RestElement' && p.key).forEach((property) => {
if(property.type !== "Property"){
return
if (property.type !== 'Property') {
return;
}
if(property.key.type !== "Identifier" && property.key.type !== "PrivateIdentifier"){
return
if (property.key.type !== 'Identifier' && property.key.type !== 'PrivateIdentifier') {
return;
}
checkDeprecation(node, `${reactModuleName || pragma}.${property.key.name}`, property);
});
Expand Down
Loading

0 comments on commit 9018532

Please sign in to comment.