Guys, as I was working on my current job, I faced so many times about "ordering imported modules" issue in "routes", "controllers" and "components" files. In scenario like this route:
import Route from '@ember/routing/route';
import { get, getProperties, getWithDefault, set, setProperties } from '@ember/object';
import { hash, allSettled, Promise } from 'rsvp';
import { inject as service } from '@ember/service';
import { isBlank } from '@ember/utils';
import { assign } from '@ember/polyfills';
import { task, timeout } from 'ember-concurrency';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
import LastLocationRestorableMixin from '../mixins/components/last-location-restorable';
import OPTIONS from '../pods/map/configurations/options';
import MapUtils from '../utils/map';
import ENV from '../config/environment';
import $ from 'jquery';
import _ from 'lodash';
In some files I ordered in some ways and in other files I ordered in another ways, I have switched many times in same files too, I felt a lack of ordering pattern like "eslint rules" have for "models", "routes", "controllers" and "components". I searched about this topic from the rules (https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules) but I didn't found a kind of rule like this, only have ordering for "models", "routes", "controllers" and "components", but nothing about "modules imports" ordering.
I would like to propose the following ordering, for example, in "Route":
All ember core packages.
All ember packages extended/created/customized (by the organization).
All third party ember addons.
All third party libs non ember addons.
Example:
Domain object (If the file is a "route", import Route from '@ember/routing/route';).
rsvp
others...
-----------> At this stage is about "all ember core packages".
models (from "models" folder like import Question from '../models/question';)
mixins (from "mixins" folder like import LastLocationRestorableMixin from '../mixins/components/last-location-restorable';)
utils (from "utils" folder like import MapUtils from '../utils/map';)
ENV (import ENV from '../config/environment';)
Domain object options/configurations (like
import OPTIONS from '../pods/map/configurations/options';import demographicQuestions from './demographic-questions';
)
others...
-----------> At this stage is "all ember packages extended/created/customized by us".
third party ember addons like:
import { task, timeout } from 'ember-concurrency';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
others...
-----------> At this stage is "all third party ember addons".
third party non ember addons like:
import $ from 'jquery';
import _ from 'lodash';
others...
-----------> At this stage is "all third party libs non ember addons".
There is some ordering proposition already? Or there is some suggestion? What do you think guys?
Guys, as I was working on my current job, I faced so many times about "ordering imported modules" issue in "routes", "controllers" and "components" files. In scenario like this route:
In some files I ordered in some ways and in other files I ordered in another ways, I have switched many times in same files too, I felt a lack of ordering pattern like "eslint rules" have for "models", "routes", "controllers" and "components". I searched about this topic from the rules (https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules) but I didn't found a kind of rule like this, only have ordering for "models", "routes", "controllers" and "components", but nothing about "modules imports" ordering.
I would like to propose the following ordering, for example, in "Route":
Example:
Domain object
(If the file is a "route",import Route from '@ember/routing/route';
).@ember/object
(and object modules in the order they are presented, https://www.emberjs.com/api/ember/release/modules/@ember%2Fobject).@ember/utils
@ember/polyfills
@ember/service
rsvp
others... -----------> At this stage is about "all ember core packages".models
(from "models" folder likeimport Question from '../models/question';
)mixins
(from "mixins" folder likeimport LastLocationRestorableMixin from '../mixins/components/last-location-restorable';
)utils
(from "utils" folder likeimport MapUtils from '../utils/map';
)ENV
(import ENV from '../config/environment';)Domain object options/configurations
(likeimport OPTIONS from '../pods/map/configurations/options';
import demographicQuestions from './demographic-questions';
) others... -----------> At this stage is "all ember packages extended/created/customized by us".third party ember addons
like: import { task, timeout } from 'ember-concurrency'; import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; others... -----------> At this stage is "all third party ember addons".third party non ember addons
like: import $ from 'jquery'; import _ from 'lodash'; others... -----------> At this stage is "all third party libs non ember addons".There is some ordering proposition already? Or there is some suggestion? What do you think guys?