-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
88 lines (85 loc) · 2.68 KB
/
index.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
const eslintConfigXoTypescript = require('eslint-config-xo-typescript');
const ruleBanTypeOverride = eslintConfigXoTypescript.rules['@typescript-eslint/ban-types'];
delete ruleBanTypeOverride[1].types.null;
const ruleNamingConventionOverride = eslintConfigXoTypescript.rules['@typescript-eslint/naming-convention'];
ruleNamingConventionOverride[1].format = [
'strictCamelCase',
'snake_case',
];
module.exports = {
overrides: [
{
files: ['*.{js,ts}'],
plugins: ['import', 'promise'],
extends: ['xo', 'plugin:promise/recommended'],
rules: {
// Disable because sometimes we need to comment some code.
'capitalized-comments': 'off',
// Console should not be used in project. Instead use our internal logger.
'no-console': 'error',
// Override from eslint-config-xo to avoid unnecessary newline in file.
'object-curly-newline': [
'error',
{
consistent: true,
},
],
// For each require/import, we should a explicit file extension.
'import/extensions': [
'error',
'ignorePackages',
],
// No duplicate in import
'import/no-duplicates': 'error',
// Order import by alphabet and groups ('builtin', 'external', 'internal', etc)
'import/order': [
'error',
{
alphabetize: {
order: 'asc',
},
},
],
// Override from eslint-config-xo to allow Typebox usage.
'new-cap': [
'error',
{
newIsCap: true,
capIsNew: true,
capIsNewExceptionPattern: '^Type\\..',
},
],
},
},
{
files: ['*.js'],
rules: {
// Use space indent instead of tab.
indent: [2, 2, {SwitchCase: 1}],
// Avoid error on legacy but keep warning.
camelcase: 'warn',
'prefer-promise-reject-errors': 'warn',
'promise/no-return-wrap': 'warn',
// Expressjs have a unused params "next" in middleware.
'no-unused-vars': [
'error',
{
argsIgnorePattern: 'next',
},
],
},
},
{
files: ['*.ts'],
extends: ['xo-typescript/space'],
rules: {
// Override naming convention rule to allow `snake_case`.
'@typescript-eslint/naming-convention': ruleNamingConventionOverride,
// Override this rule to allow usage of null and undefined.
'@typescript-eslint/ban-types': ruleBanTypeOverride,
// Disable this rule because we need interface and type.
'@typescript-eslint/consistent-type-definitions': 'off',
},
},
],
};