Skip to content

Commit 4ae52d1

Browse files
authored
Update build, linter and formatter (#421)
* chore: update build, lint and formatter * chore: update exports with right ones
1 parent c135e28 commit 4ae52d1

File tree

82 files changed

+6816
-7895
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+6816
-7895
lines changed

.eslintrc.json

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

.npmignore

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
11
src
2-
test
2+
src/test
33
typings
44
bundled
55
build
66
coverage
77
docs
88
wiki
9-
bower.json
10-
karma.conf.js
119
tsconfig.json
12-
typings.json
1310
CONTRIBUTING.md
1411
ISSUE_TEMPLATE.md
1512
PULL_REQUEST_TEMPLATE.md
16-
tslint.json
17-
wallaby.js
18-
.travis.yml
1913
.gitignore
2014
.vscode
21-
type_definitions
22-
.eslintrc.json
2315
.github/

.publishrc

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

.travis.yml

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

eslint.config.js

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

eslint.config.mjs

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
// @ts-check
2+
3+
import eslint from '@eslint/js';
4+
import tseslint from 'typescript-eslint';
5+
import eslintPrettierConfig from 'eslint-plugin-prettier/recommended';
6+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
7+
8+
/**
9+
* @returns {import('typescript-eslint').ConfigWithExtends}
10+
*/
11+
function buildBaseConfig() {
12+
return {
13+
extends: [
14+
eslint.configs.recommended,
15+
...tseslint.configs.strictTypeChecked,
16+
],
17+
languageOptions: {
18+
parser: tseslint.parser,
19+
parserOptions: {
20+
project: './tsconfig.json',
21+
},
22+
},
23+
plugins: {
24+
'@typescript-eslint': tseslint.plugin,
25+
'simple-import-sort': simpleImportSort,
26+
},
27+
rules: {
28+
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
29+
'@typescript-eslint/explicit-member-accessibility': [
30+
'error',
31+
{
32+
overrides: {
33+
constructors: 'no-public',
34+
},
35+
},
36+
],
37+
'@typescript-eslint/member-ordering': ['warn'],
38+
'@typescript-eslint/naming-convention': [
39+
'error',
40+
{
41+
selector: ['classProperty'],
42+
format: ['strictCamelCase', 'UPPER_CASE', 'snake_case'],
43+
leadingUnderscore: 'allow',
44+
},
45+
{
46+
selector: 'typeParameter',
47+
format: ['StrictPascalCase'],
48+
prefix: ['T'],
49+
},
50+
{
51+
selector: ['typeLike'],
52+
format: ['StrictPascalCase'],
53+
},
54+
{
55+
selector: ['function', 'classMethod'],
56+
format: ['strictCamelCase'],
57+
leadingUnderscore: 'allow',
58+
},
59+
{
60+
selector: ['parameter'],
61+
format: ['strictCamelCase'],
62+
leadingUnderscore: 'allow',
63+
},
64+
{
65+
selector: ['variableLike'],
66+
format: ['strictCamelCase', 'UPPER_CASE', 'snake_case'],
67+
},
68+
],
69+
'@typescript-eslint/no-deprecated': 'error',
70+
'@typescript-eslint/no-duplicate-type-constituents': 'off',
71+
'@typescript-eslint/no-dynamic-delete': 'error',
72+
'@typescript-eslint/no-extraneous-class': 'off',
73+
'@typescript-eslint/no-inferrable-types': 'off',
74+
'@typescript-eslint/no-empty-interface': 'warn',
75+
'@typescript-eslint/no-explicit-any': 'error',
76+
'@typescript-eslint/no-floating-promises': ['error'],
77+
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
78+
'no-magic-numbers': 'off',
79+
'@typescript-eslint/no-magic-numbers': [
80+
'warn',
81+
{
82+
ignore: [0, 1],
83+
ignoreArrayIndexes: true,
84+
ignoreEnums: true,
85+
ignoreReadonlyClassProperties: true,
86+
},
87+
],
88+
'@typescript-eslint/no-require-imports': 'error',
89+
'@typescript-eslint/no-unnecessary-type-arguments': 'off',
90+
'@typescript-eslint/no-unused-expressions': ['error'],
91+
'@typescript-eslint/no-useless-constructor': 'error',
92+
'@typescript-eslint/prefer-for-of': 'error',
93+
'@typescript-eslint/prefer-nullish-coalescing': ['off'],
94+
'@typescript-eslint/prefer-optional-chain': 'off',
95+
'@typescript-eslint/prefer-readonly': ['warn'],
96+
'@typescript-eslint/promise-function-async': ['error'],
97+
'@typescript-eslint/require-await': 'off',
98+
'@typescript-eslint/restrict-plus-operands': [
99+
'error',
100+
{
101+
skipCompoundAssignments: false,
102+
},
103+
],
104+
'@typescript-eslint/typedef': [
105+
'error',
106+
{
107+
arrayDestructuring: true,
108+
arrowParameter: true,
109+
memberVariableDeclaration: true,
110+
objectDestructuring: true,
111+
parameter: true,
112+
propertyDeclaration: true,
113+
variableDeclaration: true,
114+
},
115+
],
116+
'@typescript-eslint/unified-signatures': 'error',
117+
'@typescript-eslint/strict-boolean-expressions': 'error',
118+
'@typescript-eslint/switch-exhaustiveness-check': [
119+
'error',
120+
{
121+
considerDefaultExhaustiveForUnions: true,
122+
},
123+
],
124+
'@typescript-eslint/no-unused-vars': [
125+
'warn',
126+
{
127+
args: 'all',
128+
argsIgnorePattern: '^_',
129+
caughtErrors: 'all',
130+
caughtErrorsIgnorePattern: '^_',
131+
destructuredArrayIgnorePattern: '^_',
132+
varsIgnorePattern: '^_',
133+
ignoreRestSiblings: true,
134+
},
135+
],
136+
'simple-import-sort/imports': [
137+
'error',
138+
{
139+
groups: [['^\\u0000'], ['^node:'], ['^@?\\w'], ['^'], ['^\\.']],
140+
},
141+
],
142+
'sort-keys': [
143+
'error',
144+
'asc',
145+
{
146+
caseSensitive: false,
147+
natural: true,
148+
},
149+
],
150+
},
151+
};
152+
}
153+
154+
const baseRules = buildBaseConfig();
155+
156+
const config = tseslint.config(
157+
{
158+
...baseRules,
159+
files: ['**/*.ts'],
160+
ignores: ['**/*.test.ts'],
161+
},
162+
{
163+
...baseRules,
164+
files: ['**/*.test.ts'],
165+
rules: {
166+
...(baseRules.rules ?? {}),
167+
'@typescript-eslint/no-confusing-void-expression': 'off',
168+
'@typescript-eslint/unbound-method': 'off',
169+
'@typescript-eslint/no-magic-numbers': 'off',
170+
},
171+
},
172+
/** @type {import('typescript-eslint').ConfigWithExtends} */ (
173+
eslintPrettierConfig
174+
),
175+
);
176+
177+
export default [...config];

jest.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
],
1414
"rootDir": ".",
1515
"setupFilesAfterEnv": [
16-
"<rootDir>/test/helpers/jest.setup.ts"
16+
"<rootDir>/src/test/helpers/jest.setup.ts"
1717
],
1818
"testEnvironment": "node",
1919
"testPathIgnorePatterns": [

0 commit comments

Comments
 (0)