Skip to content

Commit

Permalink
Migrate to lodash-es
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald committed Jan 23, 2024
1 parent d7f9d3b commit 78bba65
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 26 deletions.
4 changes: 2 additions & 2 deletions packages/alpine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
},
"dependencies": {
"laravel-precognition": "0.5.3",
"lodash": "^4.17.21"
"lodash-es": "^4.17.21"
},
"devDependencies": {
"@types/alpinejs": "^3.7.1",
"@types/lodash": "^4.14.202",
"@types/lodash-es": "^4.17.12",
"typescript": "^5.0.0"
}
}
4 changes: 1 addition & 3 deletions packages/alpine/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Alpine as TAlpine } from 'alpinejs'
import { client, Config, createValidator, RequestMethod, resolveName, toSimpleValidationErrors, ValidationConfig, resolveUrl, resolveMethod } from 'laravel-precognition'
import cloneDeep from 'lodash/clonedeep'
import get from 'lodash/get'
import set from 'lodash/set'
import {cloneDeep, get, set} from 'lodash-es'

Check failure on line 3 in packages/alpine/src/index.ts

View workflow job for this annotation

GitHub Actions / lint

A space is required after '{'

Check failure on line 3 in packages/alpine/src/index.ts

View workflow job for this annotation

GitHub Actions / lint

A space is required before '}'
import { Form } from './types.js'

export { client }
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
},
"dependencies": {
"axios": "^1.4.0",
"lodash": "^4.17.21"
"lodash-es": "^4.17.21"
},
"devDependencies": {
"@types/lodash": "^4.14.202",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.1.0",
"typescript": "^5.0.0",
"vitest": "^0.31.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isAxiosError, isCancel, AxiosInstance, AxiosResponse, default as Axios } from 'axios'
import merge from 'lodash/merge'
import {merge} from 'lodash-es'

Check failure on line 2 in packages/core/src/client.ts

View workflow job for this annotation

GitHub Actions / lint

A space is required after '{'

Check failure on line 2 in packages/core/src/client.ts

View workflow job for this annotation

GitHub Actions / lint

A space is required before '}'
import { Config, Client, RequestFingerprintResolver, StatusHandler, SuccessResolver, RequestMethod } from './types.js'

/**
Expand Down
11 changes: 3 additions & 8 deletions packages/core/src/validator.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import debounce from 'lodash/debounce'
import isequal from 'lodash/isequal'
import get from 'lodash/get'
import set from 'lodash/set'
import { debounce, isEqual, get, set, omit, merge } from 'lodash-es'
import { ValidationCallback, Config, NamedInputEvent, SimpleValidationErrors, ValidationErrors, Validator as TValidator, ValidatorListeners, ValidationConfig } from './types.js'
import { client, isFile } from './client.js'
import { isAxiosError } from 'axios'
import omit from 'lodash/omit'
import merge from 'lodash/merge'

export const createValidator = (callback: ValidationCallback, initialData: Record<string, unknown> = {}): TValidator => {
/**
Expand Down Expand Up @@ -110,7 +105,7 @@ export const createValidator = (callback: ValidationCallback, initialData: Recor
const setErrors = (value: ValidationErrors|SimpleValidationErrors): (() => void)[] => {
const prepared = toValidationErrors(value)

if (! isequal(errors, prepared)) {
if (! isEqual(errors, prepared)) {
errors = prepared

return listeners.errorsChanged
Expand Down Expand Up @@ -225,7 +220,7 @@ export const createValidator = (callback: ValidationCallback, initialData: Recor
},
onBefore: () => {
const beforeValidationResult = (config.onBeforeValidation ?? ((previous, next) => {
return ! isequal(previous, next)
return ! isEqual(previous, next)
}))({ data, touched }, { data: oldData, touched: oldTouched })

if (beforeValidationResult === false) {
Expand Down
4 changes: 2 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
},
"dependencies": {
"laravel-precognition": "0.5.3",
"lodash": "^4.17.21"
"lodash-es": "^4.17.21"
},
"devDependencies": {
"@types/lodash": "^4.14.202",
"@types/lodash-es": "^4.17.12",
"@types/react": "^18.2.6",
"typescript": "^5.0.0"
}
Expand Down
4 changes: 1 addition & 3 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { resolveName, client, createValidator, Config, RequestMethod, Validator, toSimpleValidationErrors, ValidationConfig, resolveUrl, resolveMethod } from 'laravel-precognition'
import cloneDeep from 'lodash/cloneDeep'
import get from 'lodash/get'
import set from 'lodash/set'
import { cloneDeep, get, set } from 'lodash-es'
import { useRef, useState } from 'react'
import { Form } from './types.js'

Expand Down
4 changes: 2 additions & 2 deletions packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
},
"dependencies": {
"laravel-precognition": "0.5.3",
"lodash": "^4.17.21"
"lodash-es": "^4.17.21"
},
"devDependencies": {
"@types/lodash": "^4.14.202",
"@types/lodash-es": "^4.17.12",
"typescript": "^5.0.0"
}
}
4 changes: 1 addition & 3 deletions packages/vue/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Config, RequestMethod, client, createValidator, toSimpleValidationErrors, ValidationConfig, resolveUrl, resolveMethod , resolveName } from 'laravel-precognition'
import { Form } from './types.js'
import { reactive, ref, toRaw } from 'vue'
import cloneDeep from 'lodash/clonedeep'
import get from 'lodash/get'
import set from 'lodash/set'
import {cloneDeep, get, set} from 'lodash-es'

Check failure on line 4 in packages/vue/src/index.ts

View workflow job for this annotation

GitHub Actions / lint

A space is required after '{'

Check failure on line 4 in packages/vue/src/index.ts

View workflow job for this annotation

GitHub Actions / lint

A space is required before '}'

export { client }

Expand Down

0 comments on commit 78bba65

Please sign in to comment.