Skip to content
New issue

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

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

Already on GitHub? Sign in 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

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.

Coding Standards Triage 2020-05-19 automation moved this from To do to Done Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants