Skip to content

Commit f13ceb9

Browse files
committed
Set up linter, introduce cst types, improve recovery
1 parent e506313 commit f13ceb9

26 files changed

Lines changed: 10345 additions & 4793 deletions

eslint.config.ts

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import js from "@eslint/js"
2+
import tseslint from "typescript-eslint"
3+
import prettier from "eslint-plugin-prettier"
4+
import prettierConfig from "eslint-config-prettier"
5+
import globals from "globals"
6+
import { Linter } from "eslint"
7+
8+
export default [
9+
{
10+
ignores: ["dist/", "node_modules/", "eslint.config.ts", "src/parser/cst-types.d.ts"],
11+
},
12+
{
13+
files: ["**/*.{js,ts}"],
14+
languageOptions: {
15+
globals: {
16+
...globals.node,
17+
...globals.es2020,
18+
},
19+
ecmaVersion: 2020,
20+
sourceType: "module",
21+
},
22+
plugins: {
23+
prettier,
24+
},
25+
rules: {
26+
"prettier/prettier": "warn",
27+
},
28+
},
29+
{
30+
files: ["src/**/*.ts"],
31+
languageOptions: {
32+
parser: tseslint.parser,
33+
parserOptions: {
34+
project: "./tsconfig.json",
35+
tsconfigRootDir: import.meta.dirname,
36+
},
37+
},
38+
plugins: {
39+
"@typescript-eslint": tseslint.plugin,
40+
},
41+
rules: {
42+
...js.configs.recommended.rules,
43+
...tseslint.configs.recommended.reduce(
44+
(acc, config) => ({ ...acc, ...config.rules }),
45+
{} as Linter.RulesRecord,
46+
),
47+
...tseslint.configs.recommendedTypeChecked.reduce(
48+
(acc, config) => ({ ...acc, ...config.rules }),
49+
{} as Linter.RulesRecord,
50+
),
51+
52+
"@typescript-eslint/explicit-function-return-type": "off",
53+
"@typescript-eslint/explicit-module-boundary-types": "off",
54+
"@typescript-eslint/no-unused-vars": [
55+
"error",
56+
{
57+
caughtErrors: "none",
58+
argsIgnorePattern: "^_",
59+
},
60+
],
61+
"@typescript-eslint/strict-boolean-expressions": "off",
62+
"@typescript-eslint/consistent-type-definitions": "off",
63+
"@typescript-eslint/no-misused-promises": [
64+
"error",
65+
{
66+
checksVoidReturn: false,
67+
},
68+
],
69+
70+
"quote-props": ["error", "as-needed"],
71+
"object-shorthand": ["error", "always"],
72+
"no-unused-vars": "off",
73+
"no-var": ["error"],
74+
"no-console": [
75+
"warn",
76+
{
77+
allow: ["warn", "error", "info"],
78+
},
79+
],
80+
// NaN is used as a Chevrotain token name (SQL NaN keyword)
81+
"no-shadow-restricted-names": "off",
82+
},
83+
},
84+
85+
prettierConfig,
86+
] satisfies Linter.Config[]

package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
"test": "vitest run",
1818
"test:watch": "vitest",
1919
"test:coverage": "vitest run --coverage",
20-
"clean": "rm -rf dist coverage"
20+
"clean": "rm -rf dist coverage",
21+
"lint": "eslint src/",
22+
"lint:fix": "eslint src/ --fix"
2123
},
2224
"keywords": [
2325
"questdb",
@@ -41,9 +43,17 @@
4143
"chevrotain": "^11.1.1"
4244
},
4345
"devDependencies": {
46+
"@eslint/js": "^10.0.1",
4447
"@types/jest": "^30.0.0",
4548
"@types/node": "^25.2.0",
49+
"eslint": "^10.0.0",
50+
"eslint-config-prettier": "^10.1.8",
51+
"eslint-plugin-prettier": "^5.5.5",
52+
"globals": "^17.3.0",
53+
"jiti": "^2.6.1",
54+
"prettier": "^3.8.1",
4655
"typescript": "^5.9.3",
56+
"typescript-eslint": "^8.55.0",
4757
"vitest": "^4.0.18"
4858
}
4959
}

prettier.config.cjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module.exports = {
2+
arrowParens: "always",
3+
endOfLine: "auto",
4+
proseWrap: "always",
5+
trailingComma: "all",
6+
semi: false,
7+
overrides: [
8+
{
9+
files: "*.js",
10+
options: {
11+
parser: "babel",
12+
},
13+
},
14+
{
15+
files: "*.md",
16+
options: {
17+
parser: "markdown",
18+
},
19+
},
20+
{
21+
files: "*.ts",
22+
options: {
23+
parser: "typescript",
24+
},
25+
},
26+
{
27+
files: "*.yml",
28+
options: {
29+
parser: "yaml",
30+
},
31+
},
32+
],
33+
}

0 commit comments

Comments
 (0)