gscan 4.10.2 → 4.12.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.
@@ -1,6 +1,7 @@
1
1
  const _ = require('lodash');
2
2
  const spec = require('../specs');
3
3
  const versions = require('../utils').versions;
4
+ const {getPackageJSON} = require('../utils');
4
5
 
5
6
  const checkKoenigCssClasses = function checkKoenigCssClasses(theme, options) {
6
7
  const checkVersion = _.get(options, 'checkVersion', versions.default);
@@ -9,7 +10,30 @@ const checkKoenigCssClasses = function checkKoenigCssClasses(theme, options) {
9
10
  // CASE: 050-koenig-css-classes checks only needs `rules` that start with `GS050-`
10
11
  const ruleRegex = /GS050-.*/g;
11
12
 
13
+ // Following the introduction of card assets, we disable certain rules
14
+ // when it's enabled by the theme.
15
+ const packageJson = getPackageJSON(theme);
16
+ const cardAssetsEnabled = packageJson
17
+ && packageJson.config
18
+ && packageJson.config.card_assets === true;
19
+ const enabledCards = packageJson
20
+ && packageJson.config
21
+ && packageJson.config.card_assets
22
+ && Array.isArray(packageJson.config.card_assets.include)
23
+ && packageJson.config.card_assets.include;
24
+ const disabledCards = !enabledCards // include takes priority over exclude
25
+ && packageJson
26
+ && packageJson.config
27
+ && packageJson.config.card_assets
28
+ && Array.isArray(packageJson.config.card_assets.exclude)
29
+ && packageJson.config.card_assets.exclude;
30
+
12
31
  ruleSet = _.pickBy(ruleSet.rules, function (rule, ruleCode) {
32
+ if (rule.cardAsset && (cardAssetsEnabled
33
+ || (enabledCards && enabledCards.includes(rule.cardAsset))
34
+ || (disabledCards && !disabledCards.includes(rule.cardAsset)))) {
35
+ return; // skip rule
36
+ }
13
37
  if (ruleCode.match(ruleRegex)) {
14
38
  return rule;
15
39
  }
package/lib/specs/v2.js CHANGED
@@ -10,6 +10,15 @@ const previousKnownHelpers = previousSpec.knownHelpers;
10
10
  const previousTemplates = previousSpec.templates;
11
11
  const previousRules = previousSpec.rules;
12
12
 
13
+ function requiredClassRule(strings) {
14
+ return `The <code>.${strings[0]}</code> CSS class is required to appear styled in your theme`;
15
+ }
16
+
17
+ function requiredClassDetails(strings) {
18
+ return oneLineTrim`The <code>.${strings[0]}</code> CSS class is required otherwise wide images will appear unstyled.
19
+ Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/" target=_blank>here</a>.`;
20
+ }
21
+
13
22
  // assign new or overwrite existing knownHelpers, templates, or rules here:
14
23
  let knownHelpers = ['link', 'link_class', 'concat'];
15
24
  let templates = [];
@@ -446,138 +455,136 @@ let rules = {
446
455
  },
447
456
  'GS050-CSS-KGWW': {
448
457
  level: 'error',
449
- rule: 'The <code>.kg-width-wide</code> CSS class is required to appear styled in your theme',
450
- details: oneLineTrim`The <code>.kg-width-wide</code> CSS class is required otherwise wide images will appear unstyled.
451
- Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/#image-size-implementations" target=_blank>here</a>.`,
458
+ rule: requiredClassRule`kg-width-wide`,
459
+ details: requiredClassDetails`kg-width-wide`,
452
460
  regex: /\.kg-width-wide/g,
453
461
  className: '.kg-width-wide',
454
462
  css: true
455
463
  },
456
464
  'GS050-CSS-KGWF': {
457
465
  level: 'error',
458
- rule: 'The <code>.kg-width-full</code> CSS class is required to appear styled in your theme',
459
- details: oneLineTrim`The <code>.kg-width-full</code> CSS class is required otherwise full width images will appear unstyled.
460
- Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/#image-size-implementations" target=_blank>here</a>.`,
466
+ rule: requiredClassRule`kg-width-full`,
467
+ details: requiredClassDetails`kg-width-full`,
461
468
  regex: /\.kg-width-full/g,
462
469
  className: '.kg-width-full',
463
470
  css: true
464
471
  },
465
472
  'GS050-CSS-KGGC': {
466
473
  level: 'error',
467
- rule: 'The <code>.kg-gallery-container</code> CSS class is required to appear styled in your theme',
468
- details: oneLineTrim`The <code>.kg-gallery-container</code> CSS class is required otherwise galleries will appear unstyled.
469
- Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/#gallery-card" target=_blank>here</a>.`,
474
+ rule: requiredClassRule`kg-gallery-container`,
475
+ details: requiredClassDetails``,
470
476
  regex: /\.kg-gallery-container/g,
471
477
  className: '.kg-gallery-container',
472
- css: true
478
+ css: true,
479
+ cardAsset: 'gallery'
473
480
  },
474
481
  'GS050-CSS-KGGR': {
475
482
  level: 'error',
476
- rule: 'The <code>.kg-gallery-row</code> CSS class is required to appear styled in your theme',
477
- details: oneLineTrim`The <code>.kg-gallery-row</code> CSS class is required otherwise gallery rows will appear unstyled.
478
- Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/#gallery-card" target=_blank>here</a>.`,
483
+ rule: requiredClassRule`kg-gallery-row`,
484
+ details: requiredClassDetails`kg-gallery-row`,
479
485
  regex: /\.kg-gallery-row/g,
480
486
  className: '.kg-gallery-row',
481
- css: true
487
+ css: true,
488
+ cardAsset: 'gallery'
482
489
  },
483
490
  'GS050-CSS-KGGI': {
484
491
  level: 'error',
485
- rule: 'The <code>.kg-gallery-image</code> CSS class is required to appear styled in your theme',
486
- details: oneLineTrim`The <code>.kg-gallery-image</code> CSS class is required otherwise gallery images will appear unstyled.
487
- Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/#gallery-card" target=_blank>here</a>.`,
492
+ rule: requiredClassRule`kg-gallery-image`,
493
+ details: requiredClassDetails`kg-gallery-image`,
488
494
  regex: /\.kg-gallery-image/g,
489
495
  className: '.kg-gallery-image',
490
- css: true
496
+ css: true,
497
+ cardAsset: 'gallery'
491
498
  },
492
499
  'GS050-CSS-KGBM': {
493
500
  level: 'error',
494
- rule: 'The <code>.kg-bookmark-card</code> CSS class is required to appear styled in your theme',
495
- details: oneLineTrim`The <code>.kg-bookmark-card</code> CSS class is required otherwise the bookmark card will appear unstyled.
496
- Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/#bookmark-card" target=_blank>here</a>.`,
501
+ rule: requiredClassRule`kg-bookmark-card`,
502
+ details: requiredClassDetails`kg-bookmark-card`,
497
503
  regex: /\.kg-bookmark-card/g,
498
504
  className: '.kg-bookmark-card',
499
- css: true
505
+ css: true,
506
+ cardAsset: 'bookmark'
500
507
  },
501
508
  'GS050-CSS-KGBMCO': {
502
509
  level: 'error',
503
- rule: 'The <code>.kg-bookmark-container</code> CSS class is required to appear styled in your theme',
504
- details: oneLineTrim`The <code>.kg-bookmark-card</code> CSS class is required otherwise the bookmark card will appear unstyled.
505
- Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/#bookmark-card" target=_blank>here</a>.`,
510
+ rule: requiredClassRule`kg-bookmark-container`,
511
+ details: requiredClassDetails`kg-bookmark-container`,
506
512
  regex: /\.kg-bookmark-container/g,
507
513
  className: '.kg-bookmark-container',
508
- css: true
514
+ css: true,
515
+ cardAsset: 'bookmark'
509
516
  },
510
517
  'GS050-CSS-KGBMCON': {
511
518
  level: 'error',
512
- rule: 'The <code>.kg-bookmark-content</code> CSS class is required to appear styled in your theme',
513
- details: oneLineTrim`The <code>.kg-bookmark-content</code> CSS class is required otherwise the bookmark card main content will appear unstyled.
514
- Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/#bookmark-card" target=_blank>here</a>.`,
519
+ rule: requiredClassRule`kg-bookmark-content`,
520
+ details: requiredClassDetails`kg-bookmark-content`,
515
521
  regex: /\.kg-bookmark-content/g,
516
522
  className: '.kg-bookmark-content',
517
- css: true
523
+ css: true,
524
+ cardAsset: 'bookmark'
518
525
  },
519
526
  'GS050-CSS-KGBMTI': {
520
527
  level: 'error',
521
- rule: 'The <code>.kg-bookmark-title</code> CSS class is required to appear styled in your theme',
522
- details: oneLineTrim`The <code>.kg-bookmark-title</code> CSS class is required otherwise the bookmark card title will appear unstyled.
523
- Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/#bookmark-card" target=_blank>here</a>.`,
528
+ rule: requiredClassRule`kg-bookmark-title`,
529
+ details: requiredClassDetails`kg-bookmark-title`,
524
530
  regex: /\.kg-bookmark-title/g,
525
531
  className: '.kg-bookmark-title',
526
- css: true
532
+ css: true,
533
+ cardAsset: 'bookmark'
527
534
  },
528
535
  'GS050-CSS-KGBMDE': {
529
536
  level: 'error',
530
- rule: 'The <code>.kg-bookmark-description</code> CSS class is required to appear styled in your theme',
531
- details: oneLineTrim`The <code>.kg-bookmark-description</code> CSS class is required otherwise the bookmark card description will appear unstyled.
532
- Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/#bookmark-card" target=_blank>here</a>.`,
537
+ rule: requiredClassRule`kg-bookmark-description`,
538
+ details: requiredClassDetails`kg-bookmark-description`,
533
539
  regex: /\.kg-bookmark-description/g,
534
540
  className: '.kg-bookmark-description',
535
- css: true
541
+ css: true,
542
+ cardAsset: 'bookmark'
536
543
  },
537
544
  'GS050-CSS-KGBMME': {
538
545
  level: 'error',
539
- rule: 'The <code>.kg-bookmark-metadata</code> CSS class is required to appear styled in your theme',
540
- details: oneLineTrim`The <code>.kg-bookmark-metadata</code> CSS class is required otherwise the bookmark card meta details will appear unstyled.
541
- Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/#bookmark-card" target=_blank>here</a>.`,
546
+ rule: requiredClassRule`kg-bookmark-metadata`,
547
+ details: requiredClassDetails`kg-bookmark-metadata`,
542
548
  regex: /\.kg-bookmark-metadata/g,
543
549
  className: '.kg-bookmark-metadata',
544
- css: true
550
+ css: true,
551
+ cardAsset: 'bookmark'
545
552
  },
546
553
  'GS050-CSS-KGBMIC': {
547
554
  level: 'error',
548
- rule: 'The <code>.kg-bookmark-icon</code> CSS class is required to appear styled in your theme',
549
- details: oneLineTrim`The <code>.kg-bookmark-icon</code> CSS class is required otherwise the bookmark card author icon will appear unstyled.
550
- Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/#bookmark-card" target=_blank>here</a>.`,
555
+ rule: requiredClassRule`kg-bookmark-icon`,
556
+ details: requiredClassDetails`kg-bookmark-icon`,
551
557
  regex: /\.kg-bookmark-icon/g,
552
558
  className: '.kg-bookmark-icon',
553
- css: true
559
+ css: true,
560
+ cardAsset: 'bookmark'
554
561
  },
555
562
  'GS050-CSS-KGBMAU': {
556
563
  level: 'error',
557
- rule: 'The <code>.kg-bookmark-author</code> CSS class is required to appear styled in your theme',
558
- details: oneLineTrim`The <code>.kg-bookmark-author</code> CSS class is required otherwise the bookmark card author name will appear unstyled.
559
- Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/#bookmark-card" target=_blank>here</a>.`,
564
+ rule: requiredClassRule`kg-bookmark-author`,
565
+ details: requiredClassDetails`kg-bookmark-author`,
560
566
  regex: /\.kg-bookmark-author/g,
561
567
  className: '.kg-bookmark-author',
562
- css: true
568
+ css: true,
569
+ cardAsset: 'bookmark'
563
570
  },
564
571
  'GS050-CSS-KGBMPU': {
565
572
  level: 'error',
566
- rule: 'The <code>.kg-bookmark-publisher</code> CSS class is required to appear styled in your theme',
567
- details: oneLineTrim`The <code>.kg-bookmark-publisher</code> CSS class is required otherwise the bookmark card publisher name will appear unstyled.
568
- Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/#bookmark-card" target=_blank>here</a>.`,
573
+ rule: requiredClassRule`kg-bookmark-publisher`,
574
+ details: requiredClassDetails``,
569
575
  regex: /\.kg-bookmark-publisher/g,
570
576
  className: '.kg-bookmark-publisher',
571
- css: true
577
+ css: true,
578
+ cardAsset: 'bookmark'
572
579
  },
573
580
  'GS050-CSS-KGBMTH': {
574
581
  level: 'error',
575
- rule: 'The <code>.kg-bookmark-thumbnail</code> CSS class is required to appear styled in your theme',
576
- details: oneLineTrim`The <code>.kg-bookmark-thumbnail</code> CSS class is required otherwise the bookmark card thumbnail image will appear unstyled.
577
- Find out more about required theme changes for the Koenig editor <a href="${docsBaseUrl}editor/#bookmark-card" target=_blank>here</a>.`,
582
+ rule: requiredClassRule`kg-bookmark-thumbnail`,
583
+ details: requiredClassDetails``,
578
584
  regex: /\.kg-bookmark-thumbnail/g,
579
585
  className: '.kg-bookmark-thumbnail',
580
- css: true
586
+ css: true,
587
+ cardAsset: 'bookmark'
581
588
  },
582
589
  // Updated v1 rules
583
590
  'GS001-DEPR-AC': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gscan",
3
- "version": "4.10.2",
3
+ "version": "4.12.0",
4
4
  "description": "Scans Ghost themes looking for errors, deprecations, features and compatibility",
5
5
  "keywords": [
6
6
  "ghost",
@@ -41,16 +41,16 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@sentry/node": "6.15.0",
44
- "@tryghost/config": "0.2.0",
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.0",
47
+ "@tryghost/logging": "1.0.1",
48
48
  "@tryghost/pretty-cli": "1.2.22",
49
49
  "@tryghost/server": "0.1.0",
50
50
  "@tryghost/zip": "1.1.18",
51
51
  "bluebird": "3.7.2",
52
52
  "chalk": "4.1.2",
53
- "common-tags": "1.8.1",
53
+ "common-tags": "1.8.2",
54
54
  "express": "4.17.1",
55
55
  "express-hbs": "2.4.0",
56
56
  "fs-extra": "9.1.0",