diff --git a/.eslintrc.json b/.eslintrc.json index 8c9ed96d00..a838276139 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,301 +3,10 @@ "es6": true, "node": true }, - "extends": "eslint:recommended", - "rules": { - "accessor-pairs": "error", - "array-bracket-newline": "off", - "array-bracket-spacing": [ - "error", - "never" - ], - "array-callback-return": "off", - "array-element-newline": "off", - "arrow-body-style": [ - "error", - "always" - ], - "arrow-parens": [ - "error", - "always" - ], - "arrow-spacing": [ - "error", - { - "after": true, - "before": true - } - ], - "block-scoped-var": "error", - "brace-style": [ - "error", - "1tbs", - { - "allowSingleLine": true - } - ], - "callback-return": "error", - "camelcase": [ - "error", - { - "properties": "never" - } - ], - "capitalized-comments": "off", - "class-methods-use-this": "off", - "comma-dangle": "error", - "comma-spacing": "error", - "comma-style": [ - "error", - "last" - ], - "complexity": "off", - "computed-property-spacing": [ - "error", - "never" - ], - "consistent-return": "off", - "consistent-this": "off", - "curly": "error", - "default-case": "error", - "dot-location": [ - "error", - "property" - ], - "dot-notation": "error", - "eol-last": "error", - "eqeqeq": "error", - "for-direction": "error", - "func-call-spacing": "error", - "func-name-matching": "off", - "func-names": "off", - "func-style": "off", - "function-paren-newline": "off", - "generator-star-spacing": "error", - "getter-return": "error", - "global-require": "off", - "guard-for-in": "error", - "handle-callback-err": "error", - "id-blacklist": "error", - "id-length": "off", - "id-match": "error", - "indent": [ - "error", - 4, - { - "SwitchCase": 1 - } - ], - "indent-legacy": "off", - "init-declarations": "off", - "jsx-quotes": "error", - "key-spacing": "error", - "keyword-spacing": "error", - "line-comment-position": "off", - "linebreak-style": [ - "error", - "unix" - ], - "lines-around-comment": "off", - "lines-around-directive": "off", - "lines-between-class-members": [ - "error", - "always" - ], - "max-depth": "error", - "max-len": "off", - "max-lines": "off", - "max-nested-callbacks": "error", - "max-params": "off", - "max-statements": "off", - "max-statements-per-line": "off", - "multiline-comment-style": "off", - "multiline-ternary": "off", - "new-parens": "error", - "newline-after-var": "off", - "newline-before-return": "off", - "newline-per-chained-call": "off", - "no-alert": "error", - "no-array-constructor": "error", - "no-await-in-loop": "error", - "no-bitwise": "off", - "no-buffer-constructor": "off", - "no-caller": "error", - "no-catch-shadow": "error", - "no-confusing-arrow": "error", - "no-continue": "error", - "no-div-regex": "off", - "no-duplicate-imports": "error", - "no-else-return": "off", - "no-empty-function": "off", - "no-eq-null": "error", - "no-eval": "error", - "no-extend-native": "error", - "no-extra-bind": "error", - "no-extra-label": "error", - "no-extra-parens": "off", - "no-floating-decimal": "error", - "no-implicit-globals": "error", - "no-implied-eval": "error", - "no-inline-comments": "off", - "no-inner-declarations": [ - "error", - "functions" - ], - "no-invalid-this": "error", - "no-iterator": "error", - "no-label-var": "error", - "no-labels": "error", - "no-lone-blocks": "error", - "no-lonely-if": "off", - "no-loop-func": "error", - "no-magic-numbers": "off", - "no-mixed-operators": "off", - "no-mixed-requires": "off", - "no-multi-assign": "off", - "no-multi-spaces": "off", - "no-multi-str": "error", - "no-multiple-empty-lines": ["error", {"max": 1}], - "no-native-reassign": "error", - "no-negated-condition": "off", - "no-negated-in-lhs": "error", - "no-nested-ternary": "off", - "no-new": "error", - "no-new-func": "error", - "no-new-object": "error", - "no-new-require": "error", - "no-new-wrappers": "error", - "no-octal-escape": "error", - "no-param-reassign": "off", - "no-path-concat": "off", - "no-plusplus": "error", - "no-process-env": "off", - "no-process-exit": "off", - "no-proto": "error", - "no-prototype-builtins": "off", - "no-restricted-globals": "error", - "no-restricted-imports": "error", - "no-restricted-modules": "error", - "no-restricted-properties": "error", - "no-restricted-syntax": "error", - "no-return-assign": "error", - "no-return-await": "error", - "no-script-url": "error", - "no-self-compare": "error", - "no-sequences": "error", - "no-shadow": "off", - "no-shadow-restricted-names": "error", - "no-spaced-func": "error", - "no-sync": "off", - "no-tabs": "error", - "no-template-curly-in-string": "error", - "no-ternary": "off", - "no-throw-literal": "error", - "no-trailing-spaces": "error", - "no-undef-init": "error", - "no-undefined": "off", - "no-underscore-dangle": "off", - "no-unmodified-loop-condition": "error", - "no-unneeded-ternary": "off", - "no-use-before-define": "off", - "no-useless-call": "error", - "no-useless-computed-key": "error", - "no-useless-concat": "off", - "no-useless-constructor": "error", - "no-useless-escape": "off", - "no-useless-rename": "error", - "no-useless-return": "error", - "no-var": "off", - "no-void": "error", - "no-warning-comments": "off", - "no-whitespace-before-property": "error", - "no-with": "error", - "nonblock-statement-body-position": "error", - "object-curly-newline": [ - "error", - { - "consistent": true - } - ], - "object-curly-spacing": [ - "error", - "never" - ], - "object-property-newline": [ - "error", - { - "allowMultiplePropertiesPerLine": true - } - ], - "object-shorthand": "off", - "one-var": "off", - "one-var-declaration-per-line": "off", - "operator-assignment": "off", - "operator-linebreak": "off", - "padded-blocks": [ - "error", - "never" - ], - "padding-line-between-statements": "error", - "prefer-arrow-callback": "off", - "prefer-const": "off", - "prefer-destructuring": "off", - "prefer-numeric-literals": "error", - "prefer-promise-reject-errors": "off", - "prefer-reflect": "off", - "prefer-rest-params": "off", - "prefer-spread": "off", - "prefer-template": "off", - "quote-props": [ - "error", - "as-needed" - ], - "quotes": ["error", "single"], - "radix": "off", - "require-await": "error", - "require-jsdoc": "off", - "rest-spread-spacing": "error", - "semi": ["error", "always"], - "semi-spacing": "error", - "semi-style": [ - "error", - "last" - ], - "sort-imports": "error", - "sort-keys": "off", - "sort-vars": "off", - "space-before-blocks": "error", - "space-before-function-paren": [ - "error", - { - "anonymous": "always", - "named": "never" - } - ], - "space-in-parens": [ - "error", - "never" - ], - "space-infix-ops": "error", - "space-unary-ops": "error", - "spaced-comment": "error", - "strict": "off", - "switch-colon-spacing": "error", - "symbol-description": "error", - "template-curly-spacing": [ - "error", - "never" - ], - "template-tag-spacing": "error", - "unicode-bom": [ - "error", - "never" - ], - "valid-jsdoc": "off", - "vars-on-top": "off", - "wrap-iife": "off", - "wrap-regex": "off", - "yield-star-spacing": "error", - "yoda": "error" - } + "plugins": [ + "ghost" + ], + "extends": [ + "plugin:ghost/node" + ] } diff --git a/core/server/api/authentication.js b/core/server/api/authentication.js index ad4c79f6dc..c3386dd155 100644 --- a/core/server/api/authentication.js +++ b/core/server/api/authentication.js @@ -326,7 +326,9 @@ authentication = { updatedUser.set('status', 'active'); return updatedUser.save(options); }) - .catch(common.errors.ValidationError, (err) => { return Promise.reject(err); }) + .catch(common.errors.ValidationError, (err) => { + return Promise.reject(err); + }) .catch((err) => { if (common.errors.utils.isIgnitionError(err)) { return Promise.reject(err); @@ -411,7 +413,9 @@ authentication = { roles: [invite.toJSON().role_id] }, options); }) - .then(() => { return invite.destroy(options); }); + .then(() => { + return invite.destroy(options); + }); } function formatResponse() { diff --git a/core/server/api/invites.js b/core/server/api/invites.js index 098ef58760..730052f38a 100644 --- a/core/server/api/invites.js +++ b/core/server/api/invites.js @@ -162,7 +162,9 @@ const invites = { return invite.destroy(options); }) - .then(() => { return options; }); + .then(() => { + return options; + }); } function validation(options) { @@ -202,7 +204,9 @@ const invites = { message: common.i18n.t('errors.api.invites.notAllowedToInvite') })); } - }).then(() => { return options; }); + }).then(() => { + return options; + }); } function checkIfUserExists(options) { diff --git a/core/server/api/notifications.js b/core/server/api/notifications.js index 78ad717320..882ed3150a 100644 --- a/core/server/api/notifications.js +++ b/core/server/api/notifications.js @@ -167,7 +167,9 @@ notifications = { // CASE: remove any existing release notifications if a new release notification comes in if (hasReleaseNotification) { - remove(allNotifications, (el) => { return !el.custom; }); + remove(allNotifications, (el) => { + return !el.custom; + }); } // CASE: nothing to add, skip @@ -194,7 +196,9 @@ notifications = { }] }, internalContext); }) - .then(() => { return _private.publicResponse(addedNotifications); }); + .then(() => { + return _private.publicResponse(addedNotifications); + }); } tasks = [ diff --git a/core/server/api/utils.js b/core/server/api/utils.js index ed24dfb663..c609034902 100644 --- a/core/server/api/utils.js +++ b/core/server/api/utils.js @@ -115,7 +115,7 @@ utils = { from: {isDate: true}, to: {isDate: true}, fields: {matches: /^[\w, ]+$/}, - order: {matches: /^[a-z0-9_,\. ]+$/i}, + order: {matches: /^[a-z0-9_,. ]+$/i}, name: {}, email: {isEmail: true} }, diff --git a/core/server/apps/amp/lib/helpers/amp_content.js b/core/server/apps/amp/lib/helpers/amp_content.js index 6b6da50bcc..4ec659a4cd 100644 --- a/core/server/apps/amp/lib/helpers/amp_content.js +++ b/core/server/apps/amp/lib/helpers/amp_content.js @@ -134,7 +134,7 @@ function getAmperizeHTML(html, post) { if (err) { if (err.src) { logging.error(new errors.GhostError({ - message: `AMP HTML couldn\'t get parsed: ${err.src}`, + message: `AMP HTML couldn't get parsed: ${err.src}`, err: err, context: post.url, help: i18n.t('errors.apps.appWillNotBeLoaded.help') diff --git a/core/server/config/utils.js b/core/server/config/utils.js index 3ae1712c5a..8df4d0f304 100644 --- a/core/server/config/utils.js +++ b/core/server/config/utils.js @@ -49,24 +49,24 @@ exports.makePathsAbsolute = function makePathsAbsolute(obj, parent) { */ exports.getContentPath = function getContentPath(type) { switch (type) { - case 'images': - return path.join(this.get('paths:contentPath'), 'images/'); - case 'apps': - return path.join(this.get('paths:contentPath'), 'apps/'); - case 'themes': - return path.join(this.get('paths:contentPath'), 'themes/'); - case 'storage': - return path.join(this.get('paths:contentPath'), 'adapters', 'storage/'); - case 'scheduling': - return path.join(this.get('paths:contentPath'), 'adapters', 'scheduling/'); - case 'logs': - return path.join(this.get('paths:contentPath'), 'logs/'); - case 'data': - return path.join(this.get('paths:contentPath'), 'data/'); - case 'settings': - return path.join(this.get('paths:contentPath'), 'settings/'); - default: - throw new Error('getContentPath was called with: ' + type); + case 'images': + return path.join(this.get('paths:contentPath'), 'images/'); + case 'apps': + return path.join(this.get('paths:contentPath'), 'apps/'); + case 'themes': + return path.join(this.get('paths:contentPath'), 'themes/'); + case 'storage': + return path.join(this.get('paths:contentPath'), 'adapters', 'storage/'); + case 'scheduling': + return path.join(this.get('paths:contentPath'), 'adapters', 'scheduling/'); + case 'logs': + return path.join(this.get('paths:contentPath'), 'logs/'); + case 'data': + return path.join(this.get('paths:contentPath'), 'data/'); + case 'settings': + return path.join(this.get('paths:contentPath'), 'settings/'); + default: + throw new Error('getContentPath was called with: ' + type); } }; diff --git a/core/server/data/importer/importers/image.js b/core/server/data/importer/importers/image.js index 6ba9a2213c..4b6f69a1e8 100644 --- a/core/server/data/importer/importers/image.js +++ b/core/server/data/importer/importers/image.js @@ -1,4 +1,4 @@ -var _ = require('lodash'), +var _ = require('lodash'), Promise = require('bluebird'), storage = require('../../../adapters/storage'), replaceImage, diff --git a/core/server/data/meta/amp_url.js b/core/server/data/meta/amp_url.js index 6dd4431040..0868679e58 100644 --- a/core/server/data/meta/amp_url.js +++ b/core/server/data/meta/amp_url.js @@ -1,6 +1,6 @@ var urlService = require('../../services/url'), getUrl = require('./url'), - _ = require('lodash'); + _ = require('lodash'); function getAmplUrl(data) { var context = data.context ? data.context : null; diff --git a/core/server/data/meta/asset_url.js b/core/server/data/meta/asset_url.js index 877072bdf4..b1dbb38f5e 100644 --- a/core/server/data/meta/asset_url.js +++ b/core/server/data/meta/asset_url.js @@ -30,7 +30,7 @@ function getAssetUrl(path, hasMinFile) { // replace ".foo" with ".min.foo" if configured if (hasMinFile && config.get('useMinFiles') !== false) { - path = path.replace(/\.([^\.]*)$/, '.min.$1'); + path = path.replace(/\.([^.]*)$/, '.min.$1'); } // Add the path for the requested asset diff --git a/core/server/data/meta/author_fb_url.js b/core/server/data/meta/author_fb_url.js index 7f164de868..13b4a1909e 100644 --- a/core/server/data/meta/author_fb_url.js +++ b/core/server/data/meta/author_fb_url.js @@ -1,5 +1,5 @@ var getContextObject = require('./context_object.js'), - _ = require('lodash'); + _ = require('lodash'); function getAuthorFacebookUrl(data) { var context = data.context ? data.context : null, diff --git a/core/server/data/meta/creator_url.js b/core/server/data/meta/creator_url.js index a819a2f572..bdf1fd9948 100644 --- a/core/server/data/meta/creator_url.js +++ b/core/server/data/meta/creator_url.js @@ -1,5 +1,5 @@ var getContextObject = require('./context_object.js'), - _ = require('lodash'); + _ = require('lodash'); function getCreatorTwitterUrl(data) { var context = data.context ? data.context : null, diff --git a/core/server/data/xml/sitemap/handler.js b/core/server/data/xml/sitemap/handler.js index 4f68430502..ea3b34feca 100644 --- a/core/server/data/xml/sitemap/handler.js +++ b/core/server/data/xml/sitemap/handler.js @@ -1,4 +1,4 @@ -const config = require('../../../config'), +const config = require('../../../config'), Manager = require('./manager'), manager = new Manager(); diff --git a/core/server/data/xml/sitemap/manager.js b/core/server/data/xml/sitemap/manager.js index 5bbd5a8bb8..ab340889df 100644 --- a/core/server/data/xml/sitemap/manager.js +++ b/core/server/data/xml/sitemap/manager.js @@ -3,7 +3,7 @@ const common = require('../../../lib/common'), PagesMapGenerator = require('./page-generator'), PostsMapGenerator = require('./post-generator'), UsersMapGenerator = require('./user-generator'), - TagsMapGenerator = require('./tag-generator'); + TagsMapGenerator = require('./tag-generator'); class SiteMapManager { constructor(options) { diff --git a/core/server/data/xml/sitemap/page-generator.js b/core/server/data/xml/sitemap/page-generator.js index 746e491f5a..3d37adcf53 100644 --- a/core/server/data/xml/sitemap/page-generator.js +++ b/core/server/data/xml/sitemap/page-generator.js @@ -1,4 +1,4 @@ -const _ = require('lodash'), +const _ = require('lodash'), BaseMapGenerator = require('./base-generator'); class PageMapGenerator extends BaseMapGenerator { diff --git a/core/server/data/xml/sitemap/tag-generator.js b/core/server/data/xml/sitemap/tag-generator.js index fd80e77bd5..eeabe70046 100644 --- a/core/server/data/xml/sitemap/tag-generator.js +++ b/core/server/data/xml/sitemap/tag-generator.js @@ -1,4 +1,4 @@ -const _ = require('lodash'), +const _ = require('lodash'), BaseMapGenerator = require('./base-generator'); class TagsMapGenerator extends BaseMapGenerator { diff --git a/core/server/filters.js b/core/server/filters.js index 425d218adf..4533473d48 100644 --- a/core/server/filters.js +++ b/core/server/filters.js @@ -1,8 +1,8 @@ // # Filters // Filters are not yet properly used, this system is intended to allow Apps to extend Ghost in various ways. -var Promise = require('bluebird'), - pipeline = require('./lib/promise/pipeline'), - _ = require('lodash'), +var Promise = require('bluebird'), + pipeline = require('./lib/promise/pipeline'), + _ = require('lodash'), defaults; // ## Default values diff --git a/core/server/ghost-server.js b/core/server/ghost-server.js index 5e9562de12..67be59ec08 100644 --- a/core/server/ghost-server.js +++ b/core/server/ghost-server.js @@ -281,7 +281,7 @@ const connectToBootstrapSocket = (message) => { }); client.on('error', (err) => { - common.logging.warn(`Can\'t connect to the bootstrap socket (${socketAddress.host} ${socketAddress.port}) ${err.code}`); + common.logging.warn(`Can't connect to the bootstrap socket (${socketAddress.host} ${socketAddress.port}) ${err.code}`); client.removeAllListeners(); diff --git a/core/server/helpers/body_class.js b/core/server/helpers/body_class.js index b5ca80ee7e..564aaaa48c 100644 --- a/core/server/helpers/body_class.js +++ b/core/server/helpers/body_class.js @@ -32,14 +32,18 @@ module.exports = function body_class(options) { // eslint-disable-line camelcase } if (tags) { - classes = classes.concat(tags.map(function (tag) { return 'tag-' + tag.slug; })); + classes = classes.concat(tags.map(function (tag) { + return 'tag-' + tag.slug; + })); } if (_.includes(context, 'paged')) { classes.push('paged'); } - classes = _.reduce(classes, function (memo, item) { return memo + ' ' + item; }, ''); + classes = _.reduce(classes, function (memo, item) { + return memo + ' ' + item; + }, ''); return new SafeString(classes.trim()); }; diff --git a/core/server/helpers/has.js b/core/server/helpers/has.js index 942007313d..f64fb57195 100644 --- a/core/server/helpers/has.js +++ b/core/server/helpers/has.js @@ -33,7 +33,7 @@ function evaluateTagList(expr, tags) { }).reduce(function (p, c) { return p || (_.findIndex(tags, function (item) { // Escape regex special characters - item = item.replace(/[\-\/\\\^$*+?.()|\[\]{}]/g, '\\$&'); + item = item.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'); item = new RegExp('^' + item + '$', 'i'); return item.test(c); }) !== -1); diff --git a/core/server/lib/common/i18n.js b/core/server/lib/common/i18n.js index 7b8190b463..7d259ed76d 100644 --- a/core/server/lib/common/i18n.js +++ b/core/server/lib/common/i18n.js @@ -210,7 +210,7 @@ I18n = { } catch (err) { themeStrings = undefined; if (err.code === 'ENOENT') { - logging.warn(`Theme\'s file locales/${currentLocale}.json not found.`); + logging.warn(`Theme's file locales/${currentLocale}.json not found.`); } else { throw err; } diff --git a/core/server/lib/ghost-version.js b/core/server/lib/ghost-version.js index 2eb928be70..db9583f09b 100644 --- a/core/server/lib/ghost-version.js +++ b/core/server/lib/ghost-version.js @@ -7,10 +7,10 @@ let _private = {}; _private.compose = function compose(type) { switch (type) { - case 'pre': - return plainVersion + '-' + semver.prerelease(version)[0] + (semver.prerelease(version)[1] ? '.' + semver.prerelease(version)[1] : ''); - default: - return version; + case 'pre': + return plainVersion + '-' + semver.prerelease(version)[0] + (semver.prerelease(version)[1] ? '.' + semver.prerelease(version)[1] : ''); + default: + return version; } }; diff --git a/core/server/models/base/index.js b/core/server/models/base/index.js index 1e76650185..2d578d0ce5 100644 --- a/core/server/models/base/index.js +++ b/core/server/models/base/index.js @@ -925,7 +925,7 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({ _.each(rules, function (rule) { var match, field, direction; - match = /^([a-z0-9_\.]+)\s+(asc|desc)$/i.exec(rule.trim()); + match = /^([a-z0-9_.]+)\s+(asc|desc)$/i.exec(rule.trim()); // invalid order syntax if (!match) { diff --git a/core/server/models/client.js b/core/server/models/client.js index 689f592fa9..3aebf711a6 100644 --- a/core/server/models/client.js +++ b/core/server/models/client.js @@ -1,7 +1,7 @@ -var crypto = require('crypto'), - uuid = require('uuid'), +var crypto = require('crypto'), + uuid = require('uuid'), ghostBookshelf = require('./base'), - config = require('../config'), + config = require('../config'), Client, Clients; diff --git a/core/server/models/refreshtoken.js b/core/server/models/refreshtoken.js index 569f1ff1c8..1734e8afe1 100644 --- a/core/server/models/refreshtoken.js +++ b/core/server/models/refreshtoken.js @@ -1,5 +1,5 @@ -var ghostBookshelf = require('./base'), - Basetoken = require('./base/token'), +var ghostBookshelf = require('./base'), + Basetoken = require('./base/token'), Refreshtoken, Refreshtokens; diff --git a/core/server/services/routing/CollectionRouter.js b/core/server/services/routing/CollectionRouter.js index 91a36c7e53..66a470f801 100644 --- a/core/server/services/routing/CollectionRouter.js +++ b/core/server/services/routing/CollectionRouter.js @@ -66,7 +66,7 @@ class CollectionRouter extends ParentRouter { // REGISTER: is rss enabled? if (this.rss) { - this.rssRouter = new RSSRouter(); + this.rssRouter = new RSSRouter(); this.mountRouter(this.route.value, this.rssRouter.router()); } diff --git a/core/server/services/settings/validate.js b/core/server/services/settings/validate.js index d9ac6b842b..4bce0e9f95 100644 --- a/core/server/services/settings/validate.js +++ b/core/server/services/settings/validate.js @@ -147,7 +147,7 @@ _private.validateData = function validateData(object) { data.query[key][option] = object.data[key][option]; }); - const DEFAULT_RESOURCE = _.find(RESOURCE_CONFIG.QUERY, {resource: data.query[key].resource}); + const DEFAULT_RESOURCE = _.find(RESOURCE_CONFIG.QUERY, {resource: data.query[key].resource}); data.query[key].options = _.pick(object.data[key], allowedQueryOptions); if (data.query[key].type === 'read') { @@ -279,7 +279,7 @@ _private.validateCollections = function validateCollections(collections) { } // CASE: notation /:slug/ or /:primary_author/ is not allowed. We only accept /{{...}}/. - if (routingTypeObject.permalink && routingTypeObject.permalink.match(/\/\:\w+/)) { + if (routingTypeObject.permalink && routingTypeObject.permalink.match(/\/:\w+/)) { throw new common.errors.ValidationError({ message: common.i18n.t('errors.services.settings.yaml.validate', { at: routingTypeObject.permalink, @@ -334,7 +334,7 @@ _private.validateTaxonomies = function validateTaxonomies(taxonomies) { } // CASE: notation /:slug/ or /:primary_author/ is not allowed. We only accept /{{...}}/. - if (routingTypeObject && routingTypeObject.match(/\/\:\w+/)) { + if (routingTypeObject && routingTypeObject.match(/\/:\w+/)) { throw new common.errors.ValidationError({ message: common.i18n.t('errors.services.settings.yaml.validate', { at: routingTypeObject, diff --git a/core/server/services/themes/active.js b/core/server/services/themes/active.js index 4570a016f1..e0ed02292a 100644 --- a/core/server/services/themes/active.js +++ b/core/server/services/themes/active.js @@ -35,7 +35,7 @@ class ActiveTheme { // @TODO: get gscan to return validated, useful package.json fields for us! this._packageInfo = loadedTheme['package.json']; - this._partials = checkedTheme.partials; + this._partials = checkedTheme.partials; // all custom .hbs templates (e.g. custom-about) this._customTemplates = checkedTheme.templates.custom; diff --git a/core/server/services/url/Resources.js b/core/server/services/url/Resources.js index bdd3d2c138..97ac996c46 100644 --- a/core/server/services/url/Resources.js +++ b/core/server/services/url/Resources.js @@ -254,7 +254,9 @@ class Resources { return; } - const targetTagKeys = Object.keys(obj[relation].find((item) => {return item.id === obj[primaryKey].id;})); + const targetTagKeys = Object.keys(obj[relation].find((item) => { + return item.id === obj[primaryKey].id; + })); obj[primaryKey] = _.pick(obj[primaryKey], targetTagKeys); }); } @@ -325,7 +327,9 @@ class Resources { return; } - const targetTagKeys = Object.keys(obj[relation].find((item) => {return item.id === obj[primaryKey].id;})); + const targetTagKeys = Object.keys(obj[relation].find((item) => { + return item.id === obj[primaryKey].id; + })); obj[primaryKey] = _.pick(obj[primaryKey], targetTagKeys); }); } diff --git a/core/server/services/url/utils.js b/core/server/services/url/utils.js index 2d42d9fe64..d44bcd9c64 100644 --- a/core/server/services/url/utils.js +++ b/core/server/services/url/utils.js @@ -65,7 +65,7 @@ function deduplicateSubDir(url) { subDir = subDir.replace(/^\/|\/+$/, ''); // we can have subdirs that match TLDs so we need to restrict matches to // duplicates that start with a / or the beginning of the url - subDirRegex = new RegExp('(^|\/)' + subDir + '\/' + subDir + '\/'); + subDirRegex = new RegExp('(^|/)' + subDir + '/' + subDir + '/'); return url.replace(subDirRegex, '$1' + subDir + '/'); } @@ -325,7 +325,7 @@ function urlFor(context, data, absolute) { // This url already has a protocol so is likely an external url to be returned // or it is an alternative scheme, protocol-less, or an anchor-only path - if (urlPath && (urlPath.indexOf('://') !== -1 || urlPath.match(/^(\/\/|#|[a-zA-Z0-9\-]+:)/))) { + if (urlPath && (urlPath.indexOf('://') !== -1 || urlPath.match(/^(\/\/|#|[a-zA-Z0-9-]+:)/))) { return urlPath; } diff --git a/core/server/web/middleware/cache-control.js b/core/server/web/middleware/cache-control.js index e366094e30..362a755a3f 100644 --- a/core/server/web/middleware/cache-control.js +++ b/core/server/web/middleware/cache-control.js @@ -6,7 +6,7 @@ // // Allows each app to declare its own default caching rules -const _ = require('lodash'), +const _ = require('lodash'), config = require('../../config'); const cacheControl = function cacheControl(options) { diff --git a/core/server/web/middleware/custom-redirects.js b/core/server/web/middleware/custom-redirects.js index 3fd6162733..865fa17eaf 100644 --- a/core/server/web/middleware/custom-redirects.js +++ b/core/server/web/middleware/custom-redirects.js @@ -32,7 +32,7 @@ _private.registerRoutes = function registerRoutes() { } if (redirect.from[redirect.from.length - 1] !== '$') { - redirect.from += '\/?$'; + redirect.from += '/?$'; } debug('register', redirect.from); diff --git a/core/server/web/middleware/error-handler.js b/core/server/web/middleware/error-handler.js index 4567c265ca..352ec65986 100644 --- a/core/server/web/middleware/error-handler.js +++ b/core/server/web/middleware/error-handler.js @@ -129,7 +129,7 @@ _private.ThemeErrorRenderer = function ThemeErrorRenderer(err, req, res, next) { }); }; -_private.HTMLErrorRenderer = function HTMLErrorRender(err, req, res, next) { // eslint-disable-line no-unused-vars +_private.HTMLErrorRenderer = function HTMLErrorRender(err, req, res, next) { // eslint-disable-line no-unused-vars const data = { message: err.message, statusCode: err.statusCode, diff --git a/core/server/web/middleware/uncapitalise.js b/core/server/web/middleware/uncapitalise.js index fdc24556a4..ab248e2b57 100644 --- a/core/server/web/middleware/uncapitalise.js +++ b/core/server/web/middleware/uncapitalise.js @@ -22,7 +22,7 @@ const uncapitalise = function uncapitalise(req, res, next) { decodedURI; const isSignupOrReset = pathToTest.match(/^(.*\/ghost\/(signup|reset)\/)/i), - isAPI = pathToTest.match(/^(.*\/ghost\/api\/v[\d\.]+\/.*?\/)/i); + isAPI = pathToTest.match(/^(.*\/ghost\/api\/v[\d.]+\/.*?\/)/i); if (isSignupOrReset) { pathToTest = isSignupOrReset[1]; diff --git a/package.json b/package.json index 04ca83645a..dae8fff457 100644 --- a/package.json +++ b/package.json @@ -104,6 +104,7 @@ }, "devDependencies": { "eslint": "4.19.1", + "eslint-plugin-ghost": "0.0.27", "grunt": "1.0.3", "grunt-bg-shell": "2.3.3", "grunt-cli": "1.2.0", diff --git a/yarn.lock b/yarn.lock index 1991d1f5f9..e61c3dc052 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1532,6 +1532,10 @@ electron-to-chromium@^1.2.7: version "1.3.48" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.48.tgz#d3b0d8593814044e092ece2108fc3ac9aea4b900" +ember-rfc176-data@^0.3.3: + version "0.3.4" + resolved "https://registry.yarnpkg.com/ember-rfc176-data/-/ember-rfc176-data-0.3.4.tgz#566fd3b7192d02a9a0bfe7e22bbaa4d3a1682e4a" + emits@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/emits/-/emits-3.0.0.tgz#32752bba95e1707b219562384ab9bb8b1fd62f70" @@ -1608,6 +1612,26 @@ escodegen@^1.8.1: optionalDependencies: source-map "~0.6.1" +eslint-plugin-ember@^5.0.3: + version "5.2.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-ember/-/eslint-plugin-ember-5.2.0.tgz#fa436e0497dfc01d1d38608229cd616e7c5b6067" + dependencies: + ember-rfc176-data "^0.3.3" + snake-case "^2.1.0" + +eslint-plugin-ghost@0.0.27: + version "0.0.27" + resolved "https://registry.yarnpkg.com/eslint-plugin-ghost/-/eslint-plugin-ghost-0.0.27.tgz#f0a10d8ae8772f3c1ed0499603712cf7007aafb9" + dependencies: + eslint-plugin-ember "^5.0.3" + eslint-plugin-sort-imports-es6-autofix "0.2.2" + +eslint-plugin-sort-imports-es6-autofix@0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-sort-imports-es6-autofix/-/eslint-plugin-sort-imports-es6-autofix-0.2.2.tgz#6d8512bde75142c188a0695db55d442d7f7e011d" + dependencies: + eslint "^4.15.0" + eslint-scope@^3.7.1: version "3.7.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8" @@ -1619,7 +1643,7 @@ eslint-visitor-keys@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" -eslint@4.19.1, eslint@^4.0.0: +eslint@4.19.1, eslint@^4.0.0, eslint@^4.15.0: version "4.19.1" resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.19.1.tgz#32d1d653e1d90408854bfb296f076ec7e186a300" dependencies: @@ -3640,6 +3664,10 @@ loud-rejection@^1.0.0: currently-unhandled "^0.4.1" signal-exit "^3.0.0" +lower-case@^1.1.1: + version "1.1.4" + resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-1.1.4.tgz#9a2cabd1b9e8e0ae993a4bf7d5875c39c42e8eac" + lowercase-keys@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" @@ -4092,6 +4120,12 @@ nise@^1.2.0: path-to-regexp "^1.7.0" text-encoding "^0.6.4" +no-case@^2.2.0: + version "2.3.2" + resolved "https://registry.yarnpkg.com/no-case/-/no-case-2.3.2.tgz#60b813396be39b3f1288a4c1ed5d1e7d28b464ac" + dependencies: + lower-case "^1.1.1" + nock@9.4.0: version "9.4.0" resolved "https://registry.yarnpkg.com/nock/-/nock-9.4.0.tgz#d151c0020c9c10fe2f139c4bc7498457959eddc8" @@ -5539,6 +5573,12 @@ slice-ansi@1.0.0: dependencies: is-fullwidth-code-point "^2.0.0" +snake-case@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/snake-case/-/snake-case-2.1.0.tgz#41bdb1b73f30ec66a04d4e2cad1b76387d4d6d9f" + dependencies: + no-case "^2.2.0" + snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b"