Skip to content

Commit 8c42446

Browse files
dreamorosiCopilotsdangol
authored
ci: improve linting checks (#4545)
Co-authored-by: Copilot <[email protected]> Co-authored-by: Swopnil Dangol <[email protected]>
1 parent 0ab1bd6 commit 8c42446

File tree

193 files changed

+1488
-1521
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+1488
-1521
lines changed

.github/workflows/reusable-run-linting-check-and-unit-tests.yml

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -85,66 +85,51 @@ jobs:
8585
run:
8686
working-directory: examples/${{ matrix.example }}
8787
steps:
88-
- name: Checkout code
88+
- &checkout_code
89+
name: Checkout code
8990
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
90-
- name: Setup NodeJS
91-
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
91+
- &setup_node
92+
name: Setup Node.js
93+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
9294
with:
9395
node-version: 22
9496
cache: "npm"
95-
- name: Setup dependencies
97+
- &setup_dependencies
98+
name: Setup dependencies
9699
uses: aws-powertools/actions/.github/actions/cached-node-modules@29979bc5339bf54f76a11ac36ff67701986bb0f0
97100
- name: Run linting
98-
run: npm run lint
101+
run: npm run lint:ci
99102
- name: Run tests
100103
run: npm t
101104
check-layer-publisher:
102105
runs-on: ubuntu-latest
103106
env:
104107
NODE_ENV: dev
105108
steps:
106-
- name: Checkout code
107-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
108-
- name: Setup NodeJS
109-
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
110-
with:
111-
node-version: 22
112-
cache: "npm"
113-
- name: Setup dependencies
114-
uses: aws-powertools/actions/.github/actions/cached-node-modules@29979bc5339bf54f76a11ac36ff67701986bb0f0
109+
- *checkout_code
110+
- *setup_node
111+
- *setup_dependencies
115112
- name: Run linting
116-
run: npm run lint -w layers
113+
run: npm run lint:ci -w layers
117114
- name: Run tests
118115
run: npm run test:unit -w layers
119116
check-docs-snippets:
120117
runs-on: ubuntu-latest
121118
env:
122119
NODE_ENV: dev
123120
steps:
124-
- name: Checkout code
125-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
126-
- name: Setup NodeJS
127-
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
128-
with:
129-
node-version: 22
130-
cache: "npm"
131-
- name: Setup dependencies
132-
uses: aws-powertools/actions/.github/actions/cached-node-modules@29979bc5339bf54f76a11ac36ff67701986bb0f0
121+
- *checkout_code
122+
- *setup_node
123+
- *setup_dependencies
133124
- name: Run linting
134-
run: npm run lint -w examples/snippets
125+
run: npm run lint:ci -w examples/snippets
135126
check-docs:
136127
runs-on: ubuntu-latest
137128
env:
138129
NODE_ENV: dev
139130
steps:
140-
- name: Checkout code
141-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
142-
- name: Setup NodeJS
143-
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
144-
with:
145-
node-version: 22
146-
cache: "npm"
147-
- name: Setup dependencies
148-
uses: aws-powertools/actions/.github/actions/cached-node-modules@29979bc5339bf54f76a11ac36ff67701986bb0f0
131+
- *checkout_code
132+
- *setup_node
133+
- *setup_dependencies
149134
- name: Run linting
150135
run: npm run lint:markdown

biome.json

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.0.6/schema.json",
2+
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3+
"root": true,
34
"assist": {
45
"actions": {
56
"source": {
@@ -22,6 +23,32 @@
2223
"useNumberNamespace": "error",
2324
"noInferrableTypes": "error",
2425
"noUselessElse": "error"
26+
},
27+
"suspicious": {
28+
"noTsIgnore": "error",
29+
"noConfusingVoidType": "error",
30+
"noDoubleEquals": "error",
31+
"noGlobalIsNan": "error",
32+
"noGlobalIsFinite": "error",
33+
"useNumberToFixedDigitsArgument": "error",
34+
"noPrototypeBuiltins": "error",
35+
"noSkippedTests": "error",
36+
"noFocusedTests": "error",
37+
"noUnassignedVariables": "error",
38+
"noVar": "error",
39+
"useAdjacentOverloadSignatures": "error",
40+
"useAwait": "error",
41+
"useErrorMessage": "error",
42+
"useIsArray": "error",
43+
"useStaticResponseMethods": "error"
44+
},
45+
"correctness": {
46+
"useParseIntRadix": "error",
47+
"useSingleJsDocAsterisk": "error",
48+
"noUnusedVariables": "error",
49+
"noUnusedPrivateClassMembers": "error",
50+
"noUnusedImports": "error",
51+
"noUnusedFunctionParameters": "error"
2552
}
2653
}
2754
},

docs/features/event-handler/appsync-events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ When processing batch of items with `aggregate` enabled, you must format the pay
210210

211211
=== "Error handling with batch of items"
212212

213-
```typescript hl_lines="21-24"
213+
```typescript hl_lines="25-28"
214214
--8<-- "examples/snippets/event-handler/appsync-events/errorHandlingWithBatchOfItems.ts"
215215
```
216216

docs/features/event-handler/appsync-graphql.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ You can use an AppSync JavaScript resolver or a VTL response mapping template to
176176

177177
=== "Exception Handling response"
178178

179-
```json hl_lines="11 20"
179+
```json hl_lines="9 18"
180180
--8<-- "examples/snippets/event-handler/appsync-graphql/exceptionHandlingResponse.json"
181181
```
182182

docs/features/event-handler/rest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ You can enable response compression by using the `compress` middleware. This wil
479479

480480
=== "Response"
481481

482-
```json hl_lines="7-9 11 12"
482+
```json hl_lines="4-5 7-8"
483483
--8<-- "examples/snippets/event-handler/rest/samples/advanced_compress_res.json"
484484
```
485485

docs/features/tracer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ You can trace other class methods using the `captureMethod` decorator or any arb
230230

231231
=== "Manual"
232232

233-
```typescript hl_lines="7-13 19 22 26-31"
233+
```typescript hl_lines="7-10 16 21 25 27"
234234
--8<-- "examples/snippets/tracer/captureMethodManual.ts"
235235
```
236236

examples/app/functions/process-items-stream.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,19 @@ export const handler = async (
8383
event: DynamoDBStreamEvent,
8484
context: Context
8585
): Promise<DynamoDBBatchResponse> => {
86-
return tracer.provider.captureAsyncFunc('### handler', async (segment) => {
87-
const result = await processPartialResponse(
88-
event,
89-
recordHandler,
90-
processor,
91-
{ context }
92-
);
86+
return (await tracer.provider.captureAsyncFunc(
87+
'### handler',
88+
async (segment) => {
89+
const result = await processPartialResponse(
90+
event,
91+
recordHandler,
92+
processor,
93+
{ context }
94+
);
9395

94-
segment?.close();
96+
segment?.close();
9597

96-
return result;
97-
}) as DynamoDBBatchResponse;
98+
return result;
99+
}
100+
)) as DynamoDBBatchResponse;
98101
};

examples/app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"test": "npm run test:unit",
1414
"lint": "biome lint .",
1515
"lint:fix": "biome check --write .",
16+
"lint:ci": "biome ci .",
1617
"test:unit": "export POWERTOOLS_DEV=true && vitest --run --silent",
1718
"test:e2e": "echo 'To be implemented ...'",
1819
"cdk": "cdk"

examples/snippets/batch/advancedTracingRecordHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const recordHandler = async (record: SQSRecord): Promise<void> => {
2222
// do something with the item
2323
subsegment?.addMetadata('item', item);
2424
} catch (error) {
25-
subsegment?.addError(error);
25+
subsegment?.addError(error as Error);
2626
throw error;
2727
}
2828
}

examples/snippets/biome.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "../../node_modules/@biomejs/biome/configuration_schema.json",
3+
"extends": "//",
4+
"root": false,
5+
"linter": {
6+
"rules": {
7+
"suspicious": {
8+
"useAwait": "off"
9+
}
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)