Skip to content

Commit

Permalink
[eslint config] [*] [refactor] use object spread instead of `Object.a…
Browse files Browse the repository at this point in the history
…ssign`
  • Loading branch information
ljharb committed Dec 30, 2022
1 parent 81157ee commit fd96a4f
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 13 deletions.
1 change: 0 additions & 1 deletion packages/eslint-config-airbnb-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
},
"dependencies": {
"confusing-browser-globals": "^1.0.11",
"object.assign": "^4.1.4",
"object.entries": "^1.1.5"
}
}
3 changes: 1 addition & 2 deletions packages/eslint-config-airbnb-base/whitespace-async.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env node

const assign = require('object.assign');
const entries = require('object.entries');
const { ESLint } = require('eslint');

Expand All @@ -20,7 +19,7 @@ function getSeverity(ruleConfig) {
}

async function onlyErrorOnRules(rulesToError, config) {
const errorsOnly = assign({}, config);
const errorsOnly = { ...config };
const cli = new ESLint({
useEslintrc: false,
baseConfig: config
Expand Down
3 changes: 1 addition & 2 deletions packages/eslint-config-airbnb-base/whitespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const { CLIEngine } = require('eslint');

if (CLIEngine) {
/* eslint no-inner-declarations: 0 */
const assign = require('object.assign');
const entries = require('object.entries');
const whitespaceRules = require('./whitespaceRules');

Expand All @@ -23,7 +22,7 @@ if (CLIEngine) {
}

function onlyErrorOnRules(rulesToError, config) {
const errorsOnly = assign({}, config);
const errorsOnly = { ...config };
const cli = new CLIEngine({ baseConfig: config, useEslintrc: false });
const baseRules = cli.getConfigForFile(require.resolve('./')).rules;

Expand Down
1 change: 0 additions & 1 deletion packages/eslint-config-airbnb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"homepage": "https://github.com/airbnb/javascript",
"dependencies": {
"eslint-config-airbnb-base": "^15.0.0",
"object.assign": "^4.1.4",
"object.entries": "^1.1.5"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-config-airbnb/rules/react.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const assign = require('object.assign');
const baseStyleRules = require('eslint-config-airbnb-base/rules/style').rules;

const dangleRules = baseStyleRules['no-underscore-dangle'];
Expand All @@ -17,9 +16,10 @@ module.exports = {
// View link below for react rules documentation
// https://github.com/jsx-eslint/eslint-plugin-react#list-of-supported-rules
rules: {
'no-underscore-dangle': [dangleRules[0], assign({}, dangleRules[1], {
'no-underscore-dangle': [dangleRules[0], {
...dangleRules[1],
allow: dangleRules[1].allow.concat(['__REDUX_DEVTOOLS_EXTENSION_COMPOSE__']),
})],
}],

// Specify whether double or single quotes should be used in JSX attributes
// https://eslint.org/docs/rules/jsx-quotes
Expand Down
3 changes: 1 addition & 2 deletions packages/eslint-config-airbnb/whitespace-async.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env node

const assign = require('object.assign');
const entries = require('object.entries');
const { ESLint } = require('eslint');

Expand All @@ -20,7 +19,7 @@ function getSeverity(ruleConfig) {
}

async function onlyErrorOnRules(rulesToError, config) {
const errorsOnly = assign({}, config);
const errorsOnly = { ...config };
const cli = new ESLint({
useEslintrc: false,
baseConfig: config
Expand Down
3 changes: 1 addition & 2 deletions packages/eslint-config-airbnb/whitespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const { CLIEngine } = require('eslint');

if (CLIEngine) {
/* eslint no-inner-declarations: 0 */
const assign = require('object.assign');
const entries = require('object.entries');
const whitespaceRules = require('./whitespaceRules');

Expand All @@ -23,7 +22,7 @@ if (CLIEngine) {
}

function onlyErrorOnRules(rulesToError, config) {
const errorsOnly = assign({}, config);
const errorsOnly = { ...config };
const cli = new CLIEngine({ baseConfig: config, useEslintrc: false });
const baseRules = cli.getConfigForFile(require.resolve('./')).rules;

Expand Down

0 comments on commit fd96a4f

Please sign in to comment.