Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
How to disable
@typescript-eslint/explicit-function-return-type
for
some()
,
filter()
,
forEach()
?
It's very annoying to declare a
boolean
return type for
some()
and
filter()
and
void
for
forEach()
every time.
Invalid
[2, 5, 8, 1, 4].some(elem => elem > 10)
Valid
[2, 5, 8, 1, 4].some((elem):boolean => elem > 10)
I want to be able to use the first pattern (marked "invalid") without getting errors from this rule.
This is how .eslintrc
should be configured for rule @typescript-eslint/explicit-function-return-type
"@typescript-eslint/explicit-function-return-type": "off",
"overrides": [
"files": ["*.ts", "*.tsx"],
"parser": "@typescript-eslint/parser",
"rules": {
"@typescript-eslint/explicit-function-return-type": [
"error",
"allowExpressions": true
Examples of correct code for this rule with { allowExpressions: true }:
node.addEventListener('click', () => {});
node.addEventListener('click', function() {});
const foo = arr.map(i => i * i);
More info see documentation for allowExpressions.
–
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
"@typescript-eslint/explicit-module-boundary-types": {
"allowExpressions": true
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.