Skip to content

Commit

Permalink
Remove direct dependency on lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Aug 6, 2023
1 parent 6191299 commit 779f153
Show file tree
Hide file tree
Showing 7 changed files with 1,601 additions and 8 deletions.
2 changes: 1 addition & 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
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');

Check failure on line 2 in rules/custom-error-definition.js

View workflow job for this annotation

GitHub Actions / lint-test

Missing file extension for "./utils/lodash"

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');

Check failure on line 3 in rules/filename-case.js

View workflow job for this annotation

GitHub Actions / lint-test

Missing file extension for "./utils/lodash"
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');

Check failure on line 2 in rules/import-style.js

View workflow job for this annotation

GitHub Actions / lint-test

Missing file extension for "./utils/lodash"
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');

Check failure on line 3 in rules/prevent-abbreviations.js

View workflow job for this annotation

GitHub Actions / lint-test

Missing file extension for "./utils/lodash"
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

0 comments on commit 779f153

Please sign in to comment.