-
Notifications
You must be signed in to change notification settings - Fork 400
chore: [M3-9693] - Eslint Overhaul #11941
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
Changes from 30 commits
8dc33fd
84a00fd
19dda32
05870eb
d6cb6df
98e16ea
3ead794
5193b64
5e19565
9dbbb8b
2e82f9b
c87be5e
6a67adf
e87e2f1
5c96443
6753c32
afee8a1
be33920
484ee0f
d14828d
60f4bd3
5efef2c
6e9d813
02540a9
5a7bded
9df5d98
8487cc9
dfaeaec
9c38246
0642872
13f1344
8c77acc
1c7d238
38ce73c
59ff7bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: ESLint Review | ||
| on: [pull_request] | ||
| jobs: | ||
| eslint: | ||
| name: ESLint Review | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| checks: write | ||
| strategy: | ||
| matrix: | ||
| package: [manager, api-v4, queries, shared, ui, utilities, validation] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: pnpm/action-setup@v2 | ||
| with: | ||
| run_install: false | ||
| version: 10 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20.17" | ||
| cache: "pnpm" | ||
| - run: pnpm install | ||
| - uses: abailly-akamai/action-eslint@8ad68ba04fa60924ef7607b07deb5989f38f5ed6 # v1.0.2 | ||
| with: | ||
| workdir: packages/${{ matrix.package }} | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| reporter: github-pr-check | ||
| level: warning # This will report both warnings and errors | ||
| filter_mode: added # Only comment on new/modified lines |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| auto-install-peers=true | ||
| node-linker=hoisted | ||
abailly-akamai marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,16 +2,35 @@ | |
| "name": "root", | ||
| "private": true, | ||
| "license": "Apache-2.0", | ||
| "type": "module", | ||
| "devDependencies": { | ||
| "@eslint/js": "^9.23.0", | ||
| "concurrently": "9.1.0", | ||
| "husky": "^9.1.6", | ||
| "typescript": "^5.7.3", | ||
| "vitest": "^3.0.7", | ||
| "@vitest/ui": "^3.0.7", | ||
| "lint-staged": "^15.4.3" | ||
| "lint-staged": "^15.4.3", | ||
| "eslint": "^9.23.0", | ||
| "eslint-config-prettier": "^10.1.1", | ||
| "eslint-plugin-cypress": "^4.2.0", | ||
| "eslint-plugin-jsx-a11y": "^6.10.2", | ||
| "eslint-plugin-perfectionist": "^4.10.1", | ||
| "eslint-plugin-prettier": "~5.2.6", | ||
| "eslint-plugin-react": "^7.37.4", | ||
| "eslint-plugin-react-hooks": "^5.2.0", | ||
| "eslint-plugin-sonarjs": "^3.0.2", | ||
| "eslint-plugin-testing-library": "^7.1.1", | ||
| "eslint-plugin-xss": "^0.1.12", | ||
| "prettier": "~3.5.3", | ||
| "typescript-eslint": "^8.29.0", | ||
| "@typescript-eslint/eslint-plugin": "^8.29.0", | ||
| "@typescript-eslint/parser": "^8.29.0", | ||
| "@linode/eslint-plugin-cloud-manager": "^0.0.10", | ||
| "jiti": "^2.4.2" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moving all eslint dev dependencies to the root package (one source of truth! π)
abailly-akamai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| "scripts": { | ||
| "lint": "eslint . --quiet --ext .js,.ts,.tsx", | ||
| "lint:all": "concurrently -n manager,api-v4,validation,ui,utilities,queries,shared -c green,blue,yellow,magenta,cyan,gray,blue \"pnpm run --filter linode-manager lint\" \"pnpm run --filter @linode/api-v4 lint\" \"pnpm run --filter @linode/validation lint\" \"pnpm run --filter @linode/ui lint\" \"pnpm run --filter @linode/utilities lint\" \"pnpm run --filter @linode/queries lint\" \"pnpm run --filter @linode/shared lint\"", | ||
abailly-akamai marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "install:all": "pnpm install --frozen-lockfile", | ||
| "build:sdk": "pnpm run --filter @linode/api-v4 build", | ||
| "build:validation": "pnpm run --filter @linode/validation build", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@linode/api-v4": Tech Stories | ||
| --- | ||
|
|
||
| Eslint Overhaul ([#11941](https://github.com/linode/manager/pull/11941)) |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { defineConfig } from 'eslint/config'; | ||
|
|
||
| import { baseConfig } from '../manager/eslint.config.js'; | ||
|
|
||
| export default defineConfig({ | ||
| extends: baseConfig, | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,8 @@ interface RequestConfig extends AxiosRequestConfig { | |
| validationErrors?: APIError[]; | ||
| } | ||
|
|
||
| type RequestConfigFn = (config: RequestConfig) => RequestConfig; | ||
|
|
||
| type ConfigField = 'headers' | 'data' | 'params' | 'method' | 'url'; | ||
|
|
||
| export const baseRequest = Axios.create({ | ||
|
|
@@ -71,11 +73,13 @@ export const setMethod = (method: 'GET' | 'POST' | 'PUT' | 'DELETE') => | |
| /** Param */ | ||
| export const setParams = (params: Params | undefined) => set('params', params); | ||
|
|
||
| export const setHeaders = (newHeaders: any = {}) => (object: any) => { | ||
| return !isEmpty(newHeaders) | ||
| ? { ...object, headers: { ...object.headers, ...newHeaders } } | ||
| : object; | ||
| }; | ||
| export const setHeaders = | ||
| (newHeaders: any = {}) => | ||
| (object: any) => { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These new annotations will only show for code that was touched, which is great so it can point at scoped improvements to be made in the current PR |
||
| return !isEmpty(newHeaders) | ||
| ? { ...object, headers: { ...object.headers, ...newHeaders } } | ||
| : object; | ||
| }; | ||
|
|
||
| /** | ||
| * Validate and set data in the request configuration object. | ||
|
|
@@ -93,7 +97,7 @@ export const setData = ( | |
| * object, after the validation has happened. Use with caution: It was created as a trap door for | ||
| * merging IPv4 addresses and ports in the NodeBalancer creation flow. | ||
| */ | ||
| postValidationTransform?: (_: any) => any | ||
| postValidationTransform?: (_: any) => any, | ||
| ): any => { | ||
| if (!schema) { | ||
| return set('data', data); | ||
|
|
@@ -121,7 +125,7 @@ export const setData = ( | |
| * to itself since we have nested structures (think NodeBalancers). | ||
| */ | ||
| export const convertYupToLinodeErrors = ( | ||
| validationError: ValidationError | ||
| validationError: ValidationError, | ||
| ): APIError[] => { | ||
| const { inner } = validationError; | ||
|
|
||
|
|
@@ -169,18 +173,18 @@ export const setXFilter = (xFilter: Filter | undefined) => { | |
| * is an error. | ||
| * @param fns An array of functions to be applied to the config object. | ||
| */ | ||
| const reduceRequestConfig = (...fns: Function[]): RequestConfig => | ||
| fns.reduceRight((result, fn) => fn(result), { | ||
| const reduceRequestConfig = (...fns: RequestConfigFn[]): RequestConfig => | ||
| fns.reduceRight<RequestConfig>((result, fn) => fn(result), { | ||
| url: 'https://api.linode.com/v4', | ||
| headers: {}, | ||
| }); | ||
|
|
||
| /** Generator */ | ||
| export const requestGenerator = <T>(...fns: Function[]): Promise<T> => { | ||
| export const requestGenerator = <T>(...fns: RequestConfigFn[]): Promise<T> => { | ||
| const config = reduceRequestConfig(...fns); | ||
| if (config.validationErrors) { | ||
| return Promise.reject( | ||
| config.validationErrors // All failed requests, client or server errors, should be APIError[] | ||
| config.validationErrors, // All failed requests, client or server errors, should be APIError[] | ||
| ); | ||
| } | ||
| return baseRequest(config).then((response) => response.data); | ||
|
|
@@ -199,7 +203,7 @@ export const requestGenerator = <T>(...fns: Function[]): Promise<T> => { | |
| export const mockAPIError = ( | ||
| status: number = 400, | ||
| statusText: string = 'Internal Server Error', | ||
| data: any = {} | ||
| data: any = {}, | ||
| ): Promise<AxiosError> => | ||
| new Promise((resolve, reject) => | ||
| setTimeout( | ||
|
|
@@ -213,10 +217,10 @@ export const mockAPIError = ( | |
| config: { | ||
| headers: new AxiosHeaders(), | ||
| }, | ||
| }) | ||
| }), | ||
| ), | ||
| process.env.NODE_ENV === 'test' ? 0 : 250 | ||
| ) | ||
| process.env.NODE_ENV === 'test' ? 0 : 250, | ||
| ), | ||
| ); | ||
|
|
||
| const createError = (message: string, response: AxiosResponse) => { | ||
|
|
@@ -231,7 +235,7 @@ export interface CancellableRequest<T> { | |
| } | ||
|
|
||
| export const CancellableRequest = <T>( | ||
| ...fns: Function[] | ||
| ...fns: RequestConfigFn[] | ||
| ): CancellableRequest<T> => { | ||
| const config = reduceRequestConfig(...fns); | ||
| const source = Axios.CancelToken.source(); | ||
|
|
@@ -251,7 +255,7 @@ export const CancellableRequest = <T>( | |
| cancel: source.cancel, | ||
| request: () => | ||
| baseRequest({ ...config, cancelToken: source.token }).then( | ||
| (response) => response.data | ||
| (response) => response.data, | ||
| ), | ||
| }; | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@linode/manager": Tech Stories | ||
| --- | ||
|
|
||
| Eslint Overhaul ([#11941](https://github.com/linode/manager/pull/11941)) |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean we can remove the lint steps in
ci.yml?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I'd like to make sure this is going to stick before doing so - maybe I can just comment them with a note π