Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 581005a

Browse files
committedDec 4, 2018
feat: init no-this-in-fetch
1 parent cb03b4d commit 581005a

6 files changed

+121
-4
lines changed
 

‎docs/rules/no-this-in-async-data.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Preventing using this in asyncData (no-this-in-async-data)
1+
# Prevent using this in asyncData (no-this-in-async-data)
22

33
Please describe the origin of the rule here.
44

‎docs/rules/no-this-in-fetch.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Prevent using this in fetch (no-this-in-fetch)
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-this-in-async-data.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @fileoverview Preventing using this in asyncData
2+
* @fileoverview Prevent using this in asyncData
33
* @author Clark Du
44
*/
55
"use strict";
@@ -11,7 +11,7 @@
1111
module.exports = {
1212
meta: {
1313
docs: {
14-
description: "Preventing using this in asyncData",
14+
description: "Prevent using this in asyncData",
1515
category: "Fill me in",
1616
recommended: false
1717
},

‎lib/rules/no-this-in-fetch.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* @fileoverview Prevent using this in fetch
3+
* @author Clark Du
4+
*/
5+
"use strict";
6+
7+
//------------------------------------------------------------------------------
8+
// Rule Definition
9+
//------------------------------------------------------------------------------
10+
11+
module.exports = {
12+
meta: {
13+
docs: {
14+
description: "Prevent using this in fetch",
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+
26+
// variables should be defined here
27+
28+
//----------------------------------------------------------------------
29+
// Helpers
30+
//----------------------------------------------------------------------
31+
32+
// any helper functions should go here or else delete this section
33+
34+
//----------------------------------------------------------------------
35+
// Public
36+
//----------------------------------------------------------------------
37+
38+
return {
39+
40+
// give me methods
41+
42+
};
43+
}
44+
};

‎tests/lib/rules/no-this-in-async-data.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @fileoverview Preventing using this in asyncData
2+
* @fileoverview Prevent using this in asyncData
33
* @author Clark Du
44
*/
55
"use strict";

‎tests/lib/rules/no-this-in-fetch.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* @fileoverview Prevent using this in fetch
3+
* @author Clark Du
4+
*/
5+
"use strict";
6+
7+
//------------------------------------------------------------------------------
8+
// Requirements
9+
//------------------------------------------------------------------------------
10+
11+
var rule = require("../../../lib/rules/no-this-in-fetch"),
12+
13+
RuleTester = require("eslint").RuleTester;
14+
15+
16+
//------------------------------------------------------------------------------
17+
// Tests
18+
//------------------------------------------------------------------------------
19+
20+
var ruleTester = new RuleTester();
21+
ruleTester.run("no-this-in-fetch", rule, {
22+
23+
valid: [
24+
25+
// give me some code that won't trigger a warning
26+
],
27+
28+
invalid: [
29+
{
30+
code: "console.log('route path:', this.$route.path)",
31+
errors: [{
32+
message: "Fill me in.",
33+
type: "Me too"
34+
}]
35+
}
36+
]
37+
});

0 commit comments

Comments
 (0)
This repository has been archived.