Skip to content

Commit abf1609

Browse files
authored
build(lint): use strict eslint rules [EDS-310] (#11)
1 parent edf0913 commit abf1609

File tree

10 files changed

+1066
-649
lines changed

10 files changed

+1066
-649
lines changed

actions/inputs.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ export function getMapInput(name: string): Record<string, string> {
1616
return Object.fromEntries(
1717
core
1818
.getMultilineInput(name, { trimWhitespace: true })
19-
.map((assigment) => assigment.split(':'))
20-
.map(([key, value]) => [key?.trim(), value?.trim()])
21-
.filter(([key, value]) => key && value),
19+
.reduce<Array<[string, string]>>((acc, line) => {
20+
const [key, value] = line.split(':');
21+
22+
if (key && value) {
23+
acc.push([key.trim(), value.trim()]);
24+
}
25+
26+
return acc;
27+
}, []),
2228
);
2329
}

actions/setup-elementor-env/dist/index.cjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import { run } from './main';
22

3-
run();
3+
void run();

actions/setup-elementor-env/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export async function run() {
9999
}
100100
}
101101

102+
// eslint-disable-next-line @typescript-eslint/require-await -- `core.group` requires a promise.
102103
async function parseInputs() {
103104
try {
104105
const parsed = z
@@ -138,7 +139,7 @@ async function parseInputs() {
138139

139140
if (error instanceof z.ZodError) {
140141
message = `${message}: ${error.errors
141-
.map((error) => `${error.path} - ${error.message}`)
142+
.map((e) => `${e.path.join(', ')} - ${e.message}`)
142143
.join('\n')}`;
143144
}
144145

actions/setup-wp-env/dist/index.cjs

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

actions/setup-wp-env/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import { run } from './main';
22

3-
run();
3+
void run();

actions/setup-wp-env/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export async function run() {
6969
}
7070
}
7171

72+
// eslint-disable-next-line @typescript-eslint/require-await -- `core.group` requires a promise.
7273
async function parseInputs() {
7374
try {
7475
return z
@@ -97,7 +98,7 @@ async function parseInputs() {
9798

9899
if (error instanceof z.ZodError) {
99100
message = `${message}: ${error.errors
100-
.map((error) => `${error.path} - ${error.message}`)
101+
.map((e) => `${e.path.join(', ')} - ${e.message}`)
101102
.join('\n')}`;
102103
}
103104

eslint.config.mjs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import globals from 'globals';
2-
import pluginJs from '@eslint/js';
2+
import eslint from '@eslint/js';
33
import tseslint from 'typescript-eslint';
44

5-
export default [
6-
{ files: ['**/*.{js,mjs,cjs,ts}'] },
7-
{ languageOptions: { globals: globals.browser } },
8-
pluginJs.configs.recommended,
9-
...tseslint.configs.recommended,
5+
export default tseslint.config(
6+
eslint.configs.recommended,
7+
...tseslint.configs.strictTypeChecked,
8+
{
9+
languageOptions: {
10+
globals: globals.node,
11+
parserOptions: {
12+
project: true,
13+
tsconfigRootDir: import.meta.dirname,
14+
},
15+
},
16+
},
1017
{
1118
ignores: [
1219
'**/coverage/**',
@@ -15,4 +22,4 @@ export default [
1522
'**/__snapshots__/**',
1623
],
1724
},
18-
];
25+
);

0 commit comments

Comments
 (0)