Skip to content
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8dc33fd
Save progress
abailly-akamai Mar 31, 2025
84a00fd
save progress
abailly-akamai Mar 31, 2025
19dda32
save mooaarrr progress
abailly-akamai Mar 31, 2025
05870eb
closer to stable config
abailly-akamai Apr 1, 2025
d6cb6df
perfectoinist
abailly-akamai Apr 1, 2025
98e16ea
fixes from required rules
abailly-akamai Apr 1, 2025
3ead794
fixes from required rules
abailly-akamai Apr 1, 2025
5193b64
e2e fixes
abailly-akamai Apr 1, 2025
5e19565
Wrapping CM
abailly-akamai Apr 1, 2025
9dbbb8b
oops ramda!
abailly-akamai Apr 1, 2025
2e82f9b
Move it all to the root
abailly-akamai Apr 1, 2025
c87be5e
Cleanup - part 1
abailly-akamai Apr 1, 2025
6a67adf
post rebase fix
abailly-akamai Apr 2, 2025
e87e2f1
fix lint errors in all packages
abailly-akamai Apr 2, 2025
5c96443
Oops utilities
abailly-akamai Apr 2, 2025
6753c32
missing one after rebase
abailly-akamai Apr 2, 2025
afee8a1
fix tests
abailly-akamai Apr 2, 2025
be33920
fix remaining test and fill rule gaos
abailly-akamai Apr 2, 2025
484ee0f
Some more cleanup and gh action
abailly-akamai Apr 3, 2025
d14828d
post rebase fixes
abailly-akamai Apr 3, 2025
60f4bd3
fix to action
abailly-akamai Apr 3, 2025
5efef2c
fix GH action
abailly-akamai Apr 3, 2025
6e9d813
fix GH action
abailly-akamai Apr 3, 2025
02540a9
fix GH action
abailly-akamai Apr 3, 2025
5a7bded
test action fork
abailly-akamai Apr 3, 2025
9df5d98
no exit-0 on annotations
abailly-akamai Apr 3, 2025
8487cc9
Changesets
abailly-akamai Apr 3, 2025
dfaeaec
missed one package
abailly-akamai Apr 3, 2025
9c38246
merge develop
abailly-akamai Apr 7, 2025
0642872
feedback @hkhalil-akamai @mjac0bs
abailly-akamai Apr 7, 2025
13f1344
feedback @bnussman-akamai
abailly-akamai Apr 7, 2025
8c77acc
merge develop
abailly-akamai Apr 7, 2025
1c7d238
Merge branch 'develop' into M3-9693
abailly-akamai Apr 8, 2025
38ce73c
feedback + merge
abailly-akamai Apr 8, 2025
59ff7bb
Merge branch 'develop' into M3-9693
abailly-akamai Apr 9, 2025
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
30 changes: 30 additions & 0 deletions .github/workflows/eslint_review.yml
Copy link
Copy Markdown
Contributor

@hkhalil-akamai hkhalil-akamai Apr 7, 2025

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?

Copy link
Copy Markdown
Contributor Author

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 πŸ‘

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
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
auto-install-peers=true
node-linker=hoisted
23 changes: 21 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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! πŸŽ‰)

},
"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\"",
"install:all": "pnpm install --frozen-lockfile",
"build:sdk": "pnpm run --filter @linode/api-v4 build",
"build:validation": "pnpm run --filter @linode/validation build",
Expand Down
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))
112 changes: 0 additions & 112 deletions packages/api-v4/.eslintrc.json

This file was deleted.

7 changes: 7 additions & 0 deletions packages/api-v4/eslint.config.js
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,
});
3 changes: 0 additions & 3 deletions packages/api-v4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@
"devDependencies": {
"axios-mock-adapter": "^1.22.0",
"concurrently": "^9.0.1",
"eslint": "^6.8.0",
"eslint-plugin-sonarjs": "^0.5.0",
"prettier": "~2.2.1",
"tsup": "^8.4.0"
},
"lint-staged": {
Expand Down
38 changes: 21 additions & 17 deletions packages/api-v4/src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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) => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.
Expand All @@ -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);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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(
Expand All @@ -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) => {
Expand All @@ -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();
Expand All @@ -251,7 +255,7 @@ export const CancellableRequest = <T>(
cancel: source.cancel,
request: () =>
baseRequest({ ...config, cancelToken: source.token }).then(
(response) => response.data
(response) => response.data,
),
};
};
Expand Down
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))
Loading