gscan 4.12.0 → 4.13.3
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.
|
@@ -73,7 +73,7 @@ function classifyNode(sexpr, options = {knownHelpers: [], knownHelpersOnly: fals
|
|
|
73
73
|
// An eligible helper is one that does not have a complex path, i.e. `this.foo`, `../foo` etc.
|
|
74
74
|
if (isEligible && !isHelper) {
|
|
75
75
|
let name = sexpr.path.parts[0];
|
|
76
|
-
if (options.knownHelpers
|
|
76
|
+
if (options.knownHelpers.includes(name)) {
|
|
77
77
|
isHelper = true;
|
|
78
78
|
} else if (options.knownHelpersOnly) {
|
|
79
79
|
isEligible = false;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const Rule = require('./base');
|
|
2
|
-
const {
|
|
2
|
+
const {getPartialName} = require('../helpers');
|
|
3
3
|
|
|
4
4
|
module.exports = class NoUnknownPartials extends Rule {
|
|
5
5
|
_checkForUnknownPartials(node) {
|
|
6
6
|
if (node.name) {
|
|
7
7
|
if (!this.isValidPartialReference(node)) {
|
|
8
8
|
this.log({
|
|
9
|
-
message: `The partial ${
|
|
9
|
+
message: `The partial ${getPartialName(node)} could not be found`,
|
|
10
10
|
line: node.loc && node.loc.start.line,
|
|
11
11
|
column: node.loc && node.loc.start.column,
|
|
12
12
|
source: this.sourceForNode(node)
|
package/lib/specs/canary.js
CHANGED
|
@@ -10,6 +10,19 @@ const previousKnownHelpers = previousSpec.knownHelpers;
|
|
|
10
10
|
const previousTemplates = previousSpec.templates;
|
|
11
11
|
const previousRules = previousSpec.rules;
|
|
12
12
|
|
|
13
|
+
function cssCardRule(cardName, className) {
|
|
14
|
+
return {
|
|
15
|
+
level: 'warning',
|
|
16
|
+
rule: `The <code>.${className}</code> CSS class is required to appear styled in your theme`,
|
|
17
|
+
details: oneLineTrim`The <code>.${className}</code> CSS class is required otherwise wide images will appear unstyled.
|
|
18
|
+
Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/" target=_blank>here</a>.`,
|
|
19
|
+
regex: new RegExp(`\\.${className}`, 'g'),
|
|
20
|
+
className: `.${className}`,
|
|
21
|
+
css: true,
|
|
22
|
+
cardAsset: cardName
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
13
26
|
// assign new or overwrite existing knownHelpers, templates, or rules here:
|
|
14
27
|
let knownHelpers = ['match'];
|
|
15
28
|
let templates = [];
|
|
@@ -18,70 +31,70 @@ let rules = {
|
|
|
18
31
|
'GS010-PJ-GHOST-API': {
|
|
19
32
|
level: 'warning',
|
|
20
33
|
rule: '<code>package.json</code> property <code>"engines.ghost-api"</code> is recommended. Otherwise, it falls back to "v4"',
|
|
21
|
-
details: oneLineTrim`
|
|
34
|
+
details: oneLineTrim`Add <code>"ghost-api"</code> to your <code>package.json</code>. E.g. <code>{"engines": {"ghost-api": "v4"}}</code>.<br>
|
|
22
35
|
If no <code>"ghost-api"</code> property is provided, Ghost will use its default setting of "v4" Ghost API.<br>
|
|
23
36
|
Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
24
37
|
},
|
|
25
38
|
'GS010-PJ-GHOST-API-V01': {
|
|
26
39
|
level: 'error',
|
|
27
40
|
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"',
|
|
28
|
-
details: oneLineTrim`
|
|
41
|
+
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>
|
|
29
42
|
If <code>"ghost-api"</code> property is left at "v0.1", Ghost will use its default setting of "v4".<br>
|
|
30
43
|
Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
31
44
|
},
|
|
32
45
|
'GS010-PJ-GHOST-API-V2': {
|
|
33
46
|
level: 'warning',
|
|
34
47
|
rule: '<code>package.json</code> property <code>"engines.ghost-api"</code> is using a deprecated version of Ghost API',
|
|
35
|
-
details: oneLineTrim`
|
|
48
|
+
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>
|
|
36
49
|
If <code>"ghost-api"</code> property is left at "v2", it will stop working with next major version upgrade and default to v5.<br>
|
|
37
50
|
Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
38
51
|
},
|
|
39
52
|
'GS010-PJ-CUST-THEME-TOTAL-SETTINGS': {
|
|
40
53
|
level: 'error',
|
|
41
54
|
rule: '<code>package.json</code> property <code>"config.custom"</code> contains too many settings',
|
|
42
|
-
details: oneLineTrim`
|
|
55
|
+
details: oneLineTrim`Remove key from <code>"config.custom"</code> in your <code>package.json</code> to have less than or exactly 15 settings.<br>
|
|
43
56
|
Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
44
57
|
},
|
|
45
58
|
'GS010-PJ-CUST-THEME-SETTINGS-CASE': {
|
|
46
59
|
level: 'error',
|
|
47
60
|
rule: '<code>package.json</code> property <code>"config.custom"</code> contains a property that isn\'t snake-cased',
|
|
48
|
-
details: oneLineTrim`
|
|
61
|
+
details: oneLineTrim`Rewrite all property in <code>"config.custom"</code> in your <code>package.json</code> in snake case.<br>
|
|
49
62
|
Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
50
63
|
},
|
|
51
64
|
'GS010-PJ-CUST-THEME-SETTINGS-TYPE': {
|
|
52
65
|
level: 'error',
|
|
53
66
|
rule: '<code>package.json</code> objects defined in <code>"config.custom"</code> should have a known <code>"type"</code>.',
|
|
54
|
-
details: oneLineTrim`
|
|
67
|
+
details: oneLineTrim`Only use the following types: <code>"select"</code>, <code>"boolean"</code>, <code>"color"</code>, <code>"image"</code>, <code>"text"</code>.<br>
|
|
55
68
|
Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
56
69
|
},
|
|
57
70
|
'GS010-PJ-CUST-THEME-SETTINGS-GROUP': {
|
|
58
71
|
level: 'recommendation',
|
|
59
72
|
rule: '<code>package.json</code> objects defined in <code>"config.custom"</code> should have a known <code>"group"</code>.',
|
|
60
|
-
details: oneLineTrim`
|
|
73
|
+
details: oneLineTrim`Only use the following groups: <code>"post"</code>, <code>"homepage"</code>.<br>
|
|
61
74
|
Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
62
75
|
},
|
|
63
76
|
'GS010-PJ-CUST-THEME-SETTINGS-SELECT-OPTIONS': {
|
|
64
77
|
level: 'error',
|
|
65
78
|
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>.',
|
|
66
|
-
details: oneLineTrim`
|
|
79
|
+
details: oneLineTrim`Make sure there is at least 2 <code>"options"</code> in each <code>"select"</code> custom theme property.<br>
|
|
67
80
|
Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
68
81
|
},
|
|
69
82
|
'GS010-PJ-CUST-THEME-SETTINGS-SELECT-DEFAULT': {
|
|
70
83
|
level: 'error',
|
|
71
84
|
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>.',
|
|
72
|
-
details: oneLineTrim`
|
|
85
|
+
details: oneLineTrim`Make sure the <code>"default"</code> property matches a value in <code>"options"</code> of the same <code>"select"</code>.<br>
|
|
73
86
|
Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
74
87
|
},
|
|
75
88
|
'GS010-PJ-CUST-THEME-SETTINGS-BOOLEAN-DEFAULT': {
|
|
76
89
|
level: 'error',
|
|
77
90
|
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>.',
|
|
78
|
-
details: oneLineTrim`
|
|
91
|
+
details: oneLineTrim`Make sure the <code>"default"</code> property is either <code>true</code> or <code>false</code>.<br>
|
|
79
92
|
Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
80
93
|
},
|
|
81
94
|
'GS010-PJ-CUST-THEME-SETTINGS-COLOR-DEFAULT': {
|
|
82
95
|
level: 'error',
|
|
83
96
|
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>.',
|
|
84
|
-
details: oneLineTrim`
|
|
97
|
+
details: oneLineTrim`Make sure the <code>"default"</code> property is a valid 6-hexadecimal-digit color code like <code>#15171a</code>.<br>
|
|
85
98
|
Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
86
99
|
},
|
|
87
100
|
'GS010-PJ-CUST-THEME-SETTINGS-IMAGE-DEFAULT': {
|
|
@@ -93,7 +106,7 @@ let rules = {
|
|
|
93
106
|
'GS001-DEPR-LABS-MEMBERS': {
|
|
94
107
|
level: 'warning',
|
|
95
108
|
rule: 'The <code>{{@labs.members}}</code> helper should not be used.',
|
|
96
|
-
details: oneLineTrim`
|
|
109
|
+
details: oneLineTrim`Remove <code>{{@labs.members}}</code> from the theme.<br>
|
|
97
110
|
The <code>{{@labs.members}}</code> helper will always return <code>true</code> in Ghost v4 and will be removed from Ghost v5, at which point it will return <code>null</code> and evaluate to <code>false</code>.
|
|
98
111
|
Find more information about the <code>@labs</code> property <a href="${docsBaseUrl}helpers/labs/" target=_blank>here</a>.`,
|
|
99
112
|
regex: /@labs\.members/g,
|
|
@@ -137,7 +150,7 @@ let rules = {
|
|
|
137
150
|
'GS001-DEPR-SITE-LANG': {
|
|
138
151
|
level: 'warning',
|
|
139
152
|
rule: 'The <code>{{@site.lang}}</code> helper should be replaced with <code>{{@site.locale}}</code>',
|
|
140
|
-
details: oneLineTrim`
|
|
153
|
+
details: oneLineTrim`Replace <code>{{@site.lang}}</code> helper with <code>{{@site.locale}}</code>.<br>
|
|
141
154
|
The <code>{{@site.lang}}</code> helper will be removed in next version of Ghost and should not be used.
|
|
142
155
|
Find more information about the <code>@site</code> property <a href="${docsBaseUrl}helpers/site/" target=_blank>here</a>.`,
|
|
143
156
|
regex: /@site\.lang/g,
|
|
@@ -171,7 +184,19 @@ let rules = {
|
|
|
171
184
|
level: 'error',
|
|
172
185
|
rule: 'A custom theme setting defined in <code>package.json</code> hasn\'t been used in any theme file.',
|
|
173
186
|
details: oneLineTrim`Custom theme settings defined in <code>package.json</code> must be used at least once in the theme templates.`
|
|
174
|
-
}
|
|
187
|
+
},
|
|
188
|
+
'GS050-CSS-KGCO': cssCardRule('callout', 'kg-card-callout'),
|
|
189
|
+
'GS050-CSS-KGCOE': cssCardRule('callout', 'kg-card-callout-emoji'),
|
|
190
|
+
'GS050-CSS-KGCOT': cssCardRule('callout', 'kg-card-callout-text'),
|
|
191
|
+
'GS050-CSS-KGCOBGGY': cssCardRule('callout', 'kg-card-callout-background-grey'),
|
|
192
|
+
'GS050-CSS-KGCOBGW': cssCardRule('callout', 'kg-card-callout-background-white'),
|
|
193
|
+
'GS050-CSS-KGCOBGB': cssCardRule('callout', 'kg-card-callout-background-blue'),
|
|
194
|
+
'GS050-CSS-KGCOBGGN': cssCardRule('callout', 'kg-card-callout-background-green'),
|
|
195
|
+
'GS050-CSS-KGCOBGY': cssCardRule('callout', 'kg-card-callout-background-yellow'),
|
|
196
|
+
'GS050-CSS-KGCOBGR': cssCardRule('callout', 'kg-card-callout-background-red'),
|
|
197
|
+
'GS050-CSS-KGCOBGPK': cssCardRule('callout', 'kg-card-callout-background-pink'),
|
|
198
|
+
'GS050-CSS-KGCOBGPE': cssCardRule('callout', 'kg-card-callout-background-purple'),
|
|
199
|
+
'GS050-CSS-KGCOBGA': cssCardRule('callout', 'kg-card-callout-background-accent')
|
|
175
200
|
};
|
|
176
201
|
|
|
177
202
|
knownHelpers = _.union(previousKnownHelpers, knownHelpers);
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy of Ghost defaults for https://github.com/TryGhost/Ghost/blob/e25f1df0ae551c447da0d319bae06eadf9665444/core/frontend/services/theme-engine/config/defaults.json
|
|
3
|
+
*/
|
|
4
|
+
const defaultConfig = {
|
|
5
|
+
posts_per_page: 5,
|
|
6
|
+
card_assets: {
|
|
7
|
+
exclude: ['bookmark', 'gallery']
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
1
11
|
/**
|
|
2
12
|
* Extracts the package.json JSON content. Note that this function never throws,
|
|
3
13
|
* even when there is a JSON parsing error.
|
|
14
|
+
* This function uses the default `config` property to match Ghost implementation.
|
|
4
15
|
* @param {Object} theme The theme to extract package.json from.
|
|
5
16
|
* @returns {Object} The content of the package.json file, or `null` if
|
|
6
17
|
* something happened (no file, JSON parsing error...).
|
|
@@ -9,12 +20,21 @@ function getJSON(theme) {
|
|
|
9
20
|
let packageJSON = theme.files.find(item => item.file === 'package.json');
|
|
10
21
|
if (packageJSON && packageJSON.content) {
|
|
11
22
|
try {
|
|
12
|
-
|
|
23
|
+
const json = JSON.parse(packageJSON.content);
|
|
24
|
+
|
|
25
|
+
// Use the default .config and allow it to be overwritten
|
|
26
|
+
const content = Object.assign({}, json, {
|
|
27
|
+
config: Object.assign({}, defaultConfig, json.config)
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return content;
|
|
13
31
|
} catch (e) {
|
|
14
32
|
// Do nothing here
|
|
15
33
|
}
|
|
16
34
|
}
|
|
17
|
-
return
|
|
35
|
+
return {
|
|
36
|
+
config: defaultConfig
|
|
37
|
+
};
|
|
18
38
|
}
|
|
19
39
|
|
|
20
40
|
module.exports = getJSON;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gscan",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.13.3",
|
|
4
4
|
"description": "Scans Ghost themes looking for errors, deprecations, features and compatibility",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ghost",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@tryghost/config": "0.2.1",
|
|
45
45
|
"@tryghost/debug": "0.1.9",
|
|
46
46
|
"@tryghost/ignition-errors": "0.1.8",
|
|
47
|
-
"@tryghost/logging": "1.0.
|
|
47
|
+
"@tryghost/logging": "1.0.2",
|
|
48
48
|
"@tryghost/pretty-cli": "1.2.22",
|
|
49
49
|
"@tryghost/server": "0.1.0",
|
|
50
50
|
"@tryghost/zip": "1.1.18",
|