Skip to content

Commit 675c963

Browse files
committed
feat: add no-async-functions rule
1 parent 07c28bb commit 675c963

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
recommended: require('./config')
66
},
77
rules: {
8-
'jsx-uses-vars': require('./rules/jsx-uses-vars')
8+
'jsx-uses-vars': require('./rules/jsx-uses-vars'),
9+
'no-async-functions': require('./rules/no-async-functions')
910
}
1011
}

rules/no-async-functions.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module.exports = {
2+
meta: {
3+
docs: {
4+
description: 'Disallow use of async functions (for codebases targeting Node 6.x)',
5+
category: 'Custom',
6+
recommended: false
7+
},
8+
schema: []
9+
},
10+
11+
create (context) {
12+
function report (node) {
13+
if (node.async) {
14+
context.report({
15+
node,
16+
message: "async functions are disallowed for Node 6.x compatibility."
17+
})
18+
}
19+
}
20+
21+
return {
22+
FunctionDeclaration: report,
23+
FunctionExpression: report,
24+
ArrowFunctionExpression: report
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy