-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.eslintrc.cjs
152 lines (132 loc) · 3.5 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
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
module.exports = {
root: true,
ignorePatterns: [
'**/*.*',
'!**/*.js',
'!**/*.cjs',
'coverage',
'node_modules',
'dist',
],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
env: {
browser: true,
es2021: true,
},
extends: [
'eslint:recommended',
'plugin:jsdoc/recommended-typescript-flavor',
'plugin:unicorn/recommended',
'plugin:@stylistic/disable-legacy',
'prettier-standard/prettier-file',
],
plugins: ['@stylistic', '@stylistic/migrate'],
settings: {
jsdoc: {
mode: 'typescript',
},
},
// Keep rules grouped by plugin and sorted alphabetically
rules: {
// Sort import members
'sort-imports': [
'error',
{
ignoreDeclarationSort: true,
},
],
/* @stylistic/eslint-plugin */
'@stylistic/migrate/migrate-js': 'error',
'@stylistic/padding-line-between-statements': [
'error',
/* Empty line before if statement */
{ blankLine: 'always', prev: '*', next: 'if' },
/* Empty line before return */
{ blankLine: 'always', prev: '*', next: 'return' },
/* Empty line after const, let */
{ blankLine: 'always', prev: ['const', 'let'], next: '*' },
{ blankLine: 'any', prev: ['const', 'let'], next: ['const', 'let'] },
/* Empty line between case and default inside switch */
{ blankLine: 'always', prev: 'case', next: ['case', 'default'] },
],
/* eslint-plugin-jsdoc */
// Descriptions should be sentence-like not comment-like
'jsdoc/require-description-complete-sentence': 'warn',
'jsdoc/require-hyphen-before-param-description': [
'error',
'never',
{ tags: { property: 'never' } },
],
// Empty line after description
'jsdoc/tag-lines': [
'error',
'never',
{
startLines: 1,
tags: { description: { lines: 'always', count: 1 } },
},
],
// Adding JSDoc is preferable but not required
'jsdoc/require-jsdoc': 'off',
'jsdoc/require-param-description': 'off',
'jsdoc/require-property-description': 'off',
'jsdoc/require-returns-description': 'off',
'jsdoc/require-returns': 'off',
/* eslint-plugin-unicorn */
// I like reduce
'unicorn/no-array-reduce': 'off',
/* eslint-plugin-import */
// Require extension for imports. Required by Node.js with `type: "module"`
'import/extensions': ['error', 'always', { ignorePackages: true }],
// Force using only named exports. Default export allowed for a module main export
'import/no-default-export': 'error',
'import/newline-after-import': 'error',
// Sort imports
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'type',
],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: false,
},
},
],
/* eslint-plugin-prettier */
'prettier/prettier': 'warn',
},
overrides: [
// Test files
{
files: 'tests/**/*',
extends: ['plugin:ava/recommended'],
},
// Config CommonJS
{
files: '*.cjs',
rules: {
/* eslint-plugin-unicorn */
'unicorn/prefer-module': 'off',
},
},
// Config ES module
{
files: '*.config.js',
rules: {
// Acceptable export type is not controlled for config files
'import/no-default-export': 'off',
},
},
],
}