gscan 4.29.0 → 4.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/tpl/error.hbs +1 -1
- package/app/tpl/index.hbs +2 -2
- package/app/tpl/layouts/default.hbs +8 -8
- package/bin/cli.js +2 -2
- package/lib/ast-linter/rules/index.js +5 -1
- package/lib/ast-linter/rules/internal/scope.js +14 -0
- package/lib/ast-linter/rules/lint-no-price-data-currency-context.js +26 -0
- package/lib/ast-linter/rules/lint-no-price-data-currency-global.js +26 -0
- package/lib/ast-linter/rules/lint-no-price-data-monthly-yearly.js +20 -0
- package/lib/ast-linter/rules/lint-no-tier-benefit-as-object.js +30 -0
- package/lib/ast-linter/rules/{lint-no-price-data-helper.js → lint-no-tier-price-as-object.js} +6 -3
- package/lib/checks/010-package-json.js +9 -1
- package/lib/format.js +1 -24
- package/lib/specs/canary.js +56 -18
- package/lib/specs/v1.js +40 -40
- package/lib/specs/v2.js +31 -29
- package/lib/specs/v3.js +6 -5
- package/lib/specs/v4.js +18 -16
- package/lib/utils/score-calculator.js +40 -0
- package/lib/utils/versions.json +1 -1
- package/package.json +4 -4
package/lib/specs/v3.js
CHANGED
|
@@ -2,8 +2,9 @@ const _ = require('lodash');
|
|
|
2
2
|
const oneLineTrim = require('common-tags/lib/oneLineTrim');
|
|
3
3
|
const previousSpec = require('./v2');
|
|
4
4
|
const ghostVersions = require('../utils').versions;
|
|
5
|
-
const docsBaseUrl = `https://ghost.org/docs/
|
|
6
|
-
|
|
5
|
+
const docsBaseUrl = `https://ghost.org/docs/themes/`;
|
|
6
|
+
// TODO: we don't use versioned docs anymore and the previous rules should only contain
|
|
7
|
+
// correct links. The usage of replacing the previousBaseUrl can probably be removed
|
|
7
8
|
const prevDocsBaseUrl = `https://themes.ghost.org/v${ghostVersions.v2.docs}/docs/`;
|
|
8
9
|
const prevDocsBaseUrlRegEx = new RegExp(prevDocsBaseUrl, 'g');
|
|
9
10
|
|
|
@@ -21,14 +22,14 @@ let rules = {
|
|
|
21
22
|
rule: '<code>package.json</code> property <code>"engines.ghost-api"</code> is recommended. Otherwise, it falls back to "v3"',
|
|
22
23
|
details: oneLineTrim`Please add <code>"ghost-api"</code> to your <code>package.json</code>. E.g. <code>{"engines": {"ghost-api": "v3"}}</code>.<br>
|
|
23
24
|
If no <code>"ghost-api"</code> property is provided, Ghost will use its default setting of "v3" Ghost API.<br>
|
|
24
|
-
Check the <a href="${docsBaseUrl}packagejson
|
|
25
|
+
Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
25
26
|
},
|
|
26
27
|
'GS010-PJ-GHOST-API-V01': {
|
|
27
28
|
level: 'error',
|
|
28
29
|
rule: '<code>package.json</code> property <code>"engines.ghost-api"</code> is incompatible with current version of Ghost API and will fall back to "v3"',
|
|
29
30
|
details: oneLineTrim`Please change <code>"ghost-api"</code> in your <code>package.json</code> to higher version. E.g. <code>{"engines": {"ghost-api": "v3"}}</code>.<br>
|
|
30
31
|
If <code>"ghost-api"</code> property is left at "v0.1", Ghost will use its default setting of "v3".<br>
|
|
31
|
-
Check the <a href="${docsBaseUrl}packagejson
|
|
32
|
+
Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
32
33
|
},
|
|
33
34
|
'GS001-DEPR-ESC': {
|
|
34
35
|
level: 'error',
|
|
@@ -43,7 +44,7 @@ let rules = {
|
|
|
43
44
|
level: 'error',
|
|
44
45
|
rule: 'The v0.1 API and <code>ghost.url.api()</code> JavaScript helper have been removed.',
|
|
45
46
|
details: oneLineTrim`The v0.1 API & Public API Beta have been removed, along with the <code>public/ghost-sdk.min.js</code> file & the <code>ghost.url.api()</code> helper.<br>
|
|
46
|
-
All code relying on the v0.1 API must be upgraded to use the <a href="
|
|
47
|
+
All code relying on the v0.1 API must be upgraded to use the <a href="https://ghost.org/docs/changes/" target=_blank>new API</a>.`,
|
|
47
48
|
regex: /ghost\.url\.api/g
|
|
48
49
|
},
|
|
49
50
|
'GS070-VALID-TRANSLATIONS': {
|
package/lib/specs/v4.js
CHANGED
|
@@ -3,6 +3,8 @@ const oneLineTrim = require('common-tags/lib/oneLineTrim');
|
|
|
3
3
|
const previousSpec = require('./v3');
|
|
4
4
|
const ghostVersions = require('../utils').versions;
|
|
5
5
|
const docsBaseUrl = `https://ghost.org/docs/themes/`;
|
|
6
|
+
// TODO: we don't use versioned docs anymore and the previous rules should only contain
|
|
7
|
+
// correct links. The usage of replacing the previousBaseUrl can probably be removed
|
|
6
8
|
const prevDocsBaseUrl = `https://themes.ghost.org/v${ghostVersions.v3.docs}/docs/`;
|
|
7
9
|
const prevDocsBaseUrlRegEx = new RegExp(prevDocsBaseUrl, 'g');
|
|
8
10
|
|
|
@@ -15,7 +17,7 @@ function cssCardRule(cardName, className) {
|
|
|
15
17
|
level: 'warning',
|
|
16
18
|
rule: `The <code>.${className}</code> CSS class is required to appear styled in your theme`,
|
|
17
19
|
details: oneLineTrim`The <code>.${className}</code> CSS class is required otherwise the ${cardName} card will appear unstyled.
|
|
18
|
-
Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}
|
|
20
|
+
Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}content/" target=_blank>here</a>.`,
|
|
19
21
|
regex: new RegExp(`\\.${className}`, 'g'),
|
|
20
22
|
className: `.${className}`,
|
|
21
23
|
css: true,
|
|
@@ -33,75 +35,75 @@ let rules = {
|
|
|
33
35
|
rule: '<code>package.json</code> property <code>"engines.ghost-api"</code> is deprecated.',
|
|
34
36
|
details: oneLineTrim`Remove <code>"ghost-api"</code> from your <code>package.json</code>.<br>
|
|
35
37
|
The <code>ghost-api</code> support will be removed in next major version of Ghost and should not be used.
|
|
36
|
-
Check the <a href="${docsBaseUrl}packagejson
|
|
38
|
+
Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
37
39
|
},
|
|
38
40
|
'GS010-PJ-GHOST-API-V01': {
|
|
39
41
|
level: 'error',
|
|
40
42
|
rule: '<code>package.json</code> property <code>"engines.ghost-api"</code> is incompatible with current version of Ghost API and will fall back to "v4"',
|
|
41
43
|
details: oneLineTrim`Change <code>"ghost-api"</code> in your <code>package.json</code> to higher version. E.g. <code>{"engines": {"ghost-api": "v4"}}</code>.<br>
|
|
42
44
|
If <code>"ghost-api"</code> property is left at "v0.1", Ghost will use its default setting of "v4".<br>
|
|
43
|
-
Check the <a href="${docsBaseUrl}packagejson
|
|
45
|
+
Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
44
46
|
},
|
|
45
47
|
'GS010-PJ-GHOST-API-V2': {
|
|
46
48
|
level: 'warning',
|
|
47
49
|
rule: '<code>package.json</code> property <code>"engines.ghost-api"</code> is using a deprecated version of Ghost API',
|
|
48
50
|
details: oneLineTrim`Change <code>"ghost-api"</code> in your <code>package.json</code> to higher version. E.g. <code>{"engines": {"ghost-api": "v4"}}</code>.<br>
|
|
49
51
|
If <code>"ghost-api"</code> property is left at "v2", it will stop working with next major version upgrade and default to v5.<br>
|
|
50
|
-
Check the <a href="${docsBaseUrl}packagejson
|
|
52
|
+
Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
51
53
|
},
|
|
52
54
|
'GS010-PJ-CUST-THEME-TOTAL-SETTINGS': {
|
|
53
55
|
level: 'error',
|
|
54
56
|
rule: '<code>package.json</code> property <code>"config.custom"</code> contains too many settings',
|
|
55
57
|
details: oneLineTrim`Remove key from <code>"config.custom"</code> in your <code>package.json</code> to have less than or exactly 15 settings.<br>
|
|
56
|
-
Check the <a href="${docsBaseUrl}packagejson
|
|
58
|
+
Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
57
59
|
},
|
|
58
60
|
'GS010-PJ-CUST-THEME-SETTINGS-CASE': {
|
|
59
61
|
level: 'error',
|
|
60
62
|
rule: '<code>package.json</code> property <code>"config.custom"</code> contains a property that isn\'t snake-cased',
|
|
61
63
|
details: oneLineTrim`Rewrite all property in <code>"config.custom"</code> in your <code>package.json</code> in snake case.<br>
|
|
62
|
-
Check the <a href="${docsBaseUrl}packagejson
|
|
64
|
+
Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
63
65
|
},
|
|
64
66
|
'GS010-PJ-CUST-THEME-SETTINGS-TYPE': {
|
|
65
67
|
level: 'error',
|
|
66
68
|
rule: '<code>package.json</code> objects defined in <code>"config.custom"</code> should have a known <code>"type"</code>.',
|
|
67
69
|
details: oneLineTrim`Only use the following types: <code>"select"</code>, <code>"boolean"</code>, <code>"color"</code>, <code>"image"</code>, <code>"text"</code>.<br>
|
|
68
|
-
Check the <a href="${docsBaseUrl}packagejson
|
|
70
|
+
Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
69
71
|
},
|
|
70
72
|
'GS010-PJ-CUST-THEME-SETTINGS-GROUP': {
|
|
71
73
|
level: 'recommendation',
|
|
72
74
|
rule: '<code>package.json</code> objects defined in <code>"config.custom"</code> should have a known <code>"group"</code>.',
|
|
73
75
|
details: oneLineTrim`Only use the following groups: <code>"post"</code>, <code>"homepage"</code>.<br>
|
|
74
|
-
Check the <a href="${docsBaseUrl}packagejson
|
|
76
|
+
Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
75
77
|
},
|
|
76
78
|
'GS010-PJ-CUST-THEME-SETTINGS-SELECT-OPTIONS': {
|
|
77
79
|
level: 'error',
|
|
78
80
|
rule: '<code>package.json</code> objects defined in <code>"config.custom"</code> of type <code>"select"</code> need to have at least 2 <code>"options"</code>.',
|
|
79
81
|
details: oneLineTrim`Make sure there is at least 2 <code>"options"</code> in each <code>"select"</code> custom theme property.<br>
|
|
80
|
-
Check the <a href="${docsBaseUrl}packagejson
|
|
82
|
+
Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
81
83
|
},
|
|
82
84
|
'GS010-PJ-CUST-THEME-SETTINGS-SELECT-DEFAULT': {
|
|
83
85
|
level: 'error',
|
|
84
86
|
rule: '<code>package.json</code> objects defined in <code>"config.custom"</code> of type <code>"select"</code> need to have a valid <code>"default"</code>.',
|
|
85
87
|
details: oneLineTrim`Make sure the <code>"default"</code> property matches a value in <code>"options"</code> of the same <code>"select"</code>.<br>
|
|
86
|
-
Check the <a href="${docsBaseUrl}packagejson
|
|
88
|
+
Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
87
89
|
},
|
|
88
90
|
'GS010-PJ-CUST-THEME-SETTINGS-BOOLEAN-DEFAULT': {
|
|
89
91
|
level: 'error',
|
|
90
92
|
rule: '<code>package.json</code> objects defined in <code>"config.custom"</code> of type <code>"boolean"</code> need to have a valid <code>"default"</code>.',
|
|
91
93
|
details: oneLineTrim`Make sure the <code>"default"</code> property is either <code>true</code> or <code>false</code>.<br>
|
|
92
|
-
Check the <a href="${docsBaseUrl}packagejson
|
|
94
|
+
Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
93
95
|
},
|
|
94
96
|
'GS010-PJ-CUST-THEME-SETTINGS-COLOR-DEFAULT': {
|
|
95
97
|
level: 'error',
|
|
96
98
|
rule: '<code>package.json</code> objects defined in <code>"config.custom"</code> of type <code>"color"</code> need to have a valid <code>"default"</code>.',
|
|
97
99
|
details: oneLineTrim`Make sure the <code>"default"</code> property is a valid 6-hexadecimal-digit color code like <code>#15171a</code>.<br>
|
|
98
|
-
Check the <a href="${docsBaseUrl}packagejson
|
|
100
|
+
Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
99
101
|
},
|
|
100
102
|
'GS010-PJ-CUST-THEME-SETTINGS-IMAGE-DEFAULT': {
|
|
101
103
|
level: 'error',
|
|
102
104
|
rule: '<code>package.json</code> objects defined in <code>"config.custom"</code> of type <code>"image"</code> can\'t have a <code>"default"</code> value.',
|
|
103
105
|
details: oneLineTrim`Make sure the <code>"default"</code> property is either <code>null</code>, an empty string <code>''</code> or isn't present.<br>
|
|
104
|
-
Check the <a href="${docsBaseUrl}packagejson
|
|
106
|
+
Check the <a href="${docsBaseUrl}structure/#packagejson" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
105
107
|
},
|
|
106
108
|
'GS001-DEPR-LABS-MEMBERS': {
|
|
107
109
|
level: 'warning',
|
|
@@ -114,8 +116,8 @@ let rules = {
|
|
|
114
116
|
},
|
|
115
117
|
'GS080-FEACH-POSTS': {
|
|
116
118
|
level: 'warning',
|
|
117
|
-
rule: 'The default visibility for posts in <code>{{#foreach}}</code> block helper
|
|
118
|
-
details: oneLineTrim`The default visibility for posts in <code>{{#foreach}}</code> block helper
|
|
119
|
+
rule: 'The default visibility for posts in <code>{{#foreach}}</code> block helper changed in Ghost v4.',
|
|
120
|
+
details: oneLineTrim`The default visibility for posts in <code>{{#foreach}}</code> block helper changed from <code>public</code> to <code>all</code>.<br>
|
|
119
121
|
Find more information about the <code>{{foreach}}</code> helper <a href="${docsBaseUrl}helpers/foreach/" target=_blank>here</a>.`,
|
|
120
122
|
regex: /{{\s*?#foreach\s*?\w*?\s*?}}/g,
|
|
121
123
|
helper: '{{#foreach}}',
|
|
@@ -133,7 +135,7 @@ let rules = {
|
|
|
133
135
|
'GS080-FEACH-PV': {
|
|
134
136
|
level: 'recommendation',
|
|
135
137
|
rule: 'The use of <code>visibility="all"</code> is no longer required for posts in <code>{{#foreach}}</code> helper.',
|
|
136
|
-
details: oneLineTrim`The default visibility in <code>{{#foreach}}</code> helper for posts
|
|
138
|
+
details: oneLineTrim`The default visibility in <code>{{#foreach}}</code> helper for posts changed in v4 from <code>public</code> to <code>all</code> and is no longer required when looping over posts.<br>
|
|
137
139
|
Check out the documentation for <code>{{#foreach}}</code> <a href="${docsBaseUrl}helpers/foreach/" target=_blank>here</a>.`,
|
|
138
140
|
regex: /{{\s*?#foreach\b[\w\s='"]*?visibility=("|')all("|')[\w\s='"]*?}}/g,
|
|
139
141
|
helper: '{{#foreach}}',
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const _ = require('lodash');
|
|
2
|
+
|
|
3
|
+
const levelWeights = {
|
|
4
|
+
error: 10,
|
|
5
|
+
warning: 3,
|
|
6
|
+
recommendation: 1
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} results
|
|
12
|
+
* @param {Object} results.error
|
|
13
|
+
* @param {Object} results.warning
|
|
14
|
+
* @param {Object} results.recommendation
|
|
15
|
+
* @param {Object} stats
|
|
16
|
+
* @param {Object} stats.error
|
|
17
|
+
* @param {Object} stats.warning
|
|
18
|
+
* @param {Object} stats.recommendation
|
|
19
|
+
* @returns {Object}
|
|
20
|
+
*/
|
|
21
|
+
const calcScore = function calcScore(results, stats) {
|
|
22
|
+
var maxScore, actualScore, balancedScore;
|
|
23
|
+
|
|
24
|
+
maxScore = _.reduce(levelWeights, function (max, weight, level) {
|
|
25
|
+
return max + (weight * stats[level]);
|
|
26
|
+
}, 0);
|
|
27
|
+
|
|
28
|
+
actualScore = _.reduce(levelWeights, function (max, weight, level) {
|
|
29
|
+
return max - (weight * _.size(results[level]));
|
|
30
|
+
}, maxScore);
|
|
31
|
+
|
|
32
|
+
balancedScore = _.floor((100 / maxScore) * actualScore);
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
value: balancedScore,
|
|
36
|
+
level: _.size(results.error) > 0 ? 'error' : balancedScore < 60 ? 'warning' : 'passing'
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
module.exports = calcScore;
|
package/lib/utils/versions.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gscan",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.30.0",
|
|
4
4
|
"description": "Scans Ghost themes looking for errors, deprecations, features and compatibility",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ghost",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"validator",
|
|
9
9
|
"lint"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://ghost.org",
|
|
11
|
+
"homepage": "https://ghost.org/",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "git@github.com:TryGhost/gscan.git"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"author": {
|
|
23
23
|
"name": "Ghost Foundation",
|
|
24
24
|
"email": "hello@ghost.org",
|
|
25
|
-
"web": "https://ghost.org"
|
|
25
|
+
"web": "https://ghost.org/"
|
|
26
26
|
},
|
|
27
27
|
"main": "lib",
|
|
28
28
|
"license": "MIT",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@tryghost/debug": "0.1.11",
|
|
46
46
|
"@tryghost/errors": "1.2.12",
|
|
47
47
|
"@tryghost/logging": "2.1.8",
|
|
48
|
-
"@tryghost/pretty-cli": "1.2.
|
|
48
|
+
"@tryghost/pretty-cli": "1.2.28",
|
|
49
49
|
"@tryghost/server": "0.1.4",
|
|
50
50
|
"@tryghost/zip": "1.1.25",
|
|
51
51
|
"bluebird": "3.7.2",
|