This repository has been archived by the owner on Mar 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Preventing using this in asyncData (no-this-in-async-data) | ||
|
||
Please describe the origin of the rule here. | ||
|
||
## Rule Details | ||
|
||
This rule aims to... | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```js | ||
|
||
// fill me in | ||
|
||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```js | ||
|
||
// fill me in | ||
|
||
``` | ||
|
||
### Options | ||
|
||
If there are any options, describe them here. Otherwise, delete this section. | ||
|
||
## When Not To Use It | ||
|
||
Give a short description of when it would be appropriate to turn off this rule. | ||
|
||
## Further Reading | ||
|
||
If there are other links that describe the issue this rule addresses, please include them here in a bulleted list. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* @fileoverview Preventing using this in asyncData | ||
* @author Clark Du | ||
*/ | ||
"use strict"; | ||
|
||
//------------------------------------------------------------------------------ | ||
// Rule Definition | ||
//------------------------------------------------------------------------------ | ||
|
||
module.exports = { | ||
meta: { | ||
docs: { | ||
description: "Preventing using this in asyncData", | ||
category: "Fill me in", | ||
recommended: false | ||
}, | ||
fixable: null, // or "code" or "whitespace" | ||
schema: [ | ||
// fill in your schema | ||
] | ||
}, | ||
|
||
create: function(context) { | ||
|
||
// variables should be defined here | ||
|
||
//---------------------------------------------------------------------- | ||
// Helpers | ||
//---------------------------------------------------------------------- | ||
|
||
// any helper functions should go here or else delete this section | ||
|
||
//---------------------------------------------------------------------- | ||
// Public | ||
//---------------------------------------------------------------------- | ||
|
||
return { | ||
|
||
// give me methods | ||
|
||
}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* @fileoverview Preventing using this in asyncData | ||
* @author Clark Du | ||
*/ | ||
"use strict"; | ||
|
||
//------------------------------------------------------------------------------ | ||
// Requirements | ||
//------------------------------------------------------------------------------ | ||
|
||
var rule = require("../../../lib/rules/no-this-in-async-data"), | ||
|
||
RuleTester = require("eslint").RuleTester; | ||
|
||
|
||
//------------------------------------------------------------------------------ | ||
// Tests | ||
//------------------------------------------------------------------------------ | ||
|
||
var ruleTester = new RuleTester(); | ||
ruleTester.run("no-this-in-async-data", rule, { | ||
|
||
valid: [ | ||
|
||
// give me some code that won't trigger a warning | ||
], | ||
|
||
invalid: [ | ||
{ | ||
code: "this.await fetch(`/api${this.$route.path}`)", | ||
errors: [{ | ||
message: "Fill me in.", | ||
type: "Me too" | ||
}] | ||
} | ||
] | ||
}); |