Skip to content

Commit f15c7d2

Browse files
chore: modernize linting to use eslint 9 (#459)
* build(deps-dev): bump @typescript-eslint/eslint-plugin Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 7.10.0 to 8.0.1. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.0.1/packages/eslint-plugin) --- updated-dependencies: - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * fix * chore: modernize linting to use eslint 9 * Apply suggestions from code review * fix more --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent de15400 commit f15c7d2

20 files changed

+398
-850
lines changed

.eslintrc.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

bench/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as assert from "assert";
1+
import assert from "assert";
22
import { spawnSync } from "child_process";
33
import { existsSync } from "fs";
44
import { resolve } from "path";

bin/build_wasm.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ if (!platform && process.argv[2]) {
1313
if (process.argv[2] === '--prebuild') {
1414
const cmd = `docker build --platform=${platform.toString().trim()} -t llhttp_wasm_builder .`;
1515

16-
// eslint-disable-next-line no-console
1716
console.log(`> ${cmd}\n\n`);
1817
execSync(cmd, { stdio: 'inherit' });
1918

@@ -43,7 +42,6 @@ if (process.argv[2] === '--docker') {
4342
}
4443
cmd += ` --mount type=bind,source=${WASM_SRC}/build,target=/home/node/llhttp/build llhttp_wasm_builder npm run wasm`;
4544

46-
// eslint-disable-next-line no-console
4745
console.log(`> ${cmd}\n\n`);
4846
execSync(cmd, { cwd: WASM_SRC, stdio: 'inherit' });
4947
process.exit(0);

bin/generate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { dirname, resolve } from 'path';
66
import { CHeaders, HTTP } from '../src/llhttp';
77

88
// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
9-
// eslint-disable-next-line max-len
9+
// eslint-disable-next-line @stylistic/js/max-len
1010
const semverRE = /^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
1111

1212
const C_FILE = resolve(__dirname, '../build/c/llhttp.c');

eslint.config.mjs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import stylisticJs from '@stylistic/eslint-plugin-js'
2+
import eslint from '@eslint/js';
3+
import tseslint from 'typescript-eslint';
4+
import globals from 'globals';
5+
6+
export default tseslint.config(
7+
{ ignores: ["lib", "examples", "bench"] },
8+
eslint.configs.recommended,
9+
...tseslint.configs.recommended,
10+
...tseslint.configs.stylistic,
11+
{
12+
"languageOptions": {
13+
"parser": tseslint.parser,
14+
"parserOptions": {
15+
"lib": ["es2023"],
16+
"module": "commonjs",
17+
"moduleResolution": "node",
18+
"target": "es2022",
19+
20+
"strict": true,
21+
"esModuleInterop": true,
22+
"skipLibCheck": true,
23+
"include": [
24+
"bin/**/*.ts",
25+
"src/**/*.ts",
26+
"test/**/*.ts"
27+
],
28+
"outDir": "./lib",
29+
"declaration": true,
30+
"pretty": true,
31+
"sourceMap": true
32+
},
33+
"globals": {
34+
...globals.commonjs,
35+
...globals.node,
36+
...globals.es6
37+
},
38+
},
39+
},
40+
{
41+
plugins: {
42+
'@stylistic/js': stylisticJs
43+
},
44+
files: [
45+
"bin/**/*.ts",
46+
'bench/**/*.ts',
47+
'src/**/*.ts',
48+
'test/**/*.ts',
49+
],
50+
rules: {
51+
'@stylistic/js/max-len': [ 2, {
52+
'code': 120,
53+
'ignoreComments': true
54+
} ],
55+
"@stylistic/js/array-bracket-spacing": ["error", "always"],
56+
"@stylistic/js/operator-linebreak": ["error", "after"],
57+
"@stylistic/js/linebreak-style": ["error", "unix"],
58+
"@stylistic/js/brace-style": ["error", "1tbs", { "allowSingleLine": true }],
59+
'@stylistic/js/indent': ["error", 2, {
60+
"SwitchCase": 1,
61+
"FunctionDeclaration": { "parameters": "first" },
62+
"FunctionExpression": { "parameters": "first" }
63+
}],
64+
}
65+
}
66+
);

eslint.json

Lines changed: 0 additions & 50 deletions
This file was deleted.

examples/wasm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
import { readFileSync } from 'fs';
99
import { resolve } from 'path';
10-
import * as constants from '../build/wasm/constants';
10+
import constants from '../build/wasm/constants';
1111

1212
const bin = readFileSync(resolve(__dirname, '../build/wasm/llhttp.wasm'));
1313
const mod = new WebAssembly.Module(bin);

0 commit comments

Comments
 (0)