New Rule suggestion: sort-dependencies
See original GitHub issueAcronyms
TBD - to be discussed
The use case for the rule - what is it trying to prevent or flag? Include code examples.
This rule would flag unordered dependencies preferably configurable.
Env: Node
Default flagging: Symbols -> Upper case letters -> Lower case letters
Examples flagged
es6
import * as lib from './foo';
import { x, z , F } from './bar';
import _ from 'underscore';
import y from './baz';
import A from './byz';
es5
const lib = require('./foo');
const x = require('./bar');
const z = require('./bar');
const F = require('./bar');
const _ = require('underscore');
const y = require('./baz');
const A = require('./byz');
Examples fixed
es6
import _ from 'underscore'; //TBD if * over _ or configurable
import * as lib from './foo';
import A from './byz';
import { x, z , F } from './bar'; //inline dependencies possible caveat TBD
import y from './baz';
es5
const _ = require('underscore');
const A = require('./byz');
const F = require('./bar');
const lib = require('./foo');
const x = require('./bar');
const y = require('./baz');
const z = require('./bar');
Whether the rule is trying to prevent an error or is purely stylistic.
Purely stylistic
Why you believe this rule is generic enough to be included.
The rule would basically collect all dependencies and sort them. This is possible for both es5 and es6 using the same rule.
Whether the rule should be on or off by default.
Off by default
Issue Analytics
- State:
- Created 8 years ago
- Reactions:2
- Comments:22 (10 by maintainers)
Top Results From Across the Web
Why order of Maven dependencies matter? - Stack Overflow
The order of dependencies does matter because of how Maven resolves transitive dependencies, starting with version 2.0.9. Excerpt from the documentation:.
Read more >7. Declaring relationships between packages - Debian
This relaxed restriction means that both new packages can be unpacked together and then configured in their dependency order. 4. To see why...
Read more >Violating the Dependency rule — Matthias Noback - Blog
Dependencies between classes within the same layer are allowed too. Following this rule, a domain object should never use an infrastructure ...
Read more >Discovering Domain Orders through Order Dependencies
Intuitively, an order dependency asserts that sorting a table according to some attribute(s) implies that the table is also sorted according to ...
Read more >Authoring Tasks - Gradle User Manual
In order to pass values to the Task constructor, you must annotate the ... and a task dependency is that an ordering rule...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@cschuller any chance of an auto-fix? Don’t feel up to implementing that myself, so just requesting in the hope you do 😉
@wmertens Sorry, the chance is very low, but not zero 😉 Speaking personally, I love ESLint, but I do not like the auto-fix feature. The primary focus of ESLint shall be linting not fixing. Besides my personal point of view, if more people are interested in adding auto-fix to sort-import, I can do it. 😃