-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.eslintrc.js
134 lines (124 loc) · 4.92 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
'use strict';
const nodeFiles = [
'.eslintrc.js',
'.lintstagedrc.js',
'.prettierrc.js',
'.template-lintrc.{js,ts}',
'ember-cli-build.{js,ts}',
'testem.{js,ts}',
'blueprints/*/index.{js,ts}',
'config/**/*.{js,ts}',
'lib/*/index.{js,ts}',
'server/**/*.{js,ts}',
'tests/dummy/config/**/*.{js,ts}',
];
const browserFiles = [
'addon/**/*.{js,ts}',
'addon-test-support/**/*.{js,ts}',
'app/**/*.{js,ts}',
'test-support/**/*.{js,ts}',
'types/**/*.{js,ts}',
];
const browserTestFiles = ['tests/**/*.{js,ts}'];
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true,
},
project: ['./tsconfig.json', './tsconfig-node.json'],
},
plugins: ['@typescript-eslint', 'ember', 'prettier'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:ember/recommended',
'standard',
'prettier',
// This one should come last
'plugin:prettier/recommended',
],
env: {
browser: true,
},
rules: {
'@typescript-eslint/ban-ts-comment': [
'error',
{ 'ts-expect-error': 'allow-with-description', 'ts-ignore': 'allow-with-description' },
],
'@typescript-eslint/camelcase': 'off', // Allow two levels of separation, e. g. ProductWizard_SidebarConfig_ListWithHeader_Component_Args
'@typescript-eslint/class-name-casing': 'off', // Allow two levels of separation, e. g. ProductWizard_SidebarConfig_ListWithHeader_Component_Args
'@typescript-eslint/no-empty-function': 'off', // Noop is a valid technique.
'@typescript-eslint/no-empty-interface': 'off', // Required for simplified typing of Mirage and Ember Data
'@typescript-eslint/no-non-null-assertion': 'off', // When I do it, I mean it.
'@typescript-eslint/no-unsafe-assignment': 'off', // Reenabled for TS files only
'@typescript-eslint/no-unsafe-call': 'off', // Reenabled for TS files only
'@typescript-eslint/no-unsafe-member-access': 'off', // Reenabled for TS files only
'@typescript-eslint/no-unsafe-return': 'off', // Reenabled for TS files only
'@typescript-eslint/no-unused-expressions': 'off', // Reenabled for non-tests only (Chai needs this disabled)
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-var-requires': 'off', // Reenabled for non-Node files only
// As this rule would freak out on JS files (by design!),
// it has to be enabled only for .ts in the overrides section,
// See https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md#configuring-in-a-mixed-jsts-codebase
'@typescript-eslint/explicit-function-return-type': 'off',
camelcase: 'off', // Have to keep this off for the TS equivalent to take precedence
'no-console': ['error', { allow: ['debug', 'error', 'info', 'warn'] }],
'no-unused-expressions': 'off',
'no-use-before-define': 'off', // We need circular references
'no-useless-constructor': 'off', // This rule crashes ESLint unless disabled
'node/no-unpublished-require': 'off', // Reenabled for non-Node files only
'prefer-const': 'error', // Only use `let` when you are actually mutating the variable
'prettier/prettier': 'error',
},
overrides: [
// node files
{
files: nodeFiles,
parserOptions: {
sourceType: 'script',
},
env: {
browser: false,
node: true,
},
plugins: ['node'],
extends: ['plugin:node/recommended'],
rules: {
// add your custom rules and overrides for node files here
'node/no-unsupported-features/es-syntax': ['error', { version: '>=12.0.0' }],
},
},
{
// browser files, including tests
files: [...browserFiles, ...browserTestFiles],
rules: {
'@typescript-eslint/no-var-requires': 'error', // Reenabled for non-Node files only
'node/no-unpublished-require': 'error', // Reenabled for non-Node files only
},
},
{
/// non-tests
files: [...nodeFiles, ...browserFiles],
rules: {
'@typescript-eslint/no-unused-expressions': 'error', // Reenabled for non-tests only (Chai needs this disabled)
},
},
{
// TS files
files: ['*.ts'],
rules: {
'@typescript-eslint/explicit-function-return-type': 'error', // We want to be strict with types
'@typescript-eslint/no-unsafe-assignment': 'error', // Reenabled for TS files only
'@typescript-eslint/no-unsafe-call': 'error', // Reenabled for TS files only
'@typescript-eslint/no-unsafe-member-access': 'error', // Reenabled for TS files only
'@typescript-eslint/no-unsafe-return': 'error', // Reenabled for TS files only
},
},
],
};