Skip to content

Commit

Permalink
Remove direct dependency on lodash (#2184)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Oct 29, 2023
1 parent ac51d40 commit 54da9ca
Show file tree
Hide file tree
Showing 8 changed files with 1,603 additions and 8 deletions.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -26,6 +26,7 @@
"lint:md": "markdownlint \"**/*.md\"",
"lint:package-json": "npmPkgJsonLint .",
"run-rules-on-codebase": "node ./test/run-rules-on-codebase/lint.mjs",
"bundle-lodash": "echo \"export {defaultsDeep, camelCase, kebabCase, snakeCase, upperFirst, lowerFirst} from 'lodash-es';\" | npx esbuild --bundle --outfile=rules/utils/lodash.js --format=cjs",
"smoke": "eslint-remote-tester --config ./test/smoke/eslint-remote-tester.config.js",
"test": "npm-run-all --continue-on-error lint test:*",
"test:js": "c8 ava"
Expand Down Expand Up @@ -54,7 +55,6 @@
"indent-string": "^4.0.0",
"is-builtin-module": "^3.2.1",
"jsesc": "^3.0.2",
"lodash": "^4.17.21",
"pluralize": "^8.0.0",
"read-pkg-up": "^7.0.1",
"regexp-tree": "^0.1.27",
Expand Down Expand Up @@ -114,6 +114,7 @@
"ignores": [
".cache-eslint-remote-tester",
"eslint-remote-tester-results",
"rules/utils/lodash.js",
"test/integration/{fixtures,fixtures-local}/**"
],
"rules": {
Expand Down
10 changes: 7 additions & 3 deletions rules/ast/is-method-call.js
@@ -1,5 +1,4 @@
'use strict';
const {pick} = require('lodash');
const isMemberExpression = require('./is-member-expression.js');
const {isCallExpression} = require('./call-or-new-expression.js');

Expand Down Expand Up @@ -46,11 +45,16 @@ function isMethodCall(node, options) {

return (
isCallExpression(node, {
...pick(options, ['argumentsLength', 'minimumArguments', 'maximumArguments', 'allowSpreadElement']),
argumentsLength: options.argumentsLength,
minimumArguments: options.minimumArguments,
maximumArguments: options.maximumArguments,
allowSpreadElement: options.allowSpreadElement,
optional: optionalCall,
})
&& isMemberExpression(node.callee, {
...pick(options, ['object', 'objects', 'computed']),
object: options.object,
objects: options.objects,
computed: options.computed,
property: method,
properties: methods,
optional: optionalMember,
Expand Down
2 changes: 1 addition & 1 deletion rules/custom-error-definition.js
@@ -1,5 +1,5 @@
'use strict';
const {upperFirst} = require('lodash');
const {upperFirst} = require('./utils/lodash.js');

const MESSAGE_ID_INVALID_EXPORT = 'invalidExport';
const messages = {
Expand Down
2 changes: 1 addition & 1 deletion rules/filename-case.js
@@ -1,6 +1,6 @@
'use strict';
const path = require('node:path');
const {camelCase, kebabCase, snakeCase, upperFirst} = require('lodash');
const {camelCase, kebabCase, snakeCase, upperFirst} = require('./utils/lodash.js');
const cartesianProductSamples = require('./utils/cartesian-product-samples.js');

const MESSAGE_ID = 'filename-case';
Expand Down
2 changes: 1 addition & 1 deletion rules/import-style.js
@@ -1,5 +1,5 @@
'use strict';
const {defaultsDeep} = require('lodash');
const {defaultsDeep} = require('./utils/lodash.js');
const {getStringIfConstant} = require('@eslint-community/eslint-utils');
const {isCallExpression} = require('./ast/index.js');

Expand Down
2 changes: 1 addition & 1 deletion rules/prevent-abbreviations.js
@@ -1,6 +1,6 @@
'use strict';
const path = require('node:path');
const {defaultsDeep, upperFirst, lowerFirst} = require('lodash');
const {defaultsDeep, upperFirst, lowerFirst} = require('./utils/lodash.js');
const avoidCapture = require('./utils/avoid-capture.js');
const cartesianProductSamples = require('./utils/cartesian-product-samples.js');
const isShorthandPropertyValue = require('./utils/is-shorthand-property-value.js');
Expand Down

0 comments on commit 54da9ca

Please sign in to comment.