mirror of
https://github.com/bendtherules/eslint-plugin-import-grouped.git
synced 2026-08-18 13:43:19 +00:00
Add basic plugin and rule scaffolding using yo eslint
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
# eslint-plugin-import-grouped
|
||||
|
||||
Import statements should be grouped by extensions and groups can have custom order between them
|
||||
|
||||
## Installation
|
||||
|
||||
You'll first need to install [ESLint](http://eslint.org):
|
||||
|
||||
```
|
||||
$ npm i eslint --save-dev
|
||||
```
|
||||
|
||||
Next, install `eslint-plugin-import-grouped`:
|
||||
|
||||
```
|
||||
$ npm install eslint-plugin-import-grouped --save-dev
|
||||
```
|
||||
|
||||
**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-import-grouped` globally.
|
||||
|
||||
## Usage
|
||||
|
||||
Add `import-grouped` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
|
||||
|
||||
```json
|
||||
{
|
||||
"plugins": [
|
||||
"import-grouped"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Then configure the rules you want to use under the rules section.
|
||||
|
||||
```json
|
||||
{
|
||||
"rules": {
|
||||
"import-grouped/rule-name": 2
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Supported Rules
|
||||
|
||||
* Fill in provided rules here
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# Import statements should be grouped by extensions and groups can have custom order between them (import-grouped)
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @fileoverview Import statements should be grouped by extensions and groups can have custom order between them
|
||||
* @author Abhas Bhattacharya
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
var requireIndex = require("requireindex");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Plugin Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// import all rules in lib/rules
|
||||
module.exports.rules = requireIndex(__dirname + "/rules");
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @fileoverview Import statements should be grouped by extensions and groups can have custom order between them
|
||||
* @author Abhas Bhattacharya
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
module.exports = {
|
||||
meta: {
|
||||
docs: {
|
||||
description: "Import statements should be grouped by extensions and groups can have custom order between them",
|
||||
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
|
||||
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "eslint-plugin-import-grouped",
|
||||
"version": "0.0.0",
|
||||
"description": "Import statements should be grouped by extensions and groups can have custom order between them",
|
||||
"keywords": [
|
||||
"eslint",
|
||||
"eslintplugin",
|
||||
"eslint-plugin"
|
||||
],
|
||||
"author": "Abhas Bhattacharya",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"test": "mocha tests --recursive"
|
||||
},
|
||||
"dependencies": {
|
||||
"requireindex": "~1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "~3.9.1",
|
||||
"mocha": "^3.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"license": "ISC"
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @fileoverview Import statements should be grouped by extensions and groups can have custom order between them
|
||||
* @author Abhas Bhattacharya
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
var rule = require("../../../lib/rules/import-grouped"),
|
||||
|
||||
RuleTester = require("eslint").RuleTester;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Tests
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
var ruleTester = new RuleTester();
|
||||
ruleTester.run("import-grouped", rule, {
|
||||
|
||||
valid: [
|
||||
|
||||
// give me some code that won't trigger a warning
|
||||
],
|
||||
|
||||
invalid: [
|
||||
{
|
||||
code: "`import 'a'; import 'style.css';import 'b';`",
|
||||
errors: [{
|
||||
message: "Fill me in.",
|
||||
type: "Me too"
|
||||
}]
|
||||
}
|
||||
]
|
||||
});
|
||||
Reference in New Issue
Block a user