Skip to content

Commit

Permalink
Update xo to v0.48.0 (#1735)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored Feb 17, 2022
1 parent 40b6f05 commit e6de810
Show file tree
Hide file tree
Showing 34 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"outdent": "^0.8.0",
"typescript": "^4.5.4",
"vue-eslint-parser": "^8.0.1",
"xo": "^0.47.0"
"xo": "^0.48.0"
},
"peerDependencies": {
"eslint": ">=8.8.0"
Expand Down
4 changes: 2 additions & 2 deletions rules/better-regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const create = context => {
}

return {
'Literal[regex]': node => {
'Literal[regex]'(node) {
const {raw: original, regex} = node;

// Regular Expressions with `u` flag are not well handled by `regexp-tree`
Expand Down Expand Up @@ -63,7 +63,7 @@ const create = context => {
fix: fixer => fixer.replaceText(node, optimized),
};
},
[newRegExp]: node => {
[newRegExp](node) {
const [patternNode, flagsNode] = node.arguments;

if (typeof patternNode.value !== 'string') {
Expand Down
2 changes: 1 addition & 1 deletion rules/catch-error-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const create = context => {
|| name.endsWith(expectedName.charAt(0).toUpperCase() + expectedName.slice(1));

return {
[selector]: node => {
[selector](node) {
const originalName = node.name;

if (
Expand Down
4 changes: 2 additions & 2 deletions rules/consistent-destructuring.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const create = context => {
const declarations = new Map();

return {
[declaratorSelector]: node => {
[declaratorSelector](node) {
// Ignore any complex expressions (e.g. arrays, functions)
if (!isSimpleExpression(node.init)) {
return;
Expand All @@ -69,7 +69,7 @@ const create = context => {
objectPattern: node.id,
});
},
[memberSelector]: node => {
[memberSelector](node) {
const declaration = declarations.get(source.getText(node.object));

if (!declaration) {
Expand Down
6 changes: 3 additions & 3 deletions rules/consistent-function-scoping.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,17 @@ const create = context => {
const functions = [];

return {
':function': () => {
':function'() {
functions.push(false);
},
JSXElement: () => {
JSXElement() {
// Turn off this rule if we see a JSX element because scope
// references does not include JSXElement nodes.
if (functions.length > 0) {
functions[functions.length - 1] = true;
}
},
':function:exit': node => {
':function:exit'(node) {
const currentFunctionHasJsx = functions.pop();
if (currentFunctionHasJsx) {
return;
Expand Down
4 changes: 2 additions & 2 deletions rules/new-for-builtins.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const create = context => {
const sourceCode = context.getSourceCode();

return {
[callExpressionSelector(builtins.enforceNew)]: node => {
[callExpressionSelector(builtins.enforceNew)](node) {
const {callee, parent} = node;
if (isShadowed(context.getScope(), callee)) {
return;
Expand All @@ -42,7 +42,7 @@ const create = context => {
fix: fixer => switchCallExpressionToNewExpression(node, sourceCode, fixer),
};
},
[newExpressionSelector(builtins.disallowNew)]: node => {
[newExpressionSelector(builtins.disallowNew)](node) {
const {callee} = node;

if (isShadowed(context.getScope(), callee)) {
Expand Down
2 changes: 1 addition & 1 deletion rules/no-array-callback-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function getProblem(context, node, method, options) {
name,
parameters: suggestionParameters,
},
fix: fixer => {
fix(fixer) {
const sourceCode = context.getSourceCode();
let nodeText = sourceCode.getText(node);
if (isParenthesized(node, sourceCode) || type === 'ConditionalExpression') {
Expand Down
2 changes: 1 addition & 1 deletion rules/no-hex-escape.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function checkEscape(context, node, value) {

/** @param {import('eslint').Rule.RuleContext} context */
const create = context => ({
Literal: node => {
Literal(node) {
if (node.regex || typeof node.value === 'string') {
return checkEscape(context, node, node.raw);
}
Expand Down
2 changes: 1 addition & 1 deletion rules/no-invalid-remove-event-listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const removeEventListenerSelector = [

/** @param {import('eslint').Rule.RuleContext} context */
const create = context => ({
[removeEventListenerSelector]: node => {
[removeEventListenerSelector](node) {
const listener = node.arguments[1];
if (['ArrowFunctionExpression', 'FunctionExpression'].includes(listener.type)) {
return {
Expand Down
2 changes: 1 addition & 1 deletion rules/no-keyword-prefix.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const create = context => {
}

return {
Identifier: node => {
Identifier(node) {
const {name, parent} = node;
const keyword = findKeywordPrefix(name, options);
const effectiveParent = parent.type === 'MemberExpression' ? parent.parent : parent;
Expand Down
2 changes: 1 addition & 1 deletion rules/no-nested-ternary.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const create = context => {
[nestTernarySelector(3)]: node =>
// Nesting more than one level not allowed.
({node, messageId: MESSAGE_ID_TOO_DEEP}),
[nestTernarySelector(2)]: node => {
[nestTernarySelector(2)](node) {
if (!isParenthesized(node, sourceCode)) {
return {
node,
Expand Down
2 changes: 1 addition & 1 deletion rules/no-new-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function fix(node, sourceCode, method) {
const create = context => {
const sourceCode = context.getSourceCode();
return {
[newExpressionSelector('Buffer')]: node => {
[newExpressionSelector('Buffer')](node) {
const method = inferMethod(node.arguments, context.getScope());

if (method) {
Expand Down
2 changes: 1 addition & 1 deletion rules/no-null.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const create = context => {
};

return {
[selector]: node => {
[selector](node) {
const {parent} = node;
if (!checkStrictEquality && isStrictEqual(parent)) {
return;
Expand Down
2 changes: 1 addition & 1 deletion rules/no-object-as-default-parameter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const objectParameterSelector = [

/** @param {import('eslint').Rule.RuleContext} context */
const create = () => ({
[objectParameterSelector]: node => {
[objectParameterSelector](node) {
const {left, right} = node;

if (left.type === 'Identifier') {
Expand Down
8 changes: 4 additions & 4 deletions rules/no-process-exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ const create = context => {

return {
// Check `worker_threads` require / import
[importWorkerThreadsSelector]: () => {
[importWorkerThreadsSelector]() {
requiredWorkerThreadsModule = true;
},
// Check `process.on` / `process.once` call
[processOnOrOnceCallSelector]: node => {
[processOnOrOnceCallSelector](node) {
processEventHandler = node;
},
// Check `process.exit` call
[processExitCallSelector]: node => {
[processExitCallSelector](node) {
if (!processEventHandler) {
problemNodes.push(node);
}
},
'CallExpression:exit': node => {
'CallExpression:exit'(node) {
if (node === processEventHandler) {
processEventHandler = undefined;
}
Expand Down
4 changes: 2 additions & 2 deletions rules/no-unsafe-regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const newRegExpSelector = [

/** @param {import('eslint').Rule.RuleContext} context */
const create = () => ({
'Literal[regex]': node => {
'Literal[regex]'(node) {
// Handle regex literal inside RegExp constructor in the other handler
if (
node.parent.type === 'NewExpression'
Expand All @@ -30,7 +30,7 @@ const create = () => ({
};
}
},
[newRegExpSelector]: node => {
[newRegExpSelector](node) {
const arguments_ = node.arguments;
const hasRegExp = arguments_[0].regex;

Expand Down
2 changes: 1 addition & 1 deletion rules/no-useless-undefined.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const create = context => {
start: firstUndefined.loc.start,
end: lastUndefined.loc.end,
},
fix: fixer => {
fix(fixer) {
let start = firstUndefined.range[0];
let end = lastUndefined.range[1];

Expand Down
2 changes: 1 addition & 1 deletion rules/no-zero-fractions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const messages = {

/** @param {import('eslint').Rule.RuleContext} context */
const create = context => ({
Literal: node => {
Literal(node) {
if (!isNumber(node)) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion rules/number-literal-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const fix = raw => {

/** @param {import('eslint').Rule.RuleContext} context */
const create = () => ({
Literal: node => {
Literal(node) {
const {raw} = node;

let fixed = raw;
Expand Down
2 changes: 1 addition & 1 deletion rules/numeric-separators-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const create = context => {
};

return {
Literal: node => {
Literal(node) {
if (!numeric.isNumeric(node) || numeric.isLegacyOctal(node)) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions rules/prefer-array-flat.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const emptyArrayConcat = {
}),
emptyArraySelector('callee.object'),
].join(''),
getArrayNode: node => {
getArrayNode(node) {
const argumentNode = node.arguments[0];
return argumentNode.type === 'SpreadElement' ? argumentNode.argument : argumentNode;
},
Expand All @@ -127,7 +127,7 @@ const arrayPrototypeConcat = {
}),
].join(''),
testFunction: node => node.arguments[1].type !== 'SpreadElement' || node.callee.property.name === 'call',
getArrayNode: node => {
getArrayNode(node) {
const argumentNode = node.arguments[1];
return argumentNode.type === 'SpreadElement' ? argumentNode.argument : argumentNode;
},
Expand Down
8 changes: 4 additions & 4 deletions rules/prefer-default-parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,18 @@ const create = context => {
};

return {
':function': node => {
':function'(node) {
functionStack.push(node);
},
':function:exit': () => {
':function:exit'() {
functionStack.pop();
},
[assignmentSelector]: node => {
[assignmentSelector](node) {
const {left, right} = node.expression;

return checkExpression(node, left, right, true);
},
[declarationSelector]: node => {
[declarationSelector](node) {
const {id, init} = node.declarations[0];

return checkExpression(node, id, init, false);
Expand Down
4 changes: 2 additions & 2 deletions rules/prefer-includes.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const getProblem = (context, node, target, argumentsNodes) => {
return {
node: memberExpressionNode.property,
messageId: MESSAGE_ID,
fix: fixer => {
fix(fixer) {
const replacement = `${isNegativeResult(node) ? '!' : ''}${targetSource}.includes(${argumentsSource.join(', ')})`;
return fixer.replaceText(node, replacement);
},
Expand All @@ -44,7 +44,7 @@ const includesOverSomeRule = simpleArraySearchRule({

/** @param {import('eslint').Rule.RuleContext} context */
const create = context => ({
BinaryExpression: node => {
BinaryExpression(node) {
const {left, right, operator} = node;

if (!isMethodNamed(left, 'indexOf')) {
Expand Down
2 changes: 1 addition & 1 deletion rules/prefer-math-trunc.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const create = context => {
};

return {
':matches(BinaryExpression, AssignmentExpression)[right.type="Literal"]': node => {
':matches(BinaryExpression, AssignmentExpression)[right.type="Literal"]'(node) {
const {type, operator, right, left} = node;
const isAssignment = type === 'AssignmentExpression';
if (
Expand Down
2 changes: 1 addition & 1 deletion rules/prefer-negative-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function parse(node) {

/** @param {import('eslint').Rule.RuleContext} context */
const create = context => ({
'CallExpression[callee.type="MemberExpression"]': node => {
'CallExpression[callee.type="MemberExpression"]'(node) {
const parsed = parse(node);

if (!parsed) {
Expand Down
4 changes: 2 additions & 2 deletions rules/prefer-number-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const create = context => {
const reported = new WeakSet();

return {
[methodsSelector]: node => {
[methodsSelector](node) {
if (isShadowed(context.getScope(), node)) {
return;
}
Expand Down Expand Up @@ -84,7 +84,7 @@ const create = context => {

return problem;
},
[propertiesSelector]: node => {
[propertiesSelector](node) {
if (reported.has(node) || isShadowed(context.getScope(), node)) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion rules/prefer-optional-catch-binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const selector = [

/** @param {import('eslint').Rule.RuleContext} context */
const create = context => ({
[selector]: node => {
[selector](node) {
const variables = context.getDeclaredVariables(node.parent);

if (variables.some(variable => variable.references.length > 0)) {
Expand Down
2 changes: 1 addition & 1 deletion rules/prefer-reflect-apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const fixFunctionPrototypeCall = (node, sourceCode) => {

/** @param {import('eslint').Rule.RuleContext} context */
const create = context => ({
[selector]: node => {
[selector](node) {
const sourceCode = context.getSourceCode();
const fix = fixDirectApplyCall(node, sourceCode) || fixFunctionPrototypeCall(node, sourceCode);
if (fix) {
Expand Down
2 changes: 1 addition & 1 deletion rules/prefer-set-has.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const isMultipleCall = (identifier, node) => {

/** @param {import('eslint').Rule.RuleContext} context */
const create = context => ({
[selector]: node => {
[selector](node) {
const variable = findVariable(context.getScope(), node);

// This was reported https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1075#issuecomment-768073342
Expand Down
2 changes: 1 addition & 1 deletion rules/prefer-string-replace-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function removeEscapeCharacters(regexString) {

/** @param {import('eslint').Rule.RuleContext} context */
const create = () => ({
[selector]: node => {
[selector](node) {
const {arguments: arguments_, callee} = node;
const [search] = arguments_;

Expand Down
2 changes: 1 addition & 1 deletion rules/prefer-type-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const isTypechecking = node => node.type === 'IfStatement' && isTypecheckingExpr

/** @param {import('eslint').Rule.RuleContext} context */
const create = () => ({
[selector]: node => {
[selector](node) {
if (
isLone(node)
&& node.parent.parent
Expand Down
2 changes: 1 addition & 1 deletion rules/string-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const create = context => {
}

return {
'Literal, TemplateElement': node => {
'Literal, TemplateElement'(node) {
const {type, value, raw} = node;

let string;
Expand Down
Loading

0 comments on commit e6de810

Please sign in to comment.