Repository navigation
Expand file tree
/
Copy patheslint.config.mjs
More file actions
134 lines (128 loc) · 5.15 KB
/
Copy patheslint.config.mjs
File metadata and controls
134 lines (128 loc) · 5.15 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
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import typescriptParser from '@typescript-eslint/parser';
import unicorn from 'eslint-plugin-unicorn';
export default [
// TODO: enable js.configs.recommended and typescript-eslint "recommended".
{
files: ['packages/neovim/bin/cli.js', '**/*.ts'],
ignores: [
'**/*.d.ts',
// TODO: these are probably broken because they don't end with "**"?
// irrelevant for now because --ignore-pattern is specified in the "lint" task directly.
'packages/*/lib/',
'packages/*/bin/',
'packages/neovim/scripts/',
'packages/integration-tests/__tests__/',
'examples/rplugin/node/',
'packages/example-plugin/',
'packages/example-plugin-decorators/',
],
languageOptions: {
parser: typescriptParser,
parserOptions: {
project: './tsconfig.json',
ecmaVersion: 'latest',
sourceType: 'module',
},
},
plugins: {
'@typescript-eslint': typescriptEslint,
unicorn,
},
linterOptions: {
reportUnusedDisableDirectives: true,
},
rules: {
curly: 'error', // Enforce braces on "if"/"for"/etc.
// Avoid accidental use of "==" instead of "===".
eqeqeq: 'error',
camelcase: ['error', { properties: 'never' }],
'class-methods-use-this': 'off',
'comma-dangle': [
'error',
{
arrays: 'only-multiline',
objects: 'only-multiline',
imports: 'only-multiline',
exports: 'only-multiline',
functions: 'ignore',
},
],
'no-restricted-syntax': 'off',
'no-case-declarations': 'off',
'no-prototype-builtins': 'off',
'no-underscore-dangle': 'off',
'no-mixed-operators': 'off',
'func-names': 'off',
'max-classes-per-file': 'off',
'operator-assignment': ['error', 'never'],
// For overloading (and typescript throws when dupe members anyway)
'no-dupe-class-members': 'off',
// Causes issues with enums
'no-shadow': 'off',
'prefer-destructuring': 'off', // Intentionally disabled trash.
'global-require': 'error',
'new-cap': 'error',
'no-console': 'error',
'no-param-reassign': ['error', { props: true }],
'no-void': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
// TODO: '@typescript-eslint/no-floating-promises': 'error', // Promises must catch errors or be awaited.
// TODO? '@typescript-eslint/no-unsafe-assignment': 'error',
// TODO? '@typescript-eslint/no-unsafe-return': 'error',
// TODO? '@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
// Rules from https://github.com/sindresorhus/eslint-plugin-unicorn
// TODO: 'unicorn/no-useless-promise-resolve-reject': 'error',
// TODO: 'unicorn/prefer-event-target': 'error',
// TODO: 'unicorn/prefer-string-slice': 'error',
// TODO? 'unicorn/custom-error-definition': 'error',
// TODO? 'unicorn/prefer-json-parse-buffer': 'error',
// TODO? ESM modules https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-module.md
// 'unicorn/prefer-module': 'error',
// 'unicorn/no-null': 'error',
'unicorn/no-abusive-eslint-disable': 'error',
'unicorn/prefer-at': 'error',
'unicorn/prefer-negative-index': 'error',
'unicorn/prefer-regexp-test': 'error',
'unicorn/prefer-ternary': 'error',
'unicorn/no-unnecessary-polyfills': 'error',
'unicorn/no-useless-spread': 'error',
'unicorn/prefer-array-some': 'error',
'unicorn/prefer-blob-reading-methods': 'error',
'unicorn/prefer-code-point': 'error',
'unicorn/prefer-date-now': 'error',
'unicorn/prefer-dom-node-text-content': 'error',
'unicorn/prefer-includes': 'error',
'unicorn/prefer-keyboard-event-key': 'error',
'unicorn/prefer-modern-dom-apis': 'error',
'unicorn/prefer-modern-math-apis': 'error',
'unicorn/prefer-native-coercion-functions': 'error',
'unicorn/prefer-node-protocol': 'error',
'unicorn/prefer-object-from-entries': 'error',
'unicorn/prefer-reflect-apply': 'error',
'unicorn/prefer-string-trim-start-end': 'error',
'unicorn/prefer-type-error': 'error',
},
},
{
files: ['**/*.test.ts'],
rules: {
// This rule requires es2022(?) but the CI node14 job runs the tests
// in node14, but the test code is not compiled/polyfilled... so the
// test code needs to be compatible with node14.
// TODO: can the back-compat CI jobs for older node.js versions run
// `jest` against the compiled .js results (would require compiling
// the test files as well)?
'unicorn/prefer-at': 'off',
'new-cap': 'off',
},
},
];