question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New Rule suggestion: sort-dependencies

See original GitHub issue

Acronyms

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:closed
  • Created 8 years ago
  • Reactions:2
  • Comments:22 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
wmertenscommented, Apr 18, 2016

@cschuller any chance of an auto-fix? Don’t feel up to implementing that myself, so just requesting in the hope you do 😉

0reactions
cschullercommented, Apr 20, 2016

@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. 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found