Skip to content

Commit 905361b

Browse files
committed
Add new rule: no-await-sync-query
1 parent 1028841 commit 905361b

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

docs/rules/no-await-sync-query.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Disallow unnecessary `await` for sync queries (no-await-sync-query)
2+
3+
Please describe the origin of the rule here.
4+
5+
6+
## Rule Details
7+
8+
This rule aims to...
9+
10+
Examples of **incorrect** code for this rule:
11+
12+
```js
13+
14+
// fill me in
15+
16+
```
17+
18+
Examples of **correct** code for this rule:
19+
20+
```js
21+
22+
// fill me in
23+
24+
```
25+
26+
### Options
27+
28+
If there are any options, describe them here. Otherwise, delete this section.
29+
30+
## When Not To Use It
31+
32+
Give a short description of when it would be appropriate to turn off this rule.
33+
34+
## Further Reading
35+
36+
If there are other links that describe the issue this rule addresses, please include them here in a bulleted list.

lib/rules/no-await-sync-query.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @fileoverview Disallow unnecessary `await` for sync queries
3+
* @author Mario
4+
*/
5+
'use strict';
6+
7+
// ------------------------------------------------------------------------------
8+
// Rule Definition
9+
// ------------------------------------------------------------------------------
10+
11+
module.exports = {
12+
meta: {
13+
docs: {
14+
description: 'Disallow unnecessary `await` for sync queries',
15+
category: 'Fill me in',
16+
recommended: false,
17+
},
18+
fixable: null, // or "code" or "whitespace"
19+
schema: [
20+
// fill in your schema
21+
],
22+
},
23+
24+
create: function(context) {
25+
// variables should be defined here
26+
27+
// ----------------------------------------------------------------------
28+
// Helpers
29+
// ----------------------------------------------------------------------
30+
31+
// any helper functions should go here or else delete this section
32+
33+
// ----------------------------------------------------------------------
34+
// Public
35+
// ----------------------------------------------------------------------
36+
37+
return {
38+
// give me methods
39+
};
40+
},
41+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @fileoverview Disallow unnecessary `await` for sync queries
3+
* @author Mario
4+
*/
5+
'use strict';
6+
7+
// ------------------------------------------------------------------------------
8+
// Requirements
9+
// ------------------------------------------------------------------------------
10+
11+
var rule = require('../../../lib/rules/no-await-sync-query');
12+
var RuleTester = require('eslint').RuleTester;
13+
14+
// ------------------------------------------------------------------------------
15+
// Tests
16+
// ------------------------------------------------------------------------------
17+
18+
var ruleTester = new RuleTester();
19+
ruleTester.run('no-await-sync-query', rule, {
20+
valid: [
21+
// give me some code that won't trigger a warning
22+
],
23+
24+
invalid: [
25+
{
26+
code: "await getByText('foo')",
27+
errors: [
28+
{
29+
message: 'Fill me in.',
30+
type: 'Me too',
31+
},
32+
],
33+
},
34+
],
35+
});

0 commit comments

Comments
 (0)