Skip to content

Commit 7786f24

Browse files
committed
build: upgrade toolchain
- Prettier replaced with dprint - Fixed #32 as a bonus
1 parent 8992029 commit 7786f24

15 files changed

+2565
-3115
lines changed

.prettierrc.json

-6
This file was deleted.

.vscode/extensions.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"dbaeumer.vscode-eslint",
44
"eamodio.gitlens",
55
"streetsidesoftware.code-spell-checker",
6-
"esbenp.prettier-vscode",
6+
"dprint.dprint",
77
]
88
}

.vscode/settings.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
{
22
"typescript.tsdk": "node_modules/typescript/lib",
3-
"typescript.enablePromptUseWorkspaceTsdk": true
3+
"typescript.enablePromptUseWorkspaceTsdk": true,
4+
"[typescript]": {
5+
"editor.defaultFormatter": "dprint.dprint"
6+
},
7+
"[javascript]": {
8+
"editor.defaultFormatter": "dprint.dprint"
9+
},
10+
"[json]": {
11+
"editor.defaultFormatter": "dprint.dprint"
12+
}
413
}

dprint.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"typescript": {
3+
"arrowFunction.useParentheses": "preferNone",
4+
"lineWidth": 140,
5+
"quoteStyle": "preferSingle",
6+
"quoteProps": "consistent"
7+
},
8+
"json": {
9+
},
10+
"markdown": {
11+
},
12+
"excludes": [
13+
"**/node_modules",
14+
"**/*-lock.json"
15+
],
16+
"plugins": [
17+
"https://plugins.dprint.dev/typescript-0.94.0.wasm",
18+
"https://plugins.dprint.dev/json-0.20.0.wasm",
19+
"https://plugins.dprint.dev/markdown-0.18.0.wasm"
20+
]
21+
}

eslint.config.mjs

+38-46
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,52 @@
11
// @ts-check
22

3-
import { dirname } from 'path';
4-
import { fileURLToPath } from 'url';
5-
6-
import { FlatCompat } from '@eslint/eslintrc';
7-
import eslint from '@eslint/js';
8-
import prettierConfig from 'eslint-config-prettier';
9-
import eslintCommentsPlugin from 'eslint-plugin-eslint-comments';
10-
import * as importPlugin from 'eslint-plugin-import';
3+
import comments from '@eslint-community/eslint-plugin-eslint-comments/configs';
4+
import js from '@eslint/js';
5+
// @ts-ignore -- import is valid
6+
import importPlugin from 'eslint-plugin-import';
117
import tseslint from 'typescript-eslint';
128

13-
const __dirname = dirname(fileURLToPath(import.meta.url));
14-
15-
const compat = new FlatCompat({
16-
baseDirectory: __dirname,
17-
});
18-
199
export default tseslint.config(
10+
{ ignores: ['index.js'] },
2011
{
2112
files: ['src/**/*.?(c|m)js', '*.?(c|m)js', 'src/**/*.ts'],
22-
ignores: ['index.js'],
2313
extends: [
24-
eslint.configs.recommended,
25-
...compat.extends('plugin:eslint-comments/recommended'),
26-
...compat.extends('plugin:import/typescript'),
14+
js.configs.recommended,
15+
// @ts-ignore -- type is valid
16+
comments.recommended,
2717
],
28-
plugins: {
29-
'eslint-comments': eslintCommentsPlugin,
30-
'import': importPlugin,
31-
},
3218
rules: {
33-
'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }],
34-
'eslint-comments/no-unused-disable': 'error',
35-
36-
'import/order': [
37-
'error',
38-
{
39-
'newlines-between': 'always',
40-
'alphabetize': { order: 'asc' },
41-
},
42-
],
43-
44-
'sort-imports': [
45-
'error',
46-
{
47-
ignoreDeclarationSort: true,
48-
ignoreCase: true,
49-
},
50-
],
19+
'@eslint-community/eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }],
20+
'@eslint-community/eslint-comments/no-unused-disable': 'error',
5121
},
5222
},
23+
// TODO Make eslint-plugin-import work with JS files (like this one)
5324
{
5425
files: ['src/**/*.ts'],
5526
extends: [
56-
//...tseslint.configs.recommended,
57-
//...tseslint.configs.recommendedTypeChecked,
58-
...tseslint.configs.strictTypeChecked,
59-
...tseslint.configs.stylisticTypeChecked,
27+
importPlugin.flatConfigs.recommended,
28+
importPlugin.flatConfigs.typescript,
29+
// ...tseslint.configs.recommended,
30+
...tseslint.configs.recommendedTypeChecked,
31+
// ...tseslint.configs.strictTypeChecked,
32+
// ...tseslint.configs.stylisticTypeChecked,
6033
],
6134
languageOptions: {
6235
parserOptions: {
6336
project: './tsconfig.test.json',
64-
tsconfigRootDir: __dirname,
37+
// projectService: {
38+
// defaultProject: './tsconfig.test.json',
39+
// },
40+
tsconfigRootDir: import.meta.dirname,
41+
},
42+
},
43+
settings: {
44+
'import/parsers': {
45+
'@typescript-eslint/parser': ['.ts', '.tsx'],
46+
},
47+
'import/resolver': {
48+
typescript: true,
49+
node: true,
6550
},
6651
},
6752
rules: {
@@ -84,7 +69,14 @@ export default tseslint.config(
8469
allowShortCircuit: true,
8570
},
8671
],
72+
73+
'import/order': [
74+
'error',
75+
{
76+
'newlines-between': 'always',
77+
'alphabetize': { order: 'asc' },
78+
},
79+
],
8780
},
8881
},
89-
prettierConfig,
9082
);

0 commit comments

Comments
 (0)