Skip to content

Commit

Permalink
chore: modernize linting to use eslint 9 (#459)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Uzlopak and dependabot[bot] authored Aug 11, 2024
1 parent de15400 commit f15c7d2
Show file tree
Hide file tree
Showing 20 changed files with 398 additions and 850 deletions.
31 changes: 0 additions & 31 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion bench/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from "assert";
import assert from "assert";
import { spawnSync } from "child_process";
import { existsSync } from "fs";
import { resolve } from "path";
Expand Down
2 changes: 0 additions & 2 deletions bin/build_wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ if (!platform && process.argv[2]) {
if (process.argv[2] === '--prebuild') {
const cmd = `docker build --platform=${platform.toString().trim()} -t llhttp_wasm_builder .`;

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

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

// eslint-disable-next-line no-console
console.log(`> ${cmd}\n\n`);
execSync(cmd, { cwd: WASM_SRC, stdio: 'inherit' });
process.exit(0);
Expand Down
2 changes: 1 addition & 1 deletion bin/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { dirname, resolve } from 'path';
import { CHeaders, HTTP } from '../src/llhttp';

// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
// eslint-disable-next-line max-len
// eslint-disable-next-line @stylistic/js/max-len
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-]+)*))?$/;

const C_FILE = resolve(__dirname, '../build/c/llhttp.c');
Expand Down
66 changes: 66 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import stylisticJs from '@stylistic/eslint-plugin-js'
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import globals from 'globals';

export default tseslint.config(
{ ignores: ["lib", "examples", "bench"] },
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
{
"languageOptions": {
"parser": tseslint.parser,
"parserOptions": {
"lib": ["es2023"],
"module": "commonjs",
"moduleResolution": "node",
"target": "es2022",

"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"include": [
"bin/**/*.ts",
"src/**/*.ts",
"test/**/*.ts"
],
"outDir": "./lib",
"declaration": true,
"pretty": true,
"sourceMap": true
},
"globals": {
...globals.commonjs,
...globals.node,
...globals.es6
},
},
},
{
plugins: {
'@stylistic/js': stylisticJs
},
files: [
"bin/**/*.ts",
'bench/**/*.ts',
'src/**/*.ts',
'test/**/*.ts',
],
rules: {
'@stylistic/js/max-len': [ 2, {
'code': 120,
'ignoreComments': true
} ],
"@stylistic/js/array-bracket-spacing": ["error", "always"],
"@stylistic/js/operator-linebreak": ["error", "after"],
"@stylistic/js/linebreak-style": ["error", "unix"],
"@stylistic/js/brace-style": ["error", "1tbs", { "allowSingleLine": true }],
'@stylistic/js/indent': ["error", 2, {
"SwitchCase": 1,
"FunctionDeclaration": { "parameters": "first" },
"FunctionExpression": { "parameters": "first" }
}],
}
}
);
50 changes: 0 additions & 50 deletions eslint.json

This file was deleted.

2 changes: 1 addition & 1 deletion examples/wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import { readFileSync } from 'fs';
import { resolve } from 'path';
import * as constants from '../build/wasm/constants';
import constants from '../build/wasm/constants';

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

0 comments on commit f15c7d2

Please sign in to comment.