Skip to content

Commit 7ceebba

Browse files
committed
fix: relax return type linting rules
1 parent 31caf5f commit 7ceebba

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

eslint.config.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function addRule (rules, name, value) {
2222
const ruleSet = config.find(c => c.name === rules)
2323

2424
assert.ok(ruleSet, `No ruleset with name ${rules} found`)
25-
assert.notDeepEqual(ruleSet.rules?.[name], value, `${rules}/${name} is already set to ${value}`)
25+
assert.notDeepEqual(ruleSet.rules?.[name], value, `${rules}/${name} is already set to ${JSON.stringify(value, null, 2)}`)
2626

2727
ruleSet.rules ??= {}
2828
ruleSet.rules[name] = value
@@ -103,18 +103,34 @@ setParser('neostandard/ts', eslintParser, {
103103
ecmaVersion: 'latest'
104104
})
105105

106+
// TODO: not compatible with ESLint 9x yet
106107
// addPlugin('neostandard/ts', 'etc', etc)
107-
108108
// addRule('neostandard/ts', 'etc/prefer-interface', 'error') // https://ncjamieson.com/prefer-interfaces/
109+
110+
addRule('neostandard/ts', '@typescript-eslint/no-use-before-define', [
111+
'error', {
112+
functions: false,
113+
classes: false,
114+
enums: false,
115+
variables: false,
116+
typedefs: false,
117+
}
118+
]) // Types often are recursive & no use before define is too restrictive
109119
addRule('neostandard/ts', '@typescript-eslint/prefer-function-type', 'off') // conflicts with 'etc/prefer-interface'
110-
addRule('neostandard/ts', '@typescript-eslint/explicit-function-return-type', 'error') // functions require return types
120+
addRule('neostandard/ts', '@typescript-eslint/explicit-function-return-type', [
121+
'error', {
122+
allowExpressions: true,
123+
allowHigherOrderFunctions: true,
124+
allowTypedFunctionExpressions: true,
125+
allowDirectConstAssertionInArrowFunctions: true
126+
}
127+
]) // functions require return types
111128
addRule('neostandard/ts', '@typescript-eslint/no-this-alias', 'off') // allow 'const self = this'
112129
addRule('neostandard/ts', '@typescript-eslint/await-thenable', 'error') // disallows awaiting a value that is not a "Thenable"
113130
addRule('neostandard/ts', '@typescript-eslint/restrict-template-expressions', 'off') // allow values with `any` type in template literals
114131
addRule('neostandard/ts', '@typescript-eslint/method-signature-style', ['error', 'method']) // enforce method signature style
115132
addRule('neostandard/ts', '@typescript-eslint/no-unsafe-argument', 'off') // allow passing argswith `any` type to functions
116133
addRule('neostandard/ts', '@typescript-eslint/unbound-method', 'off') // allow invoking functions that may be unbound (e.g. passed as part of an options object)
117-
addRule('neostandard/ts', '@typescript-eslint/no-unused-vars', 'error') // disallow unused variables
118134
addRule('neostandard/ts', 'no-return-await', 'off') // disable this rule to use @typescript-eslint/return-await instead
119135
addRule('neostandard/ts', '@typescript-eslint/return-await', ['error', 'in-try-catch']) // require awaiting thenables returned from try/catch
120136
addRule('neostandard/ts', 'jsdoc/require-param', 'off') // do not require jsdoc for params

src/config/tsconfig.aegir.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"forceConsistentCasingInFileNames": true,
2727
"skipLibCheck": true,
2828
"stripInternal": true,
29-
"resolveJsonModule": true
29+
"resolveJsonModule": true,
30+
"rewriteRelativeImportExtensions": true
3031
},
3132
"include": [
3233
"src",

0 commit comments

Comments
 (0)