Giter VIP home page Giter VIP logo

eslint-plugin-import-order's Introduction

eslint-plugin-import-order

version

ESLint plugin to enforce the order of import/require statements.

Deprecation notice

This plugin is no longer maintained, as its sole feature has been integrated and improved upon in eslint-plugin-import, which does even more cool stuff. The corresponding rule is available under the name order.

Install

$ npm install --save-dev eslint eslint-plugin-import-order

Usage

Configure it in package.json.

{
	"name": "my-awesome-project",
	"eslintConfig": {
		"env": {
			"es6": true
		},
		"parserOptions": {
			"ecmaVersion": 6,
			"sourceType": "module"
		},
		"plugins": [
			"import-order"
		],
		"rules": {
			"import-order/import-order": 2
		}
	}
}

Rules

  • import-order - Enforce a convention in module import order.

Recommended configuration

This plugin exports a recommended configuration that enforces good practices.

To enable this configuration use the extends property in your package.json.

{
	"name": "my-awesome-project",
	"eslintConfig": {
		"extends": "plugin:import-order/recommended",
		"plugins": [
			"import-order"
		]
	}
}

See ESLint documentation for more information about extending configuration files.

Note: This configuration will also enable the correct parser options and environment.

eslint-plugin-import-order's People

Contributors

jfmengels avatar

Stargazers

 avatar Ken Huang avatar May avatar Steve Hook avatar Ben Mosher avatar Andrew Pinkham avatar Gil Barbara avatar Sigurd Fosseng avatar  avatar  avatar Michael Scott Hertzberg avatar Igor Davydenko avatar Jacky Alciné avatar  avatar Gustaf Dalemar avatar Philipp Andreychev avatar BJR Matos avatar Kir Belevich avatar Mehdy Dara avatar Jim Fitzpatrick avatar Jamlfy avatar Paolo Moretti avatar Andrea Parodi avatar Forbes Lindesay avatar Roland Warmerdam avatar Kumarajiva avatar sasha gudulin avatar tsuyoshi wada avatar Lawrence Peng avatar Pier Paolo Ramon avatar João Cunha avatar C. T. Lin avatar Dmytro Piddubnyi avatar Zach Orlovsky avatar Vladimir Starkov avatar Michael Mayer avatar Dustin Specker avatar EGOIST avatar Valentin Semirulnik avatar floydwch avatar Sindre Sorhus avatar Emily Marigold Klassen avatar

Watchers

Sindre Sorhus avatar Emily Marigold Klassen avatar James Cloos avatar (◕ᴥ◕) avatar  avatar James Talmage avatar  avatar

Forkers

duncanbeevers

eslint-plugin-import-order's Issues

Condense output

With the following:

var AvaError = require('./ava-error');
var debug = require('debug')('ava:watcher');
var diff = require('arr-diff');
var flatten = require('arr-flatten');
var union = require('array-union');
var uniq = require('array-uniq');
var defaultIgnore = require('ignore-by-default').directories();
var multimatch = require('multimatch');
var keypress = require('keypress');
var nodePath = require('path');
var slash = require('slash');

(source)

I currently get a lot of violations:

   4:13  error  `debug` import should occur before import of `./ava-error`              import-order/import-order
   5:12  error  `arr-diff` import should occur before import of `./ava-error`           import-order/import-order
   6:15  error  `arr-flatten` import should occur before import of `./ava-error`        import-order/import-order
   7:13  error  `array-union` import should occur before import of `./ava-error`        import-order/import-order
   8:12  error  `array-uniq` import should occur before import of `./ava-error`         import-order/import-order
   9:21  error  `ignore-by-default` import should occur before import of `./ava-error`  import-order/import-order
  10:18  error  `multimatch` import should occur before import of `./ava-error`         import-order/import-order
  11:16  error  `keypress` import should occur before import of `./ava-error`           import-order/import-order
  12:16  error  `path` import should occur before import of `./ava-error`               import-order/import-order
  13:13  error  `slash` import should occur before import of `./ava-error`              import-order/import-order

Here it should instead report that ./ava-error should be below slash.

Autofix

Would be so nice if this plugin supported autofixing.

Publish new patch to npm for the latest REAME.md

The README that currently is available at npm is out of date with the master on this repository.

Most notably the rule is incorrect leading to the user getting the following error:

  1:1  error  Definition for rule 'import-order' was not found  import-order

Publishing a new version will avoid this confusion.

Use options object for the config

Just in case you want to add more options in the future:

"import-order/import-order": [2, ["index", "sibling", "parent", "external", "builtin"]]

To:

"import-order/import-order": [2, {"order": ["index", "sibling", "parent", "external", "builtin"]}]

Enforce `import` at the top

According to the ES2015 spec the import keyword should always be at the top. Would be useful to have a rule to enforce this for early warning in the editor and for Babel, which doesn't seem to enforce it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.