gscan 4.8.0 → 4.9.2
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/lib/ast-linter/rules/lint-no-unknown-custom-theme-select-value-in-match.js +10 -2
- package/lib/checks/010-package-json.js +6 -0
- package/lib/checks/090-template-syntax.js +6 -0
- package/lib/checks/100-custom-template-settings-usage.js +6 -0
- package/lib/read-theme.js +1 -1
- package/lib/specs/canary.js +6 -0
- package/package.json +3 -3
|
@@ -17,8 +17,16 @@ function getCustomSettingValue(node) {
|
|
|
17
17
|
module.exports = class NoUnknownCustomThemeSelectValueInMatch extends Rule {
|
|
18
18
|
_checkForCustomThemeSelectValueInMatch(node) {
|
|
19
19
|
if (node.path.original === 'match' && node.params.length === 3) {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
if (node.params.length < 2 || node.params.length > 3) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let indexSecondParameter = 1; // Case {{match @custom.example "123"}}
|
|
25
|
+
if (node.params.length === 3) {
|
|
26
|
+
indexSecondParameter = 2; // Case {{match @custom.example "!=" "123"}}
|
|
27
|
+
}
|
|
28
|
+
const setting = getCustomSettingName(node.params[0]) || getCustomSettingName(node.params[indexSecondParameter]);
|
|
29
|
+
const value = getCustomSettingValue(node.params[0]) || getCustomSettingValue(node.params[indexSecondParameter]);
|
|
22
30
|
|
|
23
31
|
if (!setting || !value || !this.isSelectCustomTheme(setting)) {
|
|
24
32
|
return;
|
|
@@ -50,6 +50,7 @@ const canaryPackageJSONValidationRules = _.extend({},
|
|
|
50
50
|
{missingCustomThemeSettingsSelectDefault: 'GS010-PJ-CUST-THEME-SETTINGS-SELECT-DEFAULT'},
|
|
51
51
|
{invalidCustomThemeSetingBooleanDefault: 'GS010-PJ-CUST-THEME-SETTINGS-BOOLEAN-DEFAULT'},
|
|
52
52
|
{invalidCustomThemeSetingColorDefault: 'GS010-PJ-CUST-THEME-SETTINGS-COLOR-DEFAULT'},
|
|
53
|
+
{invalidCustomThemeSetingImageDefault: 'GS010-PJ-CUST-THEME-SETTINGS-IMAGE-DEFAULT'},
|
|
53
54
|
canaryPackageJSONConditionalRules
|
|
54
55
|
);
|
|
55
56
|
|
|
@@ -173,6 +174,11 @@ _private.validatePackageJSONFields = function validatePackageJSONFields(packageJ
|
|
|
173
174
|
markFailed('invalidCustomThemeSetingColorDefault');
|
|
174
175
|
}
|
|
175
176
|
break;
|
|
177
|
+
case 'image':
|
|
178
|
+
if (entry.default) {
|
|
179
|
+
markFailed('invalidCustomThemeSetingImageDefault');
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
176
182
|
default:
|
|
177
183
|
//do nothing here
|
|
178
184
|
}
|
|
@@ -4,6 +4,12 @@ const {versions, normalizePath} = require('../utils');
|
|
|
4
4
|
const ASTLinter = require('../ast-linter');
|
|
5
5
|
|
|
6
6
|
function processFileFunction(files, failures, rules) {
|
|
7
|
+
// This rule is needed to find partials
|
|
8
|
+
// Partials are needed for a full parsing
|
|
9
|
+
if (!rules['mark-used-partials']) {
|
|
10
|
+
rules['mark-used-partials'] = require(`../ast-linter/rules/mark-used-partials`);
|
|
11
|
+
}
|
|
12
|
+
|
|
7
13
|
return function processFile(linter, themeFile) {
|
|
8
14
|
if (themeFile.parsed.error) {
|
|
9
15
|
// Ignore parsing errors, they are handled in 005
|
|
@@ -74,6 +74,12 @@ function applyRule(rule, theme) {
|
|
|
74
74
|
function parseWithAST({theme, log, file, rules, callback}){
|
|
75
75
|
const linter = new ASTLinter();
|
|
76
76
|
|
|
77
|
+
// This rule is needed to find partials
|
|
78
|
+
// Partials are needed for a full parsing
|
|
79
|
+
if (!rules['mark-used-partials']) {
|
|
80
|
+
rules['mark-used-partials'] = require(`../ast-linter/rules/mark-used-partials`);
|
|
81
|
+
}
|
|
82
|
+
|
|
77
83
|
function processFile(themeFile) {
|
|
78
84
|
if (themeFile.parsed.error) {
|
|
79
85
|
// Ignore parsing errors, they are handled in 005
|
package/lib/read-theme.js
CHANGED
|
@@ -106,7 +106,7 @@ const readFiles = function readFiles(theme, options = {}) {
|
|
|
106
106
|
const packageJsonMatch = themeFile.file.match(/^package\.json/);
|
|
107
107
|
if (packageJsonMatch) {
|
|
108
108
|
const packageJson = JSON.parse(themeFile.content);
|
|
109
|
-
if (packageJson.config.custom) {
|
|
109
|
+
if (packageJson.config && packageJson.config.custom) {
|
|
110
110
|
theme.customSettings = packageJson.config.custom;
|
|
111
111
|
}
|
|
112
112
|
}
|
package/lib/specs/canary.js
CHANGED
|
@@ -84,6 +84,12 @@ let rules = {
|
|
|
84
84
|
details: oneLineTrim`Please make sure the <code>"default"</code> property is either <code>null</code>, an empty string <code>''</code> or a valid 6-hexadecimal-digit color code like <code>#15171a</code>.<br>
|
|
85
85
|
Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
86
86
|
},
|
|
87
|
+
'GS010-PJ-CUST-THEME-SETTINGS-IMAGE-DEFAULT': {
|
|
88
|
+
level: 'error',
|
|
89
|
+
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.',
|
|
90
|
+
details: oneLineTrim`Make sure the <code>"default"</code> property is either <code>null</code>, an empty string <code>''</code> or isn't present.<br>
|
|
91
|
+
Check the <a href="${docsBaseUrl}packagejson/" target=_blank><code>package.json</code> documentation</a> for further information.`
|
|
92
|
+
},
|
|
87
93
|
'GS001-DEPR-LABS-MEMBERS': {
|
|
88
94
|
level: 'warning',
|
|
89
95
|
rule: 'The <code>{{@labs.members}}</code> helper should not be used.',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gscan",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.2",
|
|
4
4
|
"description": "Scans Ghost themes looking for errors, deprecations, features and compatibility",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ghost",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@sentry/node": "6.13.3",
|
|
44
|
-
"@tryghost/pretty-cli": "1.2.
|
|
45
|
-
"@tryghost/zip": "1.1.
|
|
44
|
+
"@tryghost/pretty-cli": "1.2.22",
|
|
45
|
+
"@tryghost/zip": "1.1.18",
|
|
46
46
|
"bluebird": "3.7.2",
|
|
47
47
|
"chalk": "4.1.2",
|
|
48
48
|
"common-tags": "1.8.0",
|