Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

enforce JS import ordering #84

Closed
kadamwhite opened this issue Aug 20, 2018 · 2 comments
Closed

enforce JS import ordering #84

kadamwhite opened this issue Aug 20, 2018 · 2 comments
Assignees

Comments

@kadamwhite
Copy link
Contributor

In #75 @igmoweb proposed the addition of the sort-imports ESLint rule, to control the ordering of modules we import into our code.

In a Slack thread @rmccue further proposed that we conform to a general ordering of absolute, then relative, then side effects (e.g. importing a CSS file to ensure it gets included in the build, but not using the return of that import), with a blank line between each, and each section alphabetized.

As an example:

import React from 'react';
import { connect } from 'react-redux';

import Foo from './Foo';

import './Bar.css';

This made sense to me, and would help a lot on several projects we've had lately.

The sort-imports rule looks like it can handle putting the import-for-side-effects after other imports, but doesn't at first glance support including the relative imports after absolute. We should investigate further.

@mikeselander
Copy link
Contributor

Huge 👍 on this - I frequently get these slightly wrong manually and having a rule for this would prevent a lot of silly code churn.

@tfrommen
Copy link
Contributor

Closing as done in #219.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants