-
Notifications
You must be signed in to change notification settings - Fork 135
/
.eslintrc.js
105 lines (105 loc) · 4.16 KB
/
.eslintrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/** @type { import('eslint').Linter.Config } */
module.exports = {
root: true,
ignorePatterns: ['node_modules', 'dist'],
parserOptions: {
ecmaVersion: 2020,
},
extends: [
// Turn on on eslint recommended rules https://github.com/eslint/eslint/blob/main/conf/eslint-recommended.js
'eslint:recommended',
// Turn off eslint rules that conflict with prettier https://github.com/prettier/eslint-config-prettier/blob/main/index.js
'prettier',
],
overrides: [
{
files: ['*.{ts,tsx}'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: [
'./tsconfig.json',
'./packages/*/tsconfig.json',
'./playgrounds/*/tsconfig.json',
],
},
extends: [
// Disable rules from eslint:recommended which are already handled by TypeScript. Enables eslint (@not typescript-eslint) rules that make sense due to TS's typechecking / transpilation.
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended.ts
'plugin:@typescript-eslint/eslint-recommended',
// Enable recommended rules from @typescript-eslint
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended.ts
'plugin:@typescript-eslint/recommended',
// Handle prettier rules through eslint https://github.com/prettier/eslint-plugin-prettier/blob/master/eslint-plugin-prettier.js#L65
'plugin:prettier/recommended',
// add special jest rules https://github.com/jest-community/eslint-plugin-jest#rules
'plugin:jest/recommended',
],
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-floating-promises': [
'error',
{
ignoreVoid: true,
},
],
'require-await': 'off',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-types': 'off', // TODO: turn on
/** jest */
'jest/valid-title': 'off', // allow functions to be used as describe titles
'jest/no-conditional-expect': 'off', // best practice, but TODO
'jest/no-alias-methods': 'off', // best practice, but TODO
'jest/expect-expect': 'off', // sometimes we compose assertion functions
'jest/no-disabled-tests': process.env.CI ? 'error' : 'off', // fail CI if tests are disabled, but do not interfere with local development
'jest/no-focused-tests': process.env.CI ? 'error' : 'off',
},
overrides: [
{
files: ['**/src/**'],
rules: {
'@typescript-eslint/no-restricted-imports': [
'error',
{
paths: [
{
// Prevent accidental imports from 'lodash'
name: 'lodash',
message:
'Lodash should only be used for dev-related things, and not in any public library src code (e.g. @segment/analytics-next)',
},
],
},
],
},
},
{
files: ['**/__tests__/**', '**/scripts/**'],
rules: {
'require-await': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-restricted-imports': 'off',
},
},
],
},
{
files: ['*.{js,mjs}'],
env: {
// Config files and possible scripts. Allow anything, we don't really care.
browser: true,
node: true,
},
extends: [
// Handle prettier rules through eslint https://github.com/prettier/eslint-plugin-prettier/blob/master/eslint-plugin-prettier.js#L65
'plugin:prettier/recommended',
],
},
],
}