Skip to content

Commit 2f35738

Browse files
committed
Update linting setup
1 parent 9122fdf commit 2f35738

17 files changed

+757
-2442
lines changed

.config/tsconfig.base.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"noUncheckedIndexedAccess": true,
2828

2929
/* Additional checks */
30+
"importsNotUsedAsValues": "remove",
3031
"noUnusedLocals": true,
3132
"noUnusedParameters": true
3233
}

.eslintignore

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

.eslintrc.js

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

.oxlintrc.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"settings": {},
3+
"rules": {
4+
"consistent-function-scoping": "allow",
5+
"no-async-endpoint-handlers": "allow",
6+
"no-await-in-loop": "allow",
7+
"no-control-regex": "allow",
8+
"no-empty-file": "allow",
9+
"no-extraneous-class": "allow",
10+
"no-new": "allow",
11+
"no-new-array": "allow",
12+
"no-this-alias": ["deny"],
13+
"no-unused-vars": "allow"
14+
}
15+
}

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.github/
22
coverage/
33
**/dist
4-
scripts/
54
package-lock.json

.prettierrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"arrowParens": "avoid",
33
"semi": false,
44
"singleQuote": true,
5-
"jsxSingleQuote": true,
65
"trailingComma": "none",
76
"printWidth": 80
87
}

.taprc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ color: true
44
include:
55
- test/**/*.test.ts
66
exclude:
7-
- dist/**
7+
- test/dist/**
88
tsconfig: .config/tsconfig.tap.json
99
typecheck: false
1010
allow-incomplete-coverage: true

eslint.config.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
'use strict'
2+
3+
const path = require('node:path')
4+
5+
const { includeIgnoreFile } = require('@eslint/compat')
6+
const tsEslint = require('typescript-eslint')
7+
const tsParser = require('@typescript-eslint/parser')
8+
9+
const gitignorePath = path.resolve(__dirname, '.gitignore')
10+
const prettierignorePath = path.resolve(__dirname, '.prettierignore')
11+
12+
module.exports = [
13+
includeIgnoreFile(gitignorePath),
14+
includeIgnoreFile(prettierignorePath),
15+
{
16+
files: ['src/**/*.ts', 'test/**/*.ts'],
17+
languageOptions: {
18+
parser: tsParser,
19+
parserOptions: {
20+
projectService: {
21+
allowDefaultProject: ['test/*.ts'],
22+
defaultProject: 'tsconfig.json',
23+
tsconfigRootDir: __dirname
24+
}
25+
}
26+
},
27+
plugins: {
28+
'@typescript-eslint': tsEslint.plugin
29+
},
30+
linterOptions: {
31+
reportUnusedDisableDirectives: 'off'
32+
},
33+
rules: {
34+
'@typescript-eslint/no-floating-promises': ['error'],
35+
'@typescript-eslint/no-misused-promises': ['error'],
36+
// Returning unawaited promises in a try/catch/finally is dangerous
37+
// (the `catch` won't catch if the promise is rejected, and the `finally`
38+
// won't wait for the promise to resolve). Returning unawaited promises
39+
// elsewhere is probably fine, but this lint rule doesn't have a way
40+
// to only apply to try/catch/finally (the 'in-try-catch' option *enforces*
41+
// not awaiting promises *outside* of try/catch/finally, which is not what
42+
// we want), and it's nice to await before returning anyways, since you get
43+
// a slightly more comprehensive stack trace upon promise rejection.
44+
'@typescript-eslint/return-await': ['error', 'always'],
45+
'no-warning-comments': ['warn', { terms: ['fixme'] }]
46+
}
47+
},
48+
{
49+
files: ['test/**/*.ts'],
50+
rules: {
51+
'@typescript-eslint/no-floating-promises': 'off'
52+
}
53+
},
54+
{
55+
files: ['scripts/**/*.js', 'test/**/*.cjs'],
56+
rules: {
57+
'no-warning-comments': ['warn', { terms: ['fixme'] }]
58+
}
59+
}
60+
]

0 commit comments

Comments
 (0)