Skip to content

Commit

Permalink
chore: yarn lint:fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Pixelik committed Jan 10, 2024
1 parent a2231c1 commit 1157d6a
Show file tree
Hide file tree
Showing 24 changed files with 178 additions and 164 deletions.
16 changes: 15 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ module.exports = {
env: {
browser: true,
},
rules: {},
rules: {
'ember/no-controller-access-in-routes': 1,
'ember/no-computed-properties-in-native-classes': 1,
'ember/no-classic-classes': 1,
'ember/avoid-leaking-state-in-ember-objects': 1,
'n/no-missing-require': 1,
'ember/no-new-mixins': 1,
'ember/no-arrow-function-computed-properties': 1,
'ember/no-actions-hash': 1,
},
overrides: [
// node files
{
Expand All @@ -46,11 +55,16 @@ module.exports = {
node: true,
},
extends: ['plugin:n/recommended'],
rules: {},
},
{
// test files
files: ['tests/**/*-test.{js,ts}'],
extends: ['plugin:qunit/recommended'],
rules: {
'qunit/no-assert-equal': 1,
'qunit/require-expect': 1,
},
},
],
};
4 changes: 2 additions & 2 deletions addon/-private/parachute-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class ParachuteEvent {
return changedParams;
},
{},
undefined
undefined,
);

/**
Expand All @@ -57,7 +57,7 @@ export default class ParachuteEvent {
* Whether or not a model refresh should occur
*/
this.shouldRefresh = emberArray(keys(this.changed)).any(
key => queryParams[key].refresh
(key) => queryParams[key].refresh,
);

/**
Expand Down
12 changes: 6 additions & 6 deletions addon/-private/parachute-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,38 @@ export default class ParachuteMeta {
}, {});

this.queryParamsArray = emberArray(
keys(this.queryParams).map(key => {
keys(this.queryParams).map((key) => {
return this.queryParams[key];
})
}),
);

this.qpMapForController = this.queryParamsArray.reduce(
(qps, { key, as, scope }) => {
qps[key] = { as, scope };
return qps;
},
{}
{},
);

// Meta info used by the decorators
Object.defineProperty(this.qpMapForController, PARACHUTE_QPS, {
value: true
value: true,
});

this.qpMapForRoute = this.queryParamsArray.reduce(
(qps, { key, replace }) => {
qps[key] = { replace };
return qps;
},
{}
{},
);

this.defaultValues = this.queryParamsArray.reduce(
(defaults, { key, defaultValue }) => {
defaults[key] = defaultValue;
return defaults;
},
{}
{},
);
}
}
2 changes: 1 addition & 1 deletion addon/-private/query-param.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class QueryParam {
constructor(key, options = {}) {
assert(
`[ember-parachute] You must specify a key to the QueryParam Class`,
isPresent(key)
isPresent(key),
);

this.key = key;
Expand Down
6 changes: 3 additions & 3 deletions addon/-private/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ function queryParamsState(queryParamsArray, controller) {
serializedValue: qp.serializedValue(controller),
as: qp.as,
defaultValue: qp.defaultValue,
changed: JSON.stringify(value) !== JSON.stringify(qp.defaultValue)
changed: JSON.stringify(value) !== JSON.stringify(qp.defaultValue),
};
return state;
},
{},
undefined
undefined,
);
}

Expand All @@ -39,7 +39,7 @@ function queryParamsState(queryParamsArray, controller) {
export default function queryParamsStateFor(controller) {
assert(
'[ember-parachute] Cannot construct query params state object without a controller',
isPresent(controller)
isPresent(controller),
);
let { queryParamsArray } = QueryParams.metaFor(controller);
return queryParamsState(queryParamsArray, controller);
Expand Down
2 changes: 1 addition & 1 deletion addon/decorators/-private/query-params-for.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export function getQueryParamsFor(klass) {
export function addQueryParamFor(klass, key, definition) {
QP_MAP.set(
klass,
getQueryParamsFor(klass).extend({ [key]: definition || {} })
getQueryParamsFor(klass).extend({ [key]: definition || {} }),
);
}
6 changes: 3 additions & 3 deletions addon/decorators/query-param.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { A } from '@ember/array';
import { PARACHUTE_QPS } from 'ember-parachute/-private/symbols';
import {
addQueryParamFor,
getQueryParamsFor
getQueryParamsFor,
} from './-private/query-params-for';

function createDescriptor(desc, qpDefinition) {
Expand Down Expand Up @@ -30,7 +30,7 @@ function createDescriptor(desc, qpDefinition) {
}

return klass;
}
},
};

if (desc.kind === 'field') {
Expand All @@ -53,5 +53,5 @@ export default function queryParam(qpDefinition) {
}

// Handle `@queryParam()` usage
return desc => createDescriptor(desc, qpDefinition);
return (desc) => createDescriptor(desc, qpDefinition);
}
2 changes: 1 addition & 1 deletion addon/decorators/with-parachute.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export default function withParachute(desc) {
klass.reopen(new QueryParams().Mixin);

return klass;
}
},
};
}
30 changes: 17 additions & 13 deletions addon/initializers/ember-parachute.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function initialize(/* application */) {
// Check if routeInfos have already been loaded.
// If so, don't return a promise as it will result in
// the loading screen/state flashing.
if (routeInfos.every(x => x.isResolved)) {
if (routeInfos.every((x) => x.isResolved)) {
return this._super(params, transition);
}

Expand All @@ -97,20 +97,20 @@ export function initialize(/* application */) {
// https://github.com/emberjs/ember.js/issues/15291
const _super = this._super.bind(this);

return RSVP.all(routeInfos.map(x => x.routePromise)).then(() =>
_super(params, transition)
return RSVP.all(routeInfos.map((x) => x.routePromise)).then(() =>
_super(params, transition),
);
} else {
const { handlerInfos } = transition;

if (!handlerInfos.find(x => !x.handler)) {
if (!handlerInfos.find((x) => !x.handler)) {
return this._super(params, transition);
}

const _super = this._super.bind(this);

return RSVP.all(handlerInfos.map(x => x.handlerPromise)).then(() =>
_super(params, transition)
return RSVP.all(handlerInfos.map((x) => x.handlerPromise)).then(() =>
_super(params, transition),
);
}
},
Expand Down Expand Up @@ -190,11 +190,15 @@ export function initialize(/* application */) {
*/
_setupParachuteQueryParamsMap(controller) {
if (!this.__hasSetupParachuteQPs) {
let qpMap = this.get('queryParams');
let qpMap = this.queryParams;
let { qpMapForRoute } = QueryParams.metaFor(controller);

keys(qpMapForRoute).forEach(key => {
qpMapForRoute[key] = Object.assign({}, qpMapForRoute[key], qpMap[key]);
keys(qpMapForRoute).forEach((key) => {
qpMapForRoute[key] = Object.assign(
{},
qpMapForRoute[key],
qpMap[key],
);
});

this.set('queryParams', qpMapForRoute);
Expand All @@ -219,19 +223,19 @@ export function initialize(/* application */) {
this._scheduleParachuteChangeEvent(
routeName,
controller,
Object.assign({}, changed, removed)
Object.assign({}, changed, removed),
);
}

return this._super(...arguments);
}
}
},
},
});

Route.reopenClass({ _didInitializeParachute: true });
}

export default {
name: 'ember-parachute',
initialize
initialize,
};
23 changes: 10 additions & 13 deletions addon/query-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class QueryParams {
static metaFor(controller) {
assert(
`[ember-parachute] The controller '${controller}' is not set up with ember-parachute.`,
this.hasParachute(controller)
this.hasParachute(controller),
);
return get(controller, PARACHUTE_META);
}
Expand Down Expand Up @@ -114,7 +114,7 @@ export default class QueryParams {
return qps;
},
{},
undefined
undefined,
);
}

Expand Down Expand Up @@ -150,7 +150,7 @@ export default class QueryParams {
return defaults;
},
{},
undefined
undefined,
);

setProperties(controller, defaults);
Expand All @@ -171,7 +171,7 @@ export default class QueryParams {
let { queryParams } = this.metaFor(controller);
assert(
`[ember-parachute] The query parameter '${param}' does not exist.`,
queryParams[param]
queryParams[param],
);
set(queryParams[param], 'defaultValue', defaultValue);
}
Expand All @@ -195,11 +195,8 @@ export default class QueryParams {
* @returns {Ember.Mixin}
*/
_generateMixin() {
let {
queryParams,
defaultValues,
qpMapForController
} = this._generateMeta();
let { queryParams, defaultValues, qpMapForController } =
this._generateMeta();

let ControllerMixin = Mixin.create(defaultValues, {
/**
Expand Down Expand Up @@ -230,7 +227,7 @@ export default class QueryParams {
* @public
* @property {Ember.ComputedProperty}
*/
allQueryParams: computed(...keys(queryParams), function() {
allQueryParams: computed(...keys(queryParams), function () {
return QueryParams.queryParamsFor(this);
}).readOnly(),

Expand All @@ -243,9 +240,9 @@ export default class QueryParams {
queryParamsState: computed(
...keys(queryParams),
`${PARACHUTE_META}[email protected]`,
function() {
function () {
return QueryParams.stateFor(this);
}
},
).readOnly(),

/**
Expand All @@ -269,7 +266,7 @@ export default class QueryParams {
*/
setDefaultQueryParamValue(key, defaultValue) {
QueryParams.setDefaultValue(this, key, defaultValue);
}
},
});

return ControllerMixin;
Expand Down
8 changes: 3 additions & 5 deletions addon/utils/lookup-controller.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { get } from '@ember/object';
import { getOwner } from '@ember/application';

/**
Expand All @@ -10,7 +9,7 @@ import { getOwner } from '@ember/application';
* @returns {Ember.Controller}
*/
export default function lookupController(route, ownerLookupFn = getOwner) {
let controller = get(route, 'controller');
let controller = route.controller;

if (!controller) {
/**
Expand All @@ -19,10 +18,9 @@ export default function lookupController(route, ownerLookupFn = getOwner) {
* (especially with authentication) due to the controller being created
* prematurely.
*/
let controllerName =
get(route, 'controllerName') || get(route, 'routeName');
let controllerName = route.controllerName || route.routeName;
let factory = ownerLookupFn(route).factoryFor(
`controller:${controllerName}`
`controller:${controllerName}`,
);
return factory.class.proto();
}
Expand Down
5 changes: 4 additions & 1 deletion app/initializers/ember-parachute.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export { default, initialize } from 'ember-parachute/initializers/ember-parachute';
export {
default,
initialize,
} from 'ember-parachute/initializers/ember-parachute';
4 changes: 1 addition & 3 deletions config/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

// For details on each option run `ember help release`
module.exports = {

// angular style guide: https://github.com/angular/angular.js/blob/v1.4.8/CONTRIBUTING.md#commit
// jquery style guide: https://contribute.jquery.org/commits-and-pull-requests/#commit-guidelines
// ember style guide: https://github.com/emberjs/ember.js/blob/master/CONTRIBUTING.md#commit-tagging
Expand All @@ -18,6 +17,5 @@ module.exports = {
groupSort: function(commits) { return { commits: commits }; },
format: function(commit) { return commit.title; },
*/
}

},
};
Loading

0 comments on commit 1157d6a

Please sign in to comment.