Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove object.entries dependency #2878

Merged
merged 4 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions packages/eslint-config-airbnb-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,25 @@
},
"homepage": "https://github.com/airbnb/javascript",
"devDependencies": {
"@babel/runtime": "^7.22.6",
"@babel/runtime": "^7.23.9",
"babel-preset-airbnb": "^4.5.0",
"babel-tape-runner": "^3.0.0",
"eclint": "^2.8.1",
"eslint": "^7.32.0 || ^8.2.0",
"eslint-find-rules": "^4.1.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-import": "^2.29.1",
"in-publish": "^2.0.1",
"safe-publish-latest": "^2.0.0",
"tape": "^5.6.6"
"tape": "^5.7.4"
},
"peerDependencies": {
"eslint": "^7.32.0 || ^8.2.0",
"eslint-plugin-import": "^2.28.0"
"eslint-plugin-import": "^2.29.1"
},
"engines": {
"node": "^10.12.0 || >=12.0.0"
},
"dependencies": {
"confusing-browser-globals": "^1.0.11",
"object.entries": "^1.1.6"
"confusing-browser-globals": "^1.0.11"
}
}
5 changes: 5 additions & 0 deletions packages/eslint-config-airbnb-base/rules/best-practices.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ module.exports = {
// https://eslint.org/docs/rules/no-nonoctal-decimal-escape
'no-nonoctal-decimal-escape': 'error',

// Disallow calls to the Object constructor without an argument
// https://eslint.org/docs/latest/rules/no-object-constructor
// TODO: enable, semver-major
'no-object-constructor': 'off',

// disallow use of (old style) octal literals
// https://eslint.org/docs/rules/no-octal
'no-octal': 'error',
Expand Down
7 changes: 4 additions & 3 deletions packages/eslint-config-airbnb-base/whitespace-async.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node

const entries = require('object.entries');
const { isArray } = Array;
const { entries } = Object;
const { ESLint } = require('eslint');

const baseConfig = require('.');
Expand All @@ -9,7 +10,7 @@ const whitespaceRules = require('./whitespaceRules');
const severities = ['off', 'warn', 'error'];

function getSeverity(ruleConfig) {
if (Array.isArray(ruleConfig)) {
if (isArray(ruleConfig)) {
return getSeverity(ruleConfig[0]);
}
if (typeof ruleConfig === 'number') {
Expand All @@ -32,7 +33,7 @@ async function onlyErrorOnRules(rulesToError, config) {
const severity = getSeverity(ruleConfig);

if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') {
if (Array.isArray(ruleConfig)) {
if (isArray(ruleConfig)) {
errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1));
} else if (typeof ruleConfig === 'number') {
errorsOnly.rules[ruleName] = 1;
Expand Down
7 changes: 4 additions & 3 deletions packages/eslint-config-airbnb-base/whitespace.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
/* eslint global-require: 0 */

const { isArray } = Array;
const { entries } = Object;
const { CLIEngine } = require('eslint');

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

const baseConfig = require('.');

const severities = ['off', 'warn', 'error'];

function getSeverity(ruleConfig) {
if (Array.isArray(ruleConfig)) {
if (isArray(ruleConfig)) {
return getSeverity(ruleConfig[0]);
}
if (typeof ruleConfig === 'number') {
Expand All @@ -32,7 +33,7 @@ if (CLIEngine) {
const severity = getSeverity(ruleConfig);

if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') {
if (Array.isArray(ruleConfig)) {
if (isArray(ruleConfig)) {
errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1));
} else if (typeof ruleConfig === 'number') {
errorsOnly.rules[ruleName] = 1;
Expand Down
19 changes: 9 additions & 10 deletions packages/eslint-config-airbnb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,30 +66,29 @@
},
"homepage": "https://github.com/airbnb/javascript",
"dependencies": {
"eslint-config-airbnb-base": "^15.0.0",
"object.entries": "^1.1.6"
"eslint-config-airbnb-base": "^15.0.0"
},
"devDependencies": {
"@babel/runtime": "^7.22.6",
"@babel/runtime": "^7.23.9",
"babel-preset-airbnb": "^4.5.0",
"babel-tape-runner": "^3.0.0",
"eclint": "^2.8.1",
"eslint": "^7.32.0 || ^8.2.0",
"eslint-find-rules": "^4.1.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.33.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"in-publish": "^2.0.1",
"react": ">= 0.13.0",
"safe-publish-latest": "^2.0.0",
"tape": "^5.6.6"
"tape": "^5.7.4"
},
"peerDependencies": {
"eslint": "^7.32.0 || ^8.2.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.33.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0"
},
"engines": {
Expand Down
7 changes: 4 additions & 3 deletions packages/eslint-config-airbnb/whitespace-async.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node

const entries = require('object.entries');
const { isArray } = Array;
const { entries } = Object;
const { ESLint } = require('eslint');

const baseConfig = require('.');
Expand All @@ -9,7 +10,7 @@ const whitespaceRules = require('./whitespaceRules');
const severities = ['off', 'warn', 'error'];

function getSeverity(ruleConfig) {
if (Array.isArray(ruleConfig)) {
if (isArray(ruleConfig)) {
return getSeverity(ruleConfig[0]);
}
if (typeof ruleConfig === 'number') {
Expand All @@ -32,7 +33,7 @@ async function onlyErrorOnRules(rulesToError, config) {
const severity = getSeverity(ruleConfig);

if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') {
if (Array.isArray(ruleConfig)) {
if (isArray(ruleConfig)) {
errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1));
} else if (typeof ruleConfig === 'number') {
errorsOnly.rules[ruleName] = 1;
Expand Down
7 changes: 4 additions & 3 deletions packages/eslint-config-airbnb/whitespace.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
/* eslint global-require: 0 */

const { isArray } = Array;
const { entries } = Object;
const { CLIEngine } = require('eslint');

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

const baseConfig = require('.');

const severities = ['off', 'warn', 'error'];

function getSeverity(ruleConfig) {
if (Array.isArray(ruleConfig)) {
if (isArray(ruleConfig)) {
return getSeverity(ruleConfig[0]);
}
if (typeof ruleConfig === 'number') {
Expand All @@ -32,7 +33,7 @@ if (CLIEngine) {
const severity = getSeverity(ruleConfig);

if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') {
if (Array.isArray(ruleConfig)) {
if (isArray(ruleConfig)) {
errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1));
} else if (typeof ruleConfig === 'number') {
errorsOnly.rules[ruleName] = 1;
Expand Down