Skip to content

Commit a9ee170

Browse files
authored
Eslint ts config (#3)
* Override lint config for .ts, .test.ts files * Bump package version
1 parent d9544d4 commit a9ee170

4 files changed

Lines changed: 38 additions & 26 deletions

File tree

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pi-base/dev",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"description": "Developer utilities for pi-base packages",
55
"keywords": [
66
"Node"

src/eslint.js

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ const js = {
1010
],
1111
extends: [
1212
'eslint:recommended',
13-
'plugin:prettier/recommended',
14-
'plugin:@typescript-eslint/recommended',
15-
'plugin:@typescript-eslint/recommended-requiring-type-checking'
13+
'plugin:prettier/recommended'
1614
],
1715
rules: {
1816
"jest/no-focused-tests": "error",
@@ -23,24 +21,37 @@ const js = {
2321
},
2422
}
2523

24+
const ts = {
25+
...js,
26+
files: ["**/*.ts", "**/*.tsx"],
27+
parser: '@typescript-eslint/parser',
28+
parserOptions: {
29+
project: './tsconfig.json'
30+
},
31+
plugins: [...js.plugins, '@typescript-eslint'],
32+
extends: [
33+
...js.extends,
34+
'plugin:@typescript-eslint/recommended',
35+
'plugin:@typescript-eslint/recommended-requiring-type-checking'
36+
]
37+
}
38+
39+
const tsTest = {
40+
...ts,
41+
files: ["**/*.test.ts", "**/*.test.tsx"],
42+
rules: {
43+
...ts.rules,
44+
// Allow test matches to fail and cause an error in the test
45+
'@typescript-eslint/no-non-null-assertion': 'off',
46+
}
47+
}
48+
2649
module.exports = {
2750
...js,
2851
ignorePatterns: ['*.d.ts'],
2952
extends: [
3053
'eslint:recommended',
3154
'plugin:prettier/recommended',
3255
],
33-
overrides: [{
34-
files: ["**/*.ts", "**/*.tsx"],
35-
parser: '@typescript-eslint/parser',
36-
parserOptions: {
37-
project: './tsconfig.json'
38-
},
39-
plugins: [...js.plugins, '@typescript-eslint'],
40-
extends: [
41-
...js.extends,
42-
'plugin:@typescript-eslint/recommended',
43-
'plugin:@typescript-eslint/recommended-requiring-type-checking'
44-
]
45-
}]
56+
overrides: [ts, tsTest]
4657
}

tsconfig.shared.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"noUnusedParameters": true,
1515
},
1616
"include": [
17-
"src/**/*.ts"
17+
"src/**/*.ts",
18+
"src/*.ts"
1819
],
1920
"exclude": [
2021
"node_modules"

0 commit comments

Comments
 (0)