This repository was archived by the owner on May 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path.eslintrc.js
More file actions
157 lines (139 loc) · 4.35 KB
/
.eslintrc.js
File metadata and controls
157 lines (139 loc) · 4.35 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/**
* Copyright (c) 2020, 2022, Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
*/
/*
* The airbnb lint configuration is out of date, it refers to rules which have been
* removed. On extending 'airbnb-angular' we get lots of errors such as
* Definition for rule '@typescript-eslint/class-name-casing' was not found
* Definition for rule '@typescript-eslint/camelcase' was not found
*
* Instead we have copied code directly from the airbnb angular eslint file into this file
* the bits we have copied are the following
* - the 2 constants baseStyleRules & dangleRules
* - some of the rules in the rules section
* - the overrides section
*
* airbnb eslint file for angular:
* https://github.com/efoken/eslint-config-airbnb-angular/blob/master/rules/angular.js
*/
// eslint-disable-next-line import/no-extraneous-dependencies
const baseStyleRules = require('eslint-config-airbnb-base/rules/style').rules;
const dangleRules = baseStyleRules['no-underscore-dangle'];
module.exports = {
env: {
browser: true,
// es2021: true, // Environment key "es2021" is unknown
node: true,
},
extends: [
// 'airbnb-angular' // Oct 2020: airbnb needs updating, so we can not use it yet
'eslint-config-airbnb-base',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 12,
sourceType: 'module',
},
plugins: [
'@typescript-eslint',
'header',
],
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.component'],
},
},
},
// rules for all files (*.ts are overritten below)
//
rules: {
// our own rules
'no-empty-function': ['error', { allow: ['constructors'] }],
'@typescript-eslint/naming-convention': 'warn',
'header/header': [
2,
'block',
[
'*',
{
pattern: ' \\* Copyright \\(c\\) (\\d{4}, )+Oracle and/or its affiliates\\.',
},
' * Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/',
' ',
],
],
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
// airbnb angular rules
'class-methods-use-this': 'off',
'no-underscore-dangle': [
dangleRules[0],
{
...dangleRules[1],
},
],
'import/default': 'error',
'import/namespace': 'error',
'import/imports-first': 'error',
},
// override the above details for .ts files (copied from airbnb angular)
overrides: [
{
files: ['*.ts'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
rules: {
'no-unused-vars': ['error', { vars: 'all', args: 'none', ignoreRestSiblings: true }],
'no-useless-constructor': 'off',
// IMPORT
'import/prefer-default-export': 'off',
// TYPESCRIPT
'@typescript-eslint/adjacent-overload-signatures': 'error',
// '@typescript-eslint/class-name-casing': 'error', // no longer valid
'@typescript-eslint/member-delimiter-style': 'error',
'@typescript-eslint/member-ordering': [
'error',
{
default: [
'public-field',
'private-field',
'constructor',
'public-method',
'private-method',
],
},
],
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{ vars: 'all', args: 'none', ignoreRestSiblings: true },
],
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variable',
format: [],
},
],
},
},
],
};