mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
meta: add a eslint config that can find unused variables in our typescript
This commit is contained in:
BIN
src/js/bun.lockb
Executable file
BIN
src/js/bun.lockb
Executable file
Binary file not shown.
11
src/js/eslint.config.mjs
Normal file
11
src/js/eslint.config.mjs
Normal file
@@ -0,0 +1,11 @@
|
||||
import globals from "globals";
|
||||
import tseslint from "typescript-eslint";
|
||||
|
||||
export default [
|
||||
{ files: ["internal/**/*.ts"] },
|
||||
{ files: ["node/**/*.ts"] },
|
||||
{ ignores: ["thirdparty"] },
|
||||
{ languageOptions: { globals: globals.browser } },
|
||||
{ languageOptions: { parser: tseslint.parser } },
|
||||
{ rules: { "no-unused-vars": "error" } },
|
||||
];
|
||||
18
src/js/eslint.fmt.mjs
Normal file
18
src/js/eslint.fmt.mjs
Normal file
@@ -0,0 +1,18 @@
|
||||
export default function (results) {
|
||||
const sgr = c => "\x1b" + "[" + c + "m";
|
||||
const reset = sgr(0);
|
||||
const gray = s => sgr(2) + s + reset;
|
||||
const green = s => sgr(32) + s + reset;
|
||||
const cyan = s => sgr(36) + s + reset;
|
||||
|
||||
for (const item of results) {
|
||||
if (item.messages.length === 0) {
|
||||
continue;
|
||||
}
|
||||
for (const jtem of item.messages) {
|
||||
console.log(
|
||||
`.${item.filePath.substring(process.cwd().length)}:${green(jtem.line)}:${cyan(jtem.column)}: ${gray(jtem.ruleId)} ${jtem.message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
8
src/js/package.json
Normal file
8
src/js/package.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"scripts": {
|
||||
"lint": "bun run eslint --format ./eslint.fmt.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"typescript-eslint": "^8.8.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user