Skip to content

Commit 879af71

Browse files
authored
lint: enable eslint-plugin-unicorn rules #4369
Also allows removal of the "no-null" package, which is not maintained (and the unicorn version better by avoiding false positives).
1 parent c343a03 commit 879af71

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+358
-254
lines changed

.eslintrc.js

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ module.exports = {
22
root: true,
33
parser: '@typescript-eslint/parser',
44
parserOptions: {
5+
ecmaVersion: 'latest',
6+
sourceType: 'module',
57
project: './tsconfig.json',
68
tsconfigRootDir: __dirname,
79
},
810
env: {
911
node: true,
1012
mocha: true,
13+
es2024: true,
1114
},
12-
plugins: ['@typescript-eslint', 'header', 'no-null', 'aws-toolkits'],
15+
plugins: ['@typescript-eslint', 'unicorn', 'header', 'aws-toolkits'],
1316
extends: [
1417
'eslint:recommended',
1518
'plugin:@typescript-eslint/eslint-recommended',
@@ -90,7 +93,6 @@ module.exports = {
9093
'@typescript-eslint/no-namespace': 'error',
9194
// This is off because prettier takes care of it
9295
'no-extra-semi': 'off',
93-
'no-null/no-null': 'error',
9496
'@typescript-eslint/no-empty-function': 'off',
9597
'@typescript-eslint/no-unused-vars': 'off',
9698
'@typescript-eslint/no-floating-promises': 'error', // Promises must catch errors or be awaited.
@@ -105,6 +107,39 @@ module.exports = {
105107
// Do not check loops so while(true) works. Potentially reevalute this.
106108
'no-constant-condition': ['error', { checkLoops: false }],
107109
'no-empty': 'off',
110+
111+
// Rules from https://github.com/sindresorhus/eslint-plugin-unicorn
112+
// TODO: 'unicorn/no-useless-promise-resolve-reject': 'error',
113+
// TODO: 'unicorn/prefer-at': 'error',
114+
// TODO: 'unicorn/prefer-event-target': 'error',
115+
// TODO: 'unicorn/prefer-negative-index': 'error',
116+
// TODO: 'unicorn/prefer-string-slice': 'error',
117+
// TODO: 'unicorn/prefer-regexp-test': 'error',
118+
// TODO: 'unicorn/prefer-ternary': 'error',
119+
// TODO(?): 'unicorn/custom-error-definition': 'error',
120+
// TODO(?): 'unicorn/prefer-json-parse-buffer': 'error',
121+
// TODO: ESM modules https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-module.md
122+
// 'unicorn/prefer-module': 'error',
123+
'unicorn/no-abusive-eslint-disable': 'error',
124+
'unicorn/no-null': 'error',
125+
'unicorn/no-unnecessary-polyfills': 'error',
126+
'unicorn/no-useless-spread': 'error',
127+
'unicorn/prefer-array-some': 'error',
128+
'unicorn/prefer-blob-reading-methods': 'error',
129+
'unicorn/prefer-code-point': 'error',
130+
'unicorn/prefer-date-now': 'error',
131+
'unicorn/prefer-dom-node-text-content': 'error',
132+
'unicorn/prefer-includes': 'error',
133+
'unicorn/prefer-keyboard-event-key': 'error',
134+
'unicorn/prefer-modern-dom-apis': 'error',
135+
'unicorn/prefer-modern-math-apis': 'error',
136+
'unicorn/prefer-native-coercion-functions': 'error',
137+
// 'unicorn/prefer-node-protocol': 'error',
138+
// 'unicorn/prefer-object-from-entries': 'error',
139+
'unicorn/prefer-reflect-apply': 'error',
140+
'unicorn/prefer-string-trim-start-end': 'error',
141+
'unicorn/prefer-type-error': 'error',
142+
108143
'header/header': [
109144
'error',
110145
'block',

0 commit comments

Comments
 (0)