Skip to content

Commit 26fcfd7

Browse files
authored
prettier, eslint-import-resolver-typescript (#347)
1 parent b19afa2 commit 26fcfd7

File tree

11 files changed

+65
-90
lines changed

11 files changed

+65
-90
lines changed

.eslintrc.json

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
"eslint:recommended",
44
"plugin:@typescript-eslint/recommended",
55
"plugin:import/recommended",
6-
"plugin:prettier/recommended"
6+
"plugin:import/typescript",
7+
"prettier"
78
],
9+
"settings": {
10+
"import/parsers": {
11+
"@typescript-eslint/parser": [".ts"]
12+
},
13+
"import/resolver": {
14+
"typescript": true,
15+
"node": true
16+
}
17+
},
818
"plugins": ["@typescript-eslint", "import"],
919
"parser": "@typescript-eslint/parser",
10-
"parserOptions": {
11-
"ecmaVersion": 2020,
12-
"project": "./tsconfig.json",
13-
"sourceType": "module"
14-
},
1520
"env": {
1621
"es2020": true,
1722
"node": true
@@ -27,7 +32,6 @@
2732
"import/no-duplicates": "off",
2833
"import/no-import-module-exports": "warn",
2934
"import/no-relative-packages": "warn",
30-
"import/no-unresolved": "off",
3135
"import/no-unused-modules": "error",
3236
"import/order": [
3337
"warn",
@@ -44,19 +48,8 @@
4448
"no-sparse-arrays": 0,
4549
"no-unexpected-multiline": 0,
4650
"object-shorthand": ["warn", "always"],
47-
"prettier/prettier": ["warn", {"embeddedLanguageFormatting": "off"}],
4851
"sort-imports": ["warn", {"ignoreDeclarationSort": true}],
4952
"quotes": ["warn", "double", {"avoidEscape": true}]
5053
},
51-
"overrides": [
52-
{
53-
"files": ["public/**"],
54-
"env": {
55-
"es2020": true,
56-
"node": false,
57-
"browser": true
58-
}
59-
}
60-
],
6154
"root": true
6255
}

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
- run: |
2222
echo ::add-matcher::.github/eslint.json
2323
yarn run eslint src test --format=compact
24+
- run: yarn test:prettier
2425
- uses: actions/upload-artifact@v3
2526
if: failure()
2627
with:

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
"dev": "tsx watch ./bin/observable.ts preview",
2626
"build": "rm -rf dist && ./bin/observable.ts build",
2727
"deploy": "./bin/observable.ts deploy",
28-
"test": "yarn test:mocha && yarn test:tsc && yarn test:lint",
28+
"test": "yarn test:mocha && yarn test:tsc && yarn test:lint && yarn test:prettier",
2929
"test:coverage": "c8 yarn test:mocha",
3030
"test:mocha": "rm -rf test/.observablehq/cache test/input/build/*/.observablehq/cache && tsx --no-warnings=ExperimentalWarning ./node_modules/.bin/mocha 'test/**/*-test.*'",
3131
"test:lint": "eslint src test",
32+
"test:prettier": "prettier --check src test",
3233
"test:tsc": "tsc --noEmit",
3334
"observable": "tsx ./bin/observable.ts"
3435
},
@@ -83,9 +84,9 @@
8384
"d3-array": "^3.2.4",
8485
"d3-dsv": "^3.0.1",
8586
"eslint": "^8.50.0",
86-
"eslint-config-prettier": "^9.0.0",
87+
"eslint-config-prettier": "^9.1.0",
88+
"eslint-import-resolver-typescript": "^3.6.1",
8789
"eslint-plugin-import": "^2.29.0",
88-
"eslint-plugin-prettier": "^5.0.0",
8990
"mocha": "^10.2.0",
9091
"prettier": "^3.0.3 <3.1",
9192
"typescript": "^5.2.2",

src/client/.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"env": {
33
"browser": true
4+
},
5+
"rules": {
6+
"import/no-unresolved": [2, {"ignore": ["^npm:", "^observablehq:"]}]
47
}
58
}

src/html.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable import/no-named-as-default-member */
12
import he from "he";
23

34
/**

src/info.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable import/no-named-as-default-member */
12
import he from "he";
23

34
const //

test/preview/dashboard/404.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# 404 page
1+
# 404 page

test/preview/dashboard/code/code.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
This text is not visible by default.
88
</details>
99

10-
1110
# Graphviz
1211

1312
```dot echo
14-
strict graph {
13+
strict graph {
1514
a -- b
1615
a -- b
1716
b -- a [color=blue]
@@ -23,4 +22,3 @@
2322
```tex
2423
E = mc^2
2524
```
26-

test/preview/dashboard/index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Index
22

33
```js
4-
import formatTitle from "./format.js"
5-
display(formatTitle('index'));
6-
```
4+
import formatTitle from "./format.js";
5+
6+
display(formatTitle("index"));
7+
```

tsconfig.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
{
2-
"$schema": "https://json.schemastore.org/tsconfig",
3-
"display": "Node LTS",
4-
"_version": "18.1.0",
52
"compilerOptions": {
63
"noImplicitAny": false,
7-
"lib": ["es2023", "DOM.Iterable"],
8-
"module": "node16",
9-
"target": "es2022",
4+
"lib": ["ES2023", "DOM.Iterable"],
5+
"module": "Node16",
6+
"target": "ES2022",
107
"strict": true,
118
"esModuleInterop": true,
129
"skipLibCheck": true,
13-
"forceConsistentCasingInFileNames": true,
14-
"moduleResolution": "node16",
1510
"resolveJsonModule": true
1611
}
1712
}

0 commit comments

Comments
 (0)