Skip to content

Commit

Permalink
[eslint] remove override for object-curly-spacing, `array-bracket-s…
Browse files Browse the repository at this point in the history
…pacing`

 - fix override for `object-shorthand`
  • Loading branch information
ljharb committed Oct 18, 2021
1 parent fa64144 commit 1786e96
Show file tree
Hide file tree
Showing 122 changed files with 3,780 additions and 3,779 deletions.
7 changes: 4 additions & 3 deletions .eslintrc
Expand Up @@ -15,9 +15,10 @@
},
"rules": {
"comma-dangle": [2, "always-multiline"],
"object-curly-spacing": [2, "never"],
"object-shorthand": [2, "always"],
"array-bracket-spacing": [2, "never"],
"object-shorthand": [2, "always", {
"ignoreConstructors": false,
"avoidQuotes": false, // this is the override vs airbnb
}],
"max-len": [2, 120, {
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/forbid-elements.js
Expand Up @@ -37,12 +37,12 @@ module.exports = {
type: 'array',
items: {
anyOf: [
{type: 'string'},
{ type: 'string' },
{
type: 'object',
properties: {
element: {type: 'string'},
message: {type: 'string'},
element: { type: 'string' },
message: { type: 'string' },
},
required: ['element'],
additionalProperties: false,
Expand All @@ -63,7 +63,7 @@ module.exports = {

forbidConfiguration.forEach((item) => {
if (typeof item === 'string') {
indexedForbidConfigs[item] = {element: item};
indexedForbidConfigs[item] = { element: item };
} else {
indexedForbidConfigs[item.element] = item;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/jsx-boolean-value.js
Expand Up @@ -14,7 +14,7 @@ const report = require('../util/report');

const exceptionsSchema = {
type: 'array',
items: {type: 'string', minLength: 1},
items: { type: 'string', minLength: 1 },
uniqueItems: true,
};

Expand All @@ -26,7 +26,7 @@ function getErrorData(exceptions) {
if (!errorData.has(exceptions)) {
const exceptionProps = Array.from(exceptions, (name) => `\`${name}\``).join(', ');
const exceptionsMessage = exceptions.size > 0 ? ` for the following props: ${exceptionProps}` : '';
errorData.set(exceptions, {exceptionsMessage});
errorData.set(exceptions, { exceptionsMessage });
}
return errorData.get(exceptions);
}
Expand Down Expand Up @@ -69,7 +69,7 @@ module.exports = {
schema: {
anyOf: [{
type: 'array',
items: [{enum: [ALWAYS, NEVER]}],
items: [{ enum: [ALWAYS, NEVER] }],
additionalItems: false,
}, {
type: 'array',
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-closing-bracket-location.js
Expand Up @@ -266,7 +266,7 @@ module.exports = {
return;
}

const data = {location: MESSAGE_LOCATION[expectedLocation]};
const data = { location: MESSAGE_LOCATION[expectedLocation] };
const correctColumn = getCorrectColumn(tokens, expectedLocation);

if (correctColumn !== null) {
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/jsx-curly-brace-presence.js
Expand Up @@ -25,7 +25,7 @@ const OPTION_VALUES = [
OPTION_NEVER,
OPTION_IGNORE,
];
const DEFAULT_CONFIG = {props: OPTION_NEVER, children: OPTION_NEVER};
const DEFAULT_CONFIG = { props: OPTION_NEVER, children: OPTION_NEVER };

// ------------------------------------------------------------------------------
// Rule Definition
Expand Down Expand Up @@ -56,8 +56,8 @@ module.exports = {
{
type: 'object',
properties: {
props: {enum: OPTION_VALUES},
children: {enum: OPTION_VALUES},
props: { enum: OPTION_VALUES },
children: { enum: OPTION_VALUES },
},
additionalProperties: false,
},
Expand All @@ -73,7 +73,7 @@ module.exports = {
const HTML_ENTITY_REGEX = () => /&[A-Za-z\d#]+;/g;
const ruleOptions = context.options[0];
const userConfig = typeof ruleOptions === 'string'
? {props: ruleOptions, children: ruleOptions}
? { props: ruleOptions, children: ruleOptions }
: Object.assign({}, DEFAULT_CONFIG, ruleOptions);

function containsLineTerminators(rawStringValue) {
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-curly-newline.js
Expand Up @@ -63,8 +63,8 @@ module.exports = {
{
type: 'object',
properties: {
singleline: {enum: ['consistent', 'require', 'forbid']},
multiline: {enum: ['consistent', 'require', 'forbid']},
singleline: { enum: ['consistent', 'require', 'forbid'] },
multiline: { enum: ['consistent', 'require', 'forbid'] },
},
additionalProperties: false,
},
Expand Down
10 changes: 5 additions & 5 deletions lib/rules/jsx-curly-spacing.js
Expand Up @@ -140,7 +140,7 @@ module.exports = {

let originalConfig = context.options[0] || {};
if (SPACING_VALUES.indexOf(originalConfig) !== -1) {
originalConfig = Object.assign({when: context.options[0]}, context.options[1]);
originalConfig = Object.assign({ when: context.options[0] }, context.options[1]);
}
const defaultConfig = normalizeConfig(originalConfig, {
when: DEFAULT_WHEN,
Expand Down Expand Up @@ -256,7 +256,7 @@ module.exports = {
nextComment = sourceCode.getCommentsAfter(token);
// ESLint 3.x
} else {
const potentialComment = sourceCode.getTokenAfter(token, {includeComments: true});
const potentialComment = sourceCode.getTokenAfter(token, { includeComments: true });
nextComment = nextToken === potentialComment ? [] : [potentialComment];
}

Expand Down Expand Up @@ -293,7 +293,7 @@ module.exports = {
previousComment = sourceCode.getCommentsBefore(token);
// ESLint 3.x
} else {
const potentialComment = sourceCode.getTokenBefore(token, {includeComments: true});
const potentialComment = sourceCode.getTokenBefore(token, { includeComments: true });
previousComment = previousToken === potentialComment ? [] : [potentialComment];
}

Expand Down Expand Up @@ -373,8 +373,8 @@ module.exports = {
const sourceCode = context.getSourceCode();
const first = context.getFirstToken(node);
const last = sourceCode.getLastToken(node);
let second = context.getTokenAfter(first, {includeComments: true});
let penultimate = sourceCode.getTokenBefore(last, {includeComments: true});
let second = context.getTokenAfter(first, { includeComments: true });
let penultimate = sourceCode.getTokenBefore(last, { includeComments: true });

if (!second) {
second = context.getTokenAfter(first);
Expand Down
24 changes: 12 additions & 12 deletions lib/rules/jsx-handler-names.js
Expand Up @@ -33,22 +33,22 @@ module.exports = {
{
type: 'object',
properties: {
eventHandlerPrefix: {type: 'string'},
eventHandlerPropPrefix: {type: 'string'},
checkLocalVariables: {type: 'boolean'},
checkInlineFunction: {type: 'boolean'},
eventHandlerPrefix: { type: 'string' },
eventHandlerPropPrefix: { type: 'string' },
checkLocalVariables: { type: 'boolean' },
checkInlineFunction: { type: 'boolean' },
},
additionalProperties: false,
}, {
type: 'object',
properties: {
eventHandlerPrefix: {type: 'string'},
eventHandlerPrefix: { type: 'string' },
eventHandlerPropPrefix: {
type: 'boolean',
enum: [false],
},
checkLocalVariables: {type: 'boolean'},
checkInlineFunction: {type: 'boolean'},
checkLocalVariables: { type: 'boolean' },
checkInlineFunction: { type: 'boolean' },
},
additionalProperties: false,
}, {
Expand All @@ -58,21 +58,21 @@ module.exports = {
type: 'boolean',
enum: [false],
},
eventHandlerPropPrefix: {type: 'string'},
checkLocalVariables: {type: 'boolean'},
checkInlineFunction: {type: 'boolean'},
eventHandlerPropPrefix: { type: 'string' },
checkLocalVariables: { type: 'boolean' },
checkInlineFunction: { type: 'boolean' },
},
additionalProperties: false,
}, {
type: 'object',
properties: {
checkLocalVariables: {type: 'boolean'},
checkLocalVariables: { type: 'boolean' },
},
additionalProperties: false,
}, {
type: 'object',
properties: {
checkInlineFunction: {type: 'boolean'},
checkInlineFunction: { type: 'boolean' },
},
additionalProperties: false,
},
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-indent.js
Expand Up @@ -137,7 +137,7 @@ module.exports = {
node,
data: msgContext,
fix: getFixerFunction(node, needed),
}, loc && {loc}));
}, loc && { loc }));
}

/**
Expand Down
18 changes: 9 additions & 9 deletions lib/rules/jsx-no-constructed-context-values.js
Expand Up @@ -19,7 +19,7 @@ function isConstruction(node, callScope) {
switch (node.type) {
case 'Literal':
if (node.regex != null) {
return {type: 'regular expression', node};
return { type: 'regular expression', node };
}
return null;
case 'Identifier': {
Expand All @@ -42,7 +42,7 @@ function isConstruction(node, callScope) {
}

if (def.node.type === 'FunctionDeclaration') {
return {type: 'function declaration', node: def.node, usage: node};
return { type: 'function declaration', node: def.node, usage: node };
}

const init = def.node.init;
Expand All @@ -63,18 +63,18 @@ function isConstruction(node, callScope) {
}
case 'ObjectExpression':
// Any object initialized inline will create a new identity
return {type: 'object', node};
return { type: 'object', node };
case 'ArrayExpression':
return {type: 'array', node};
return { type: 'array', node };
case 'ArrowFunctionExpression':
case 'FunctionExpression':
// Functions that are initialized inline will have a new identity
return {type: 'function expression', node};
return { type: 'function expression', node };
case 'ClassExpression':
return {type: 'class expression', node};
return { type: 'class expression', node };
case 'NewExpression':
// `const a = new SomeClass();` is a construction
return {type: 'new expression', node};
return { type: 'new expression', node };
case 'ConditionalExpression':
return (isConstruction(node.consequent, callScope)
|| isConstruction(node.alternate, callScope)
Expand All @@ -95,9 +95,9 @@ function isConstruction(node, callScope) {
};
}
case 'JSXFragment':
return {type: 'JSX fragment', node};
return { type: 'JSX fragment', node };
case 'JSXElement':
return {type: 'JSX element', node};
return { type: 'JSX element', node };
case 'AssignmentExpression': {
const construct = isConstruction(node.right, callScope);
if (construct != null) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-pascal-case.js
Expand Up @@ -63,7 +63,7 @@ function testAllCaps(name) {

function ignoreCheck(ignore, name) {
return ignore.some(
(entry) => name === entry || minimatch(name, entry, {noglobstar: true})
(entry) => name === entry || minimatch(name, entry, { noglobstar: true })
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-props-no-spreading.js
Expand Up @@ -12,7 +12,7 @@ const report = require('../util/report');
// Constants
// ------------------------------------------------------------------------------

const OPTIONS = {ignore: 'ignore', enforce: 'enforce'};
const OPTIONS = { ignore: 'ignore', enforce: 'enforce' };
const DEFAULTS = {
html: OPTIONS.enforce,
custom: OPTIONS.enforce,
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/jsx-wrap-multilines.js
Expand Up @@ -159,8 +159,8 @@ module.exports = {

if (option === 'parens-new-line' && isMultilines(node)) {
if (!isParenthesised(node)) {
const tokenBefore = sourceCode.getTokenBefore(node, {includeComments: true});
const tokenAfter = sourceCode.getTokenAfter(node, {includeComments: true});
const tokenBefore = sourceCode.getTokenBefore(node, { includeComments: true });
const tokenAfter = sourceCode.getTokenAfter(node, { includeComments: true });
const start = node.loc.start;
if (tokenBefore.loc.end.line < start.line) {
// Strip newline after operator if parens newline is specified
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/no-typos.js
Expand Up @@ -49,7 +49,7 @@ module.exports = {
if (node.name !== 'isRequired') {
report(context, messages.typoPropTypeChain, 'typoPropTypeChain', {
node,
data: {name: node.name},
data: { name: node.name },
});
}
}
Expand All @@ -58,7 +58,7 @@ module.exports = {
if (node.name && !PROP_TYPES.some((propTypeName) => propTypeName === node.name)) {
report(context, messages.typoPropType, 'typoPropType', {
node,
data: {name: node.name},
data: { name: node.name },
});
}
}
Expand Down Expand Up @@ -166,7 +166,7 @@ module.exports = {
if (method.toLowerCase() === nodeKeyName.toLowerCase() && method !== nodeKeyName) {
report(context, messages.typoLifecycleMethod, 'typoLifecycleMethod', {
node,
data: {actual: nodeKeyName, expected: method},
data: { actual: nodeKeyName, expected: method },
});
}
});
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-unescaped-entities.js
Expand Up @@ -101,7 +101,7 @@ module.exports = {
if (c === entities[j]) {
report(context, messages.unescapedEntity, 'unescapedEntity', {
node,
loc: {line: i, column: start + index},
loc: { line: i, column: start + index },
data: {
entity: entities[j],
},
Expand All @@ -110,7 +110,7 @@ module.exports = {
} else if (c === entities[j].char) {
report(context, messages.unescapedEntityAlts, 'unescapedEntityAlts', {
node,
loc: {line: i, column: start + index},
loc: { line: i, column: start + index },
data: {
entity: entities[j].char,
alts: entities[j].alternatives.map((alt) => `\`${alt}\``).join(', '),
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-unused-prop-types.js
Expand Up @@ -56,7 +56,7 @@ module.exports = {
},

create: Components.detect((context, components) => {
const defaults = {skipShapeProps: true, customValidators: [], ignore: []};
const defaults = { skipShapeProps: true, customValidators: [], ignore: [] };
const configuration = Object.assign({}, defaults, context.options[0] || {});

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/prefer-exact-props.js
Expand Up @@ -40,7 +40,7 @@ module.exports = {
function getPropTypesErrorMessage() {
const formattedWrappers = propWrapperUtil.formatPropWrapperFunctions(exactWrappers);
const message = exactWrappers.size > 1 ? `one of ${formattedWrappers}` : formattedWrappers;
return {exactPropWrappers: message};
return { exactPropWrappers: message };
}

function isNonExactObjectTypeAnnotation(node) {
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/require-default-props.js
Expand Up @@ -70,7 +70,7 @@ module.exports = {
if (forbidDefaultForRequired && defaultProps[propName]) {
report(context, messages.noDefaultWithRequired, 'noDefaultWithRequired', {
node: prop.node,
data: {name: propName},
data: { name: propName },
});
}
return;
Expand All @@ -82,7 +82,7 @@ module.exports = {

report(context, messages.shouldHaveDefault, 'shouldHaveDefault', {
node: prop.node,
data: {name: propName},
data: { name: propName },
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/self-closing-comp.js
Expand Up @@ -13,7 +13,7 @@ const report = require('../util/report');
// Rule Definition
// ------------------------------------------------------------------------------

const optionDefaults = {component: true, html: true};
const optionDefaults = { component: true, html: true };

const messages = {
notSelfClosing: 'Empty components are self-closing',
Expand Down

0 comments on commit 1786e96

Please sign in to comment.