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

Commit

Permalink
feat: init no-this-in-async-data
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkdo committed Dec 4, 2018
1 parent 10bf876 commit cb03b4d
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 0 deletions.
35 changes: 35 additions & 0 deletions docs/rules/no-this-in-async-data.md
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.
44 changes: 44 additions & 0 deletions lib/rules/no-this-in-async-data.js
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

};
}
};
37 changes: 37 additions & 0 deletions tests/lib/rules/no-this-in-async-data.js
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"
}]
}
]
});

0 comments on commit cb03b4d

Please sign in to comment.