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 direct dependency on lodash #2184

Merged
merged 3 commits into from
Oct 29, 2023
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Loading