forked from Agoric/agoric-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.cjs
110 lines (108 loc) · 3.35 KB
/
.eslintrc.cjs
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
/* eslint-env node */
const process = require('process');
const lintTypes = !!process.env.AGORIC_ESLINT_TYPES;
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: lintTypes
? {
sourceType: 'module',
project: [
'./packages/*/jsconfig.json',
'./packages/*/tsconfig.json',
'./packages/wallet/*/jsconfig.json',
'./tsconfig.json',
],
tsconfigRootDir: __dirname,
extraFileExtensions: ['.cjs'],
}
: undefined,
plugins: [
'@jessie.js/eslint-plugin',
'@typescript-eslint',
'eslint-plugin-import',
'eslint-plugin-prettier',
],
extends: ['@agoric'],
rules: {
'@typescript-eslint/prefer-ts-expect-error': 'warn',
'@typescript-eslint/no-floating-promises': lintTypes ? 'warn' : 'off',
// so that floating-promises can be explicitly permitted with void operator
'no-void': ['error', { allowAsStatement: true }],
// Not severe but the default 'warning' clutters output and it's easy to fix
'jsdoc/check-param-names': 'error',
'jsdoc/no-multi-asterisks': 'off',
'jsdoc/multiline-blocks': 'off',
// Use these rules to warn about JSDoc type problems, such as after
// upgrading eslint-plugin-jsdoc.
// Bump the 1's to 2's to get errors.
// "jsdoc/valid-types": 1,
// "jsdoc/no-undefined-types": [1, {"definedTypes": ["never", "unknown"]}],
'jsdoc/tag-lines': 'off',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'**/*.config.js',
'**/*.config.*.js',
'**/*test*/**/*.js',
'**/demo*/**/*.js',
'**/scripts/**/*.js',
],
},
],
// CI has a separate format check but keep this warn to maintain that "eslint --fix" prettifies
// UNTIL https://github.com/Agoric/agoric-sdk/issues/4339
'prettier/prettier': 'warn',
},
settings: {
jsdoc: {
mode: 'typescript',
},
},
ignorePatterns: [
'coverage/**',
'**/output/**',
'bundles/**',
'bundle-*',
'dist/**',
'examples/**',
'test262/**',
'*.html',
'ava*.config.js',
],
overrides: [
{
// Tighten rules for exported code.
files: ['packages/*/src/**/*.js'],
rules: {
// The rule is “no nested awaits” but the architectural goal is
// “no possibility of ‘awaits sometimes but not always’”. That is our
// architectural rule. If it’s too constraining you have to fall back to
// promise.then or get a reviewed exception. “sometimes awaits” is a
// bug farm for particularly pernicious bugs in which you can combine
// two correct pieces of code to have emergent incorrect behavior.
// It’s absolutely critical for shared service code. That means
// contracts, but it also means kernel components that are used by
// multiple clients. So we enable it throughout the repo and exceptions
// are code-reviewed.
// TODO upgrade this to 'error'
'@jessie.js/no-nested-await': 'warn',
},
},
{
files: ['*.ts'],
rules: {
// TS has this covered and eslint gets it wrong
'no-undef': 'off',
},
},
{
// disable type-aware linting in HTML
files: ['*.html'],
parserOptions: {
project: false,
},
},
],
};