Update dependency eslint-plugin-ghost to v0.3.0 (#1247)

no issue

- update dependency `eslint-plugin-ghost` to v0.3.0
  - includes new rules from `eslint-plugin-ember` 6.3.0-6.7.0
- fixed linting failures for new rules
This commit is contained in:
Kevin Ansfield 2019-06-24 16:33:21 +01:00 committed by GitHub
parent 209c37f6bb
commit a2bb7c95f2
19 changed files with 115 additions and 131 deletions

View File

@ -36,6 +36,8 @@ export default Component.extend({
if (errors && !isEmpty(errors.errorsFor(property))) {
return errors.errorsFor(property).get('firstObject').message;
}
return '';
}),
timeError: computed('errors.[]', 'timeErrorProperty', function () {
@ -45,6 +47,8 @@ export default Component.extend({
if (errors && !isEmpty(errors.errorsFor(property))) {
return errors.errorsFor(property).get('firstObject').message;
}
return '';
}),
didReceiveAttrs() {

View File

@ -33,5 +33,7 @@ export default Component.extend({
index = Math.floor(Math.random() * messages.length);
return messages[index].message;
}
return '';
})
});

View File

@ -20,10 +20,13 @@ export default Component.extend({
backgroundStyle: computed('member.name', function () {
let name = this.member.name;
if (name) {
let color = stringToHslColor(name, 55, 55);
return htmlSafe(`background-color: ${color}`);
}
return htmlSafe('');
}),
initials: computed('member.name', function () {

View File

@ -2,7 +2,7 @@ import Component from '@ember/component';
import ShortcutsMixin from 'ghost-admin/mixins/shortcuts';
import calculatePosition from 'ember-basic-dropdown/utils/calculate-position';
import ctrlOrCmd from 'ghost-admin/utils/ctrl-or-cmd';
import {computed} from '@ember/object';
import {and, equal, match} from '@ember/object/computed';
import {getOwner} from '@ember/application';
import {htmlSafe} from '@ember/string';
import {inject as service} from '@ember/service';
@ -24,37 +24,20 @@ export default Component.extend(ShortcutsMixin, {
shortcuts: null,
showMenuExtension: computed('config.clientExtensions.menu', 'session.user.isOwner', function () {
return this.get('config.clientExtensions.menu') && this.get('session.user.isOwner');
}),
showDropdownExtension: computed('config.clientExtensions.dropdown', 'session.user.isOwner', function () {
return this.get('config.clientExtensions.dropdown') && this.get('session.user.isOwner');
}),
showScriptExtension: computed('config.clientExtensions.script', 'session.user.isOwner', function () {
return this.get('config.clientExtensions.script') && this.get('session.user.isOwner');
}),
isIntegrationRoute: computed('router.currentRouteName', function () {
let re = /^settings\.integration/;
return re.test(this.router.currentRouteName);
}),
isSettingsRoute: computed('router.currentRouteName', function () {
let re = /^settings/;
return re.test(this.router.currentRouteName);
}),
isIntegrationRoute: match('router.currentRouteName', /^settings\.integration/),
isSettingsRoute: match('router.currentRouteName', /^settings/),
// HACK: {{link-to}} should be doing this automatically but there appears to
// be a bug in Ember that's preventing it from working immediately after login
isOnSite: computed('router.currentRouteName', function () {
return this.router.currentRouteName === 'site';
}),
isOnSite: equal('router.currentRouteName', 'site'),
showMenuExtension: and('config.clientExtensions.menu', 'session.user.isOwner'),
showDropdownExtension: and('config.clientExtensions.dropdown', 'session.user.isOwner'),
showScriptExtension: and('config.clientExtensions.script', 'session.user.isOwner'),
init() {
this._super(...arguments);
let shortcuts = {};
shortcuts[`${ctrlOrCmd}+k`] = {action: 'toggleSearchModal'};

View File

@ -19,9 +19,7 @@ export default Component.extend(ValidationState, {
errors: readOnly('navItem.errors'),
errorClass: computed('hasError', function () {
if (this.hasError) {
return 'gh-blognav-item--error';
}
return this.hasError ? 'gh-blognav-item--error' : '';
}),
actions: {

View File

@ -21,10 +21,10 @@ export function computedGroup(category) {
}
export default Component.extend({
store: service('store'),
router: service('router'),
ajax: service(),
notifications: service(),
router: service(),
store: service(),
content: null,
contentExpiresAt: false,

View File

@ -50,15 +50,11 @@ const GhTaskButton = Component.extend({
}),
isIdleClass: computed('isIdle', function () {
if (this.isIdle) {
return this.idleClass;
}
return this.isIdle ? this.idleClass : '';
}),
isRunningClass: computed('isRunning', function () {
if (this.isRunning) {
return this.runningClass || this.idleClass;
}
return this.isRunning ? (this.runningClass || this.idleClass) : '';
}),
isSuccess: computed('hasRun', 'isRunning', 'task.last.value', function () {
@ -71,9 +67,7 @@ const GhTaskButton = Component.extend({
}),
isSuccessClass: computed('isSuccess', function () {
if (this.isSuccess) {
return this.successClass;
}
return this.isSuccess ? this.successClass : '';
}),
isFailure: computed('hasRun', 'isRunning', 'isSuccess', 'task.last.error', function () {
@ -85,9 +79,7 @@ const GhTaskButton = Component.extend({
}),
isFailureClass: computed('isFailure', function () {
if (this.isFailure) {
return this.failureClass;
}
return this.isFailure ? this.failureClass : '';
}),
isIdle: computed('isRunning', 'isSuccess', 'isFailure', function () {

View File

@ -17,9 +17,7 @@ export default DraggableObject.extend({
}),
title: computed('internal', function () {
if (this.internal) {
return `Internal tag`;
}
return this.internal ? 'Internal tag' : '';
})
});

View File

@ -17,9 +17,7 @@ export default Component.extend({
zoom() {},
style: computed('zoomed', function () {
if (this.zoomed) {
return htmlSafe('width: auto; margin: 0;');
}
return htmlSafe(this.zoomed ? 'width: auto; margin: 0;' : '');
}),
// avoid "binding style attributes" warnings

View File

@ -52,6 +52,8 @@ export default Controller.extend({
];
return htmlSafe(styles.join('; '));
}
return htmlSafe('');
}),
actions: {

View File

@ -37,14 +37,13 @@ export default Controller.extend({
email: readOnly('user.email'),
slugValue: boundOneWay('user.slug'),
canAssignRoles: or('currentUser.isAdmin', 'currentUser.isOwner'),
canChangeEmail: not('isAdminUserOnOwnerProfile'),
canChangePassword: not('isAdminUserOnOwnerProfile'),
canMakeOwner: and('currentUser.isOwner', 'isNotOwnProfile', 'user.isAdmin', 'isNotSuspended'),
isAdminUserOnOwnerProfile: and('currentUser.isAdmin', 'user.isOwner'),
isNotOwnersProfile: not('user.isOwner'),
isNotSuspended: not('user.isSuspended'),
rolesDropdownIsVisible: and('isNotOwnProfile', 'canAssignRoles', 'isNotOwnersProfile'),
rolesDropdownIsVisible: and('currentUser.isOwnerOrAdmin', 'isNotOwnProfile', 'isNotOwnersProfile'),
userActionsAreVisible: or('deleteUserActionIsVisible', 'canMakeOwner'),
isNotOwnProfile: not('isOwnProfile'),
@ -52,12 +51,22 @@ export default Controller.extend({
return this.get('user.id') === this.get('currentUser.id');
}),
deleteUserActionIsVisible: computed('currentUser', 'canAssignRoles', 'user', function () {
if ((this.canAssignRoles && this.isNotOwnProfile && !this.get('user.isOwner'))
|| (this.get('currentUser.isEditor') && (this.isNotOwnProfile
|| this.get('user.isAuthorOrContributor')))) {
deleteUserActionIsVisible: computed('currentUser.{isOwnerOrAdmin,isEditor}', 'user.{isOwner,isAuthorOrContributor}', 'isOwnProfile', function () {
// users can't delete themselves
if (this.isOwnProfile) {
return false;
}
if (
// owners/admins can delete any non-owner user
(this.currentUser.get('isOwnerOrAdmin') && !this.user.isOwner) ||
// editors can delete any author or contributor
(this.currentUser.get('isEditor') && this.user.isAuthorOrContributor)
) {
return true;
}
return false;
}),
coverTitle: computed('user.name', function () {

View File

@ -44,18 +44,20 @@ export default Component.extend({
}),
toolbar: computed('isEditing', function () {
if (!this.isEditing) {
return {
items: [{
buttonClass: 'fw4 flex items-center white',
icon: 'koenig/kg-edit',
iconClass: 'fill-white',
title: 'Edit',
text: '',
action: run.bind(this, this.editCard)
}]
};
if (this.isEditing) {
return false;
}
return {
items: [{
buttonClass: 'fw4 flex items-center white',
icon: 'koenig/kg-edit',
iconClass: 'fill-white',
title: 'Edit',
text: '',
action: run.bind(this, this.editCard)
}]
};
}),
escapedCode: computed('payload.code', function () {

View File

@ -59,20 +59,18 @@ export default Component.extend({
}),
toolbar: computed('images.[]', function () {
let items = [];
if (isEmpty(this.images)) {
return false;
}
if (!isEmpty(this.images)) {
items.push({
return {
items: [{
title: 'Add images',
icon: 'koenig/kg-add',
iconClass: 'fill-white',
action: run.bind(this, this._triggerFileDialog)
});
}
if (items.length > 0) {
return {items};
}
}]
};
}),
imageRows: computed('images.@each.{src,previewSrc,width,height,row}', function () {

View File

@ -33,18 +33,20 @@ export default Component.extend({
}),
toolbar: computed('isEditing', function () {
if (!this.isEditing) {
return {
items: [{
buttonClass: 'fw4 flex items-center white',
icon: 'koenig/kg-edit',
iconClass: 'fill-white',
title: 'Edit',
text: '',
action: run.bind(this, this.editCard)
}]
};
if (this.isEditing) {
return false;
}
return {
items: [{
buttonClass: 'fw4 flex items-center white',
icon: 'koenig/kg-edit',
iconClass: 'fill-white',
title: 'Edit',
text: '',
action: run.bind(this, this.editCard)
}]
};
}),
init() {

View File

@ -80,44 +80,37 @@ export default Component.extend({
}),
toolbar: computed('payload.{cardWidth,src}', function () {
let cardWidth = this.payload.cardWidth;
let items = [];
if (!this.payload.src) {
return false;
}
if (this.payload.src) {
items.push({
let cardWidth = this.payload.cardWidth;
return {
items: [{
title: 'Regular',
icon: 'koenig/kg-img-regular',
iconClass: `${!cardWidth ? 'fill-blue-l2' : 'fill-white'}`,
action: run.bind(this, this._changeCardWidth, '')
});
items.push({
}, {
title: 'Wide',
icon: 'koenig/kg-img-wide',
iconClass: `${cardWidth === 'wide' ? 'fill-blue-l2' : 'fill-white'}`,
action: run.bind(this, this._changeCardWidth, 'wide')
});
items.push({
}, {
title: 'Full',
icon: 'koenig/kg-img-full',
iconClass: `${cardWidth === 'full' ? 'fill-blue-l2' : 'fill-white'}`,
action: run.bind(this, this._changeCardWidth, 'full')
});
items.push({divider: true});
items.push({
}, {
divider: true
}, {
title: 'Replace image',
icon: 'koenig/kg-replace',
iconClass: 'fill-white',
action: run.bind(this, this._triggerFileDialog)
});
}
if (items.length > 0) {
return {items};
}
}]
};
}),
init() {

View File

@ -45,18 +45,20 @@ export default Component.extend({
}),
toolbar: computed('isEditing', function () {
if (!this.isEditing) {
return {
items: [{
buttonClass: 'fw4 flex items-center white',
icon: 'koenig/kg-edit',
iconClass: 'fill-white',
title: 'Edit',
text: '',
action: run.bind(this, this.editCard)
}]
};
if (this.isEditing) {
return false;
}
return {
items: [{
buttonClass: 'fw4 flex items-center white',
icon: 'koenig/kg-edit',
iconClass: 'fill-white',
title: 'Edit',
text: '',
action: run.bind(this, this.editCard)
}]
};
}),
init() {

View File

@ -69,9 +69,7 @@ export default Component.extend({
}),
selectedClass: computed('isSelected', 'showSelectedOutline', function () {
if (this.isSelected && this.showSelectedOutline) {
return 'kg-card-selected';
}
return this.isSelected && this.showSelectedOutline ? 'kg-card-selected' : '';
}),
didReceiveAttrs() {

View File

@ -97,7 +97,7 @@
"ember-useragent": "0.9.1",
"emberx-file-input": "1.2.1",
"eslint": "5.16.0",
"eslint-plugin-ghost": "0.2.0",
"eslint-plugin-ghost": "0.3.0",
"faker": "4.1.0",
"fs-extra": "8.0.1",
"glob": "7.1.4",

View File

@ -5460,20 +5460,20 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
eslint-plugin-ember@^6.2.0:
version "6.6.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-ember/-/eslint-plugin-ember-6.6.0.tgz#fa64f0e9fbbe14ae44478b5fa3890fb74d720e5e"
integrity sha512-vqRAyGMtuohMe+cnxiPYIF73gC2Rlei0GX/TAAAIXIJH8E98TFQkOHAhzF6u/6l6W5XRVuTKOlXyPJzRY+kJwQ==
eslint-plugin-ember@^6.7.0:
version "6.7.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-ember/-/eslint-plugin-ember-6.7.0.tgz#1c2eb60a3b5ef7d483bd6f3ecbeaff42667c98ba"
integrity sha512-NLrO9XY0cR0+oeMc6850A86nJJe5LkN9fs5obNfy4BE0CmDXa3PX9GQlAR/O0sXPsj9HIOnGBTp2qO5dKfgZmA==
dependencies:
ember-rfc176-data "^0.3.9"
snake-case "^2.1.0"
eslint-plugin-ghost@0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-ghost/-/eslint-plugin-ghost-0.2.0.tgz#3f7a8bf28ca239b7f869633c925dbd3d5811bc43"
integrity sha512-yHZlNYClLqYx6vF3gg4O7/18MmKyPND58WGaLduMmGDtS5iifHK9jnVukQprOHyJdxrSSOZWll/6duasctxU2A==
eslint-plugin-ghost@0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-ghost/-/eslint-plugin-ghost-0.3.0.tgz#94f4be899bcfd6dfaf581f64386a6c317c5be7de"
integrity sha512-VWewfQQE8kVu9QAWaBIRwx6P0zAuUR0KL6pXWVVUXWIVReIUZk77an5VCbVRtELC7Ea3jPFCEfnr5Olbs0ZAAw==
dependencies:
eslint-plugin-ember "^6.2.0"
eslint-plugin-ember "^6.7.0"
eslint-plugin-sort-imports-es6-autofix "0.4.0"
eslint-plugin-sort-imports-es6-autofix@0.4.0: