Skip to content

Commit e21240d

Browse files
committed
chore: initialise repository for TypeScript
1 parent 65f09ad commit e21240d

File tree

7 files changed

+7320
-1935
lines changed

7 files changed

+7320
-1935
lines changed

.eslintrc.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,27 @@ const defaultConfig = {
99
node: true,
1010
},
1111
rules: {
12+
'no-restricted-globals': [
13+
'error',
14+
/**
15+
* From Jest global environment.
16+
* https://github.com/facebook/jest/blob/v26.4.2/packages/jest-globals/src/index.ts#L12-L27
17+
*/
18+
'jest',
19+
'expect',
20+
'it',
21+
'test',
22+
'fit',
23+
'xit',
24+
'xtest',
25+
'describe',
26+
'xdescribe',
27+
'fdescribe',
28+
'beforeAll',
29+
'beforeEach',
30+
'afterEach',
31+
'afterAll',
32+
],
1233
'prettier/prettier': 'error',
1334
'sort-imports': 'error',
1435
},
@@ -42,6 +63,17 @@ function addToDefaultExtends(...configurations) {
4263

4364
const config = defaultConfig;
4465
config.overrides = [
66+
{
67+
files: ['**/*.ts', '**/*.tsx'],
68+
extends: addToDefaultExtends(
69+
'plugin:@typescript-eslint/recommended',
70+
'prettier/@typescript-eslint',
71+
'plugin:jest/style',
72+
),
73+
parser: '@typescript-eslint/parser',
74+
plugins: defaultConfig.plugins.concat(['@typescript-eslint']),
75+
rules: { ...defaultConfig.rules, 'jest/consistent-test-it': 'error' },
76+
},
4577
{
4678
files: ['**/*.json'],
4779
extends: addToDefaultExtends('plugin:json/recommended'),

.lintstagedrc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
module.exports = {
2-
'*.{ts,tsx,js,jsx,json}': ['npm run format:file', 'npm run lint-es:file:fix'],
2+
'*.{ts,tsx,js,jsx,json}': [
3+
'npm run format:file',
4+
'npm run lint-es:file:fix',
5+
'npm run test:staged',
6+
],
37
'*.{vue,css,less,scss,html,htm,md,markdown,yml,yaml}': [
48
'npm run format:file',
59
],

jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
collectCoverage: true,
3+
collectCoverageFrom: ['src/**/*.ts'],
4+
coverageDirectory: 'coverage',
5+
coverageReporters: ['cobertura', 'lcov', 'text'],
6+
preset: 'ts-jest',
7+
roots: ['<rootDir>/src'],
8+
};

0 commit comments

Comments
 (0)