@platformos/platformos-check-common 0.0.7 → 0.0.9
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/CHANGELOG.md +16 -0
- package/README.md +4 -4
- package/dist/AugmentedPlatformOSDocset.d.ts +11 -0
- package/dist/AugmentedPlatformOSDocset.js +81 -0
- package/dist/AugmentedPlatformOSDocset.js.map +1 -0
- package/dist/JSONValidator.js +1 -1
- package/dist/JSONValidator.js.map +1 -1
- package/dist/checks/deprecated-filter/index.js +4 -41
- package/dist/checks/deprecated-filter/index.js.map +1 -1
- package/dist/checks/deprecated-tag/index.js +21 -22
- package/dist/checks/deprecated-tag/index.js.map +1 -1
- package/dist/checks/duplicate-function-arguments/index.js +1 -1
- package/dist/checks/duplicate-function-arguments/index.js.map +1 -1
- package/dist/checks/duplicate-render-partial-arguments/index.js +1 -1
- package/dist/checks/duplicate-render-partial-arguments/index.js.map +1 -1
- package/dist/checks/graphql/index.js +1 -1
- package/dist/checks/graphql/index.js.map +1 -1
- package/dist/checks/graphql-variables/index.js +4 -0
- package/dist/checks/graphql-variables/index.js.map +1 -1
- package/dist/checks/img-width-and-height/index.js +1 -1
- package/dist/checks/img-width-and-height/index.js.map +1 -1
- package/dist/checks/index.d.ts +3 -3
- package/dist/checks/index.js +4 -79
- package/dist/checks/index.js.map +1 -1
- package/dist/checks/json-syntax-error/index.js +1 -1
- package/dist/checks/json-syntax-error/index.js.map +1 -1
- package/dist/checks/liquid-html-syntax-error/checks/InvalidLoopArguments.js +1 -1
- package/dist/checks/liquid-html-syntax-error/checks/InvalidLoopArguments.js.map +1 -1
- package/dist/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.d.ts +19 -0
- package/dist/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.js +79 -0
- package/dist/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.js.map +1 -0
- package/dist/checks/liquid-html-syntax-error/checks/UnknownTag.d.ts +3 -0
- package/dist/checks/liquid-html-syntax-error/checks/UnknownTag.js +32 -0
- package/dist/checks/liquid-html-syntax-error/checks/UnknownTag.js.map +1 -0
- package/dist/checks/liquid-html-syntax-error/index.js +23 -5
- package/dist/checks/liquid-html-syntax-error/index.js.map +1 -1
- package/dist/checks/matching-translations/index.d.ts +2 -2
- package/dist/checks/matching-translations/index.js +114 -90
- package/dist/checks/matching-translations/index.js.map +1 -1
- package/dist/checks/metadata-params/index.js +6 -3
- package/dist/checks/metadata-params/index.js.map +1 -1
- package/dist/checks/missing-asset/index.js +1 -1
- package/dist/checks/missing-asset/index.js.map +1 -1
- package/dist/checks/missing-partial/index.d.ts +6 -0
- package/dist/checks/missing-partial/index.js +70 -0
- package/dist/checks/missing-partial/index.js.map +1 -0
- package/dist/checks/orphaned-partial/index.js +4 -4
- package/dist/checks/orphaned-partial/index.js.map +1 -1
- package/dist/checks/parser-blocking-script/index.js +10 -36
- package/dist/checks/parser-blocking-script/index.js.map +1 -1
- package/dist/checks/parser-blocking-script/suggestions.d.ts +1 -2
- package/dist/checks/parser-blocking-script/suggestions.js +1 -11
- package/dist/checks/parser-blocking-script/suggestions.js.map +1 -1
- package/dist/checks/reserved-doc-param-names/index.js +6 -5
- package/dist/checks/reserved-doc-param-names/index.js.map +1 -1
- package/dist/checks/translation-key-exists/index.js +1 -1
- package/dist/checks/translation-key-exists/index.js.map +1 -1
- package/dist/checks/unclosed-html-element/index.js +5 -1
- package/dist/checks/unclosed-html-element/index.js.map +1 -1
- package/dist/checks/undefined-object/index.js +13 -31
- package/dist/checks/undefined-object/index.js.map +1 -1
- package/dist/checks/unique-doc-param-names/index.js +1 -1
- package/dist/checks/unique-doc-param-names/index.js.map +1 -1
- package/dist/checks/unknown-filter/index.js +3 -3
- package/dist/checks/unknown-filter/index.js.map +1 -1
- package/dist/checks/unknown-property/index.js +1 -1
- package/dist/checks/unknown-property/index.js.map +1 -1
- package/dist/checks/unrecognized-render-partial-arguments/index.js +2 -2
- package/dist/checks/unrecognized-render-partial-arguments/index.js.map +1 -1
- package/dist/checks/unused-assign/index.js +1 -1
- package/dist/checks/unused-assign/index.js.map +1 -1
- package/dist/checks/unused-doc-param/index.js +1 -1
- package/dist/checks/unused-doc-param/index.js.map +1 -1
- package/dist/checks/utils.js +1 -1
- package/dist/checks/utils.js.map +1 -1
- package/dist/checks/valid-content-for-arguments/index.js +1 -1
- package/dist/checks/valid-content-for-arguments/index.js.map +1 -1
- package/dist/checks/valid-doc-param-types/index.js +4 -4
- package/dist/checks/valid-doc-param-types/index.js.map +1 -1
- package/dist/checks/valid-html-translation/index.d.ts +2 -2
- package/dist/checks/valid-html-translation/index.js +4 -4
- package/dist/checks/valid-html-translation/index.js.map +1 -1
- package/dist/checks/valid-json/index.js +1 -1
- package/dist/checks/valid-json/index.js.map +1 -1
- package/dist/checks/valid-render-partial-argument-types/index.js +2 -2
- package/dist/checks/valid-render-partial-argument-types/index.js.map +1 -1
- package/dist/checks/variable-name/index.js +1 -1
- package/dist/checks/variable-name/index.js.map +1 -1
- package/dist/context-utils.d.ts +18 -7
- package/dist/context-utils.js +68 -109
- package/dist/context-utils.js.map +1 -1
- package/dist/disabled-checks/index.js +4 -2
- package/dist/disabled-checks/index.js.map +1 -1
- package/dist/doc-generator/DocBlockGenerator.d.ts +16 -0
- package/dist/doc-generator/DocBlockGenerator.js +464 -0
- package/dist/doc-generator/DocBlockGenerator.js.map +1 -0
- package/dist/doc-generator/index.d.ts +1 -0
- package/dist/doc-generator/index.js +6 -0
- package/dist/doc-generator/index.js.map +1 -0
- package/dist/find-root.d.ts +7 -10
- package/dist/find-root.js +10 -17
- package/dist/find-root.js.map +1 -1
- package/dist/fixes/autofix.d.ts +4 -4
- package/dist/fixes/autofix.js +2 -2
- package/dist/fixes/autofix.js.map +1 -1
- package/dist/fixes/correctors/index.js +4 -0
- package/dist/fixes/correctors/index.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +50 -17
- package/dist/index.js.map +1 -1
- package/dist/jsonc/parse.d.ts +1 -1
- package/dist/jsonc/parse.js +1 -1
- package/dist/liquid-doc/arguments.d.ts +7 -8
- package/dist/liquid-doc/arguments.js +28 -29
- package/dist/liquid-doc/arguments.js.map +1 -1
- package/dist/liquid-doc/liquidDoc.d.ts +1 -1
- package/dist/liquid-doc/liquidDoc.js.map +1 -1
- package/dist/liquid-doc/utils.d.ts +3 -3
- package/dist/liquid-doc/utils.js +14 -3
- package/dist/liquid-doc/utils.js.map +1 -1
- package/dist/path.d.ts +1 -0
- package/dist/path.js +16 -1
- package/dist/path.js.map +1 -1
- package/{src/test/MockTheme.ts → dist/test/MockApp.d.ts} +2 -3
- package/dist/test/MockApp.js +16 -0
- package/dist/test/MockApp.js.map +1 -0
- package/dist/test/MockFileSystem.d.ts +3 -3
- package/dist/test/MockFileSystem.js +6 -6
- package/dist/test/MockFileSystem.js.map +1 -1
- package/dist/test/index.d.ts +1 -1
- package/dist/test/index.js +1 -1
- package/dist/test/index.js.map +1 -1
- package/dist/test/test-helper.d.ts +10 -9
- package/dist/test/test-helper.js +15 -106
- package/dist/test/test-helper.js.map +1 -1
- package/dist/to-schema.d.ts +1 -1
- package/dist/to-source-code.d.ts +3 -2
- package/dist/to-source-code.js +20 -0
- package/dist/to-source-code.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/platformos-liquid-docs.d.ts +128 -0
- package/dist/types/platformos-liquid-docs.js +3 -0
- package/dist/types/platformos-liquid-docs.js.map +1 -0
- package/dist/types/schemas/index.d.ts +0 -2
- package/dist/types/schemas/index.js.map +1 -1
- package/dist/types.d.ts +26 -67
- package/dist/types.js +3 -5
- package/dist/types.js.map +1 -1
- package/dist/utils/block.js.map +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/yaml/parse.d.ts +5 -0
- package/dist/yaml/parse.js +94 -0
- package/dist/yaml/parse.js.map +1 -0
- package/package.json +4 -3
- package/src/{AugmentedThemeDocset.spec.ts → AugmentedPlatformOSDocset.spec.ts} +47 -34
- package/src/AugmentedPlatformOSDocset.ts +89 -0
- package/src/JSONValidator.ts +1 -1
- package/src/checks/deprecated-filter/index.spec.ts +76 -248
- package/src/checks/deprecated-filter/index.ts +5 -53
- package/src/checks/deprecated-tag/index.spec.ts +85 -34
- package/src/checks/deprecated-tag/index.ts +27 -22
- package/src/checks/duplicate-function-arguments/index.ts +1 -1
- package/src/checks/duplicate-render-partial-arguments/index.spec.ts +12 -12
- package/src/checks/duplicate-render-partial-arguments/index.ts +1 -1
- package/src/checks/graphql/index.ts +1 -1
- package/src/checks/graphql-variables/index.spec.ts +95 -0
- package/src/checks/graphql-variables/index.ts +4 -0
- package/src/checks/img-width-and-height/index.ts +2 -2
- package/src/checks/index.ts +11 -80
- package/src/checks/invalid-hash-assign-target/index.spec.ts +27 -27
- package/src/checks/json-syntax-error/index.ts +2 -2
- package/src/checks/liquid-html-syntax-error/checks/InvalidBooleanExpression.spec.ts +0 -11
- package/src/checks/liquid-html-syntax-error/checks/InvalidLoopArguments.spec.ts +1 -2
- package/src/checks/liquid-html-syntax-error/checks/InvalidLoopArguments.ts +2 -2
- package/src/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.spec.ts +259 -0
- package/src/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.ts +89 -0
- package/src/checks/liquid-html-syntax-error/checks/UnknownTag.spec.ts +293 -0
- package/src/checks/liquid-html-syntax-error/checks/UnknownTag.ts +43 -0
- package/src/checks/liquid-html-syntax-error/index.spec.ts +1 -6
- package/src/checks/liquid-html-syntax-error/index.ts +26 -5
- package/src/checks/matching-translations/index.spec.ts +187 -354
- package/src/checks/matching-translations/index.ts +117 -107
- package/src/checks/metadata-params/index.ts +6 -8
- package/src/checks/missing-asset/index.ts +1 -1
- package/src/checks/{missing-template → missing-partial}/index.spec.ts +6 -6
- package/src/checks/{missing-template → missing-partial}/index.ts +12 -26
- package/src/checks/orphaned-partial/index.ts +3 -3
- package/src/checks/parser-blocking-script/index.spec.ts +0 -118
- package/src/checks/parser-blocking-script/index.ts +3 -33
- package/src/checks/parser-blocking-script/suggestions.ts +1 -28
- package/src/checks/translation-key-exists/index.ts +1 -1
- package/src/checks/unclosed-html-element/index.ts +5 -1
- package/src/checks/undefined-object/index.spec.ts +32 -111
- package/src/checks/undefined-object/index.ts +15 -34
- package/src/checks/unique-doc-param-names/index.ts +1 -1
- package/src/checks/unknown-filter/index.spec.ts +2 -2
- package/src/checks/unknown-filter/index.ts +3 -3
- package/src/checks/unknown-property/index.ts +1 -1
- package/src/checks/unrecognized-render-partial-arguments/index.spec.ts +5 -5
- package/src/checks/unrecognized-render-partial-arguments/index.ts +2 -5
- package/src/checks/unused-assign/index.spec.ts +0 -30
- package/src/checks/unused-assign/index.ts +2 -2
- package/src/checks/unused-doc-param/index.ts +1 -1
- package/src/checks/utils.ts +1 -1
- package/src/checks/valid-doc-param-types/index.ts +4 -4
- package/src/checks/valid-html-translation/index.spec.ts +42 -32
- package/src/checks/valid-html-translation/index.ts +7 -7
- package/src/checks/valid-json/index.ts +2 -2
- package/src/checks/valid-render-partial-argument-types/index.spec.ts +13 -13
- package/src/checks/valid-render-partial-argument-types/index.ts +2 -5
- package/src/checks/variable-name/index.ts +1 -1
- package/src/context-utils.spec.ts +49 -77
- package/src/context-utils.ts +81 -129
- package/src/disabled-checks/index.spec.ts +26 -26
- package/src/disabled-checks/index.ts +2 -2
- package/src/disabled-checks/test-checks.ts +4 -4
- package/src/find-root.ts +12 -22
- package/src/fixes/autofix.spec.ts +2 -2
- package/src/fixes/autofix.ts +4 -4
- package/src/fixes/correctors/index.ts +4 -0
- package/src/ignore.spec.ts +4 -5
- package/src/index.ts +51 -21
- package/src/jsonc/parse.ts +1 -1
- package/src/liquid-doc/arguments.spec.ts +19 -45
- package/src/liquid-doc/arguments.ts +35 -42
- package/src/liquid-doc/liquidDoc.spec.ts +1 -1
- package/src/liquid-doc/liquidDoc.ts +1 -2
- package/src/liquid-doc/utils.ts +17 -8
- package/src/path.ts +16 -0
- package/src/test/MockApp.ts +17 -0
- package/src/test/MockFileSystem.spec.ts +10 -11
- package/src/test/MockFileSystem.ts +6 -6
- package/src/test/contain-offense.spec.ts +11 -3
- package/src/test/index.ts +1 -1
- package/src/test/test-helper.ts +43 -145
- package/src/to-source-code.ts +20 -1
- package/src/types/{theme-liquid-docs.ts → platformos-liquid-docs.ts} +8 -13
- package/src/types.ts +29 -92
- package/src/utils/index.ts +0 -1
- package/src/visitor.spec.ts +2 -2
- package/src/yaml/parse.ts +111 -0
- package/src/AugmentedThemeDocset.ts +0 -137
- package/src/checks/app-block-missing-schema/index.spec.ts +0 -121
- package/src/checks/app-block-missing-schema/index.ts +0 -46
- package/src/checks/app-block-valid-tags/index.spec.ts +0 -96
- package/src/checks/app-block-valid-tags/index.ts +0 -54
- package/src/checks/asset-preload/index.spec.ts +0 -78
- package/src/checks/asset-preload/index.ts +0 -65
- package/src/checks/asset-size-app-block-css/index.spec.ts +0 -88
- package/src/checks/asset-size-app-block-css/index.ts +0 -78
- package/src/checks/asset-size-app-block-javascript/index.spec.ts +0 -66
- package/src/checks/asset-size-app-block-javascript/index.ts +0 -78
- package/src/checks/asset-size-css/index.spec.ts +0 -166
- package/src/checks/asset-size-css/index.ts +0 -160
- package/src/checks/asset-size-javascript/index.spec.ts +0 -184
- package/src/checks/asset-size-javascript/index.ts +0 -144
- package/src/checks/block-id-usage/index.spec.ts +0 -76
- package/src/checks/block-id-usage/index.ts +0 -72
- package/src/checks/cdn-preconnect/index.spec.ts +0 -40
- package/src/checks/cdn-preconnect/index.ts +0 -43
- package/src/checks/content-for-header-modification/index.spec.ts +0 -65
- package/src/checks/content-for-header-modification/index.ts +0 -72
- package/src/checks/deprecate-bgsizes/index.spec.ts +0 -41
- package/src/checks/deprecate-bgsizes/index.ts +0 -49
- package/src/checks/deprecate-lazysizes/index.spec.ts +0 -26
- package/src/checks/deprecate-lazysizes/index.ts +0 -58
- package/src/checks/deprecated-filter/fixes.ts +0 -264
- package/src/checks/deprecated-fonts-on-sections-and-blocks/deprecated-fonts-data.ts +0 -1343
- package/src/checks/deprecated-fonts-on-sections-and-blocks/index.spec.ts +0 -613
- package/src/checks/deprecated-fonts-on-sections-and-blocks/index.ts +0 -284
- package/src/checks/deprecated-fonts-on-settings-schema/index.spec.ts +0 -102
- package/src/checks/deprecated-fonts-on-settings-schema/index.ts +0 -66
- package/src/checks/duplicate-content-for-arguments/index.spec.ts +0 -98
- package/src/checks/duplicate-content-for-arguments/index.ts +0 -43
- package/src/checks/empty-block-content/index.spec.ts +0 -117
- package/src/checks/empty-block-content/index.ts +0 -60
- package/src/checks/hardcoded-routes/index.spec.ts +0 -58
- package/src/checks/hardcoded-routes/index.ts +0 -100
- package/src/checks/json-missing-block/index.spec.ts +0 -435
- package/src/checks/json-missing-block/index.ts +0 -56
- package/src/checks/json-missing-block/missing-block-utils.ts +0 -147
- package/src/checks/liquid-free-settings/index.spec.ts +0 -180
- package/src/checks/liquid-free-settings/index.ts +0 -79
- package/src/checks/missing-content-for-arguments/index.spec.ts +0 -144
- package/src/checks/missing-content-for-arguments/index.ts +0 -46
- package/src/checks/pagination-size/index.spec.ts +0 -158
- package/src/checks/pagination-size/index.ts +0 -104
- package/src/checks/remote-asset/index.spec.ts +0 -280
- package/src/checks/remote-asset/index.ts +0 -238
- package/src/checks/reserved-doc-param-names/index.spec.ts +0 -62
- package/src/checks/reserved-doc-param-names/index.ts +0 -57
- package/src/checks/schema-presets-block-order/index.spec.ts +0 -344
- package/src/checks/schema-presets-block-order/index.ts +0 -154
- package/src/checks/schema-presets-static-blocks/index.spec.ts +0 -145
- package/src/checks/schema-presets-static-blocks/index.ts +0 -126
- package/src/checks/static-stylesheet-and-javascript-tags/index.spec.ts +0 -257
- package/src/checks/static-stylesheet-and-javascript-tags/index.ts +0 -48
- package/src/checks/unique-settings-id/index.spec.ts +0 -24
- package/src/checks/unique-settings-id/index.ts +0 -84
- package/src/checks/unique-settings-id/test-data.ts +0 -1191
- package/src/checks/unique-static-block-id/index.spec.ts +0 -55
- package/src/checks/unique-static-block-id/index.ts +0 -60
- package/src/checks/unrecognized-content-for-arguments/index.spec.ts +0 -145
- package/src/checks/unrecognized-content-for-arguments/index.ts +0 -55
- package/src/checks/valid-block-target/index.spec.ts +0 -1396
- package/src/checks/valid-block-target/index.ts +0 -142
- package/src/checks/valid-content-for-argument-types/index.spec.ts +0 -382
- package/src/checks/valid-content-for-argument-types/index.ts +0 -42
- package/src/checks/valid-content-for-arguments/index.spec.ts +0 -107
- package/src/checks/valid-content-for-arguments/index.ts +0 -98
- package/src/checks/valid-local-blocks/index.spec.ts +0 -286
- package/src/checks/valid-local-blocks/index.ts +0 -100
- package/src/checks/valid-local-blocks/valid-block-utils.ts +0 -97
- package/src/checks/valid-schema/index.spec.ts +0 -174
- package/src/checks/valid-schema/index.ts +0 -41
- package/src/checks/valid-schema-name/index.spec.ts +0 -112
- package/src/checks/valid-schema-name/index.ts +0 -75
- package/src/checks/valid-settings-key/index.spec.ts +0 -321
- package/src/checks/valid-settings-key/index.ts +0 -144
- package/src/checks/valid-static-block-type/index.spec.ts +0 -38
- package/src/checks/valid-static-block-type/index.ts +0 -58
- package/src/checks/valid-visible-if/index.spec.ts +0 -619
- package/src/checks/valid-visible-if/index.ts +0 -184
- package/src/checks/valid-visible-if/visible-if-utils.ts +0 -158
- package/src/tags/content-for.ts +0 -25
- package/src/to-schema.ts +0 -231
- package/src/types/schemas/index.ts +0 -5
- package/src/types/schemas/preset.ts +0 -52
- package/src/types/schemas/section.ts +0 -86
- package/src/types/schemas/setting.ts +0 -320
- package/src/types/schemas/template.ts +0 -34
- package/src/types/schemas/theme-block.ts +0 -34
- package/src/types/theme-schemas.ts +0 -80
- package/src/utils/block.ts +0 -300
- package/src/utils/markup.ts +0 -10
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { LiquidFilter } from '@platformos/liquid-html-parser';
|
|
2
|
-
import {
|
|
3
|
-
Severity,
|
|
4
|
-
SourceCodeType,
|
|
5
|
-
LiquidCheckDefinition,
|
|
6
|
-
LiquidHtmlSuggestion,
|
|
7
|
-
FilterEntry,
|
|
8
|
-
Fixer,
|
|
9
|
-
} from '../../types';
|
|
10
|
-
import { fixHexToRgba, suggestImageUrlFix, suggestImgTagFix, suggestImgUrlFix } from './fixes';
|
|
2
|
+
import { Severity, SourceCodeType, LiquidCheckDefinition, FilterEntry } from '../../types';
|
|
11
3
|
|
|
12
4
|
export const DeprecatedFilter: LiquidCheckDefinition = {
|
|
13
5
|
meta: {
|
|
@@ -15,8 +7,8 @@ export const DeprecatedFilter: LiquidCheckDefinition = {
|
|
|
15
7
|
aliases: ['DeprecatedFilters'],
|
|
16
8
|
name: 'Deprecated Filter',
|
|
17
9
|
docs: {
|
|
18
|
-
description: 'Discourages using deprecated filters
|
|
19
|
-
url: 'https://
|
|
10
|
+
description: 'Discourages using deprecated filters.',
|
|
11
|
+
url: 'https://documentation.platformos.com/developer-guide/platformos-check/checks/deprecated-filter',
|
|
20
12
|
recommended: true,
|
|
21
13
|
},
|
|
22
14
|
type: SourceCodeType.LiquidHtml,
|
|
@@ -26,13 +18,13 @@ export const DeprecatedFilter: LiquidCheckDefinition = {
|
|
|
26
18
|
},
|
|
27
19
|
|
|
28
20
|
create(context) {
|
|
29
|
-
if (!context.
|
|
21
|
+
if (!context.platformosDocset) {
|
|
30
22
|
return {};
|
|
31
23
|
}
|
|
32
24
|
|
|
33
25
|
return {
|
|
34
26
|
LiquidFilter: async (node: LiquidFilter) => {
|
|
35
|
-
const filters = await context.
|
|
27
|
+
const filters = await context.platformosDocset!.filters();
|
|
36
28
|
|
|
37
29
|
const deprecatedFilter = filters.find((f) => {
|
|
38
30
|
return f.deprecated && f.name === node.name;
|
|
@@ -46,13 +38,9 @@ export const DeprecatedFilter: LiquidCheckDefinition = {
|
|
|
46
38
|
const recommendedFilter = filters.find((f) => f.name === recommendedFilterName);
|
|
47
39
|
|
|
48
40
|
const message = deprecatedFilterMessage(deprecatedFilter, recommendedFilter);
|
|
49
|
-
const suggest = deprecatedFilterSuggestion(node);
|
|
50
|
-
const fix = deprecatedFilterFix(node);
|
|
51
41
|
|
|
52
42
|
context.report({
|
|
53
43
|
message,
|
|
54
|
-
suggest,
|
|
55
|
-
fix,
|
|
56
44
|
startIndex: node.position.start + 1,
|
|
57
45
|
endIndex: node.position.end,
|
|
58
46
|
});
|
|
@@ -61,42 +49,6 @@ export const DeprecatedFilter: LiquidCheckDefinition = {
|
|
|
61
49
|
},
|
|
62
50
|
};
|
|
63
51
|
|
|
64
|
-
function deprecatedFilterSuggestion(node: LiquidFilter): LiquidHtmlSuggestion[] | undefined {
|
|
65
|
-
const filter = node.name;
|
|
66
|
-
|
|
67
|
-
switch (filter) {
|
|
68
|
-
case 'img_tag':
|
|
69
|
-
return suggestImgTagFix(node);
|
|
70
|
-
case 'img_url':
|
|
71
|
-
return suggestImgUrlFix(node);
|
|
72
|
-
case 'article_img_url':
|
|
73
|
-
case 'collection_img_url':
|
|
74
|
-
case 'product_img_url':
|
|
75
|
-
/**
|
|
76
|
-
* These filters rely on the usage of the `image_url`
|
|
77
|
-
* filter as the fix.
|
|
78
|
-
*/
|
|
79
|
-
return suggestImageUrlFix(filter, node);
|
|
80
|
-
case 'currency_selector':
|
|
81
|
-
/**
|
|
82
|
-
* Cannot be fixed.
|
|
83
|
-
*
|
|
84
|
-
* Deprecated without a direct replacement because the
|
|
85
|
-
* currency form has also been deprecated. The currency
|
|
86
|
-
* form was replaced by the localization form.
|
|
87
|
-
*/
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function deprecatedFilterFix(node: LiquidFilter): Fixer<SourceCodeType.LiquidHtml> | undefined {
|
|
93
|
-
const filter = node.name;
|
|
94
|
-
|
|
95
|
-
if (filter === 'hex_to_rgba') {
|
|
96
|
-
return fixHexToRgba(node);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
52
|
function deprecatedFilterMessage(deprecated: FilterEntry, recommended?: FilterEntry) {
|
|
101
53
|
if (recommended) {
|
|
102
54
|
return `Deprecated filter '${deprecated.name}', consider using '${recommended.name}'.`;
|
|
@@ -2,66 +2,117 @@ import { expect, describe, it } from 'vitest';
|
|
|
2
2
|
import { highlightedOffenses, runLiquidCheck } from '../../test';
|
|
3
3
|
import { DeprecatedTag } from './index';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
const mockDependencies = {
|
|
6
|
+
platformosDocset: {
|
|
7
|
+
async graphQL() {
|
|
8
|
+
return null;
|
|
9
|
+
},
|
|
10
|
+
async filters() {
|
|
11
|
+
return [];
|
|
12
|
+
},
|
|
13
|
+
async objects() {
|
|
14
|
+
return [];
|
|
15
|
+
},
|
|
16
|
+
async liquidDrops() {
|
|
17
|
+
return [];
|
|
18
|
+
},
|
|
19
|
+
async tags() {
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
name: 'include',
|
|
23
|
+
deprecated: true,
|
|
24
|
+
deprecation_reason: "Use the 'render' tag instead.",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'deprecated_no_reason',
|
|
28
|
+
deprecated: true,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'render',
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
describe('Module: DeprecatedTag', () => {
|
|
39
|
+
it('should report an offense when a deprecated tag is used', async () => {
|
|
40
|
+
const sourceCode = `{% include 'templates/foo.liquid' %}`;
|
|
41
|
+
|
|
42
|
+
const offenses = await runLiquidCheck(
|
|
43
|
+
DeprecatedTag,
|
|
44
|
+
sourceCode,
|
|
45
|
+
'file.liquid',
|
|
46
|
+
mockDependencies,
|
|
47
|
+
);
|
|
11
48
|
|
|
12
49
|
expect(offenses).toHaveLength(1);
|
|
13
|
-
expect(offenses[0].message).toEqual(`Use the 'render' tag instead
|
|
50
|
+
expect(offenses[0].message).toEqual(`Deprecated tag 'include': Use the 'render' tag instead.`);
|
|
14
51
|
|
|
15
52
|
const highlights = highlightedOffenses({ 'file.liquid': sourceCode }, offenses);
|
|
16
53
|
expect(highlights).toEqual(['include']);
|
|
17
54
|
});
|
|
18
55
|
|
|
19
|
-
it('should not report an offense when
|
|
20
|
-
const sourceCode = `
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
56
|
+
it('should not report an offense when a non-deprecated tag is used', async () => {
|
|
57
|
+
const sourceCode = `{% render 'templates/foo.liquid' %}`;
|
|
58
|
+
|
|
59
|
+
const offenses = await runLiquidCheck(
|
|
60
|
+
DeprecatedTag,
|
|
61
|
+
sourceCode,
|
|
62
|
+
'file.liquid',
|
|
63
|
+
mockDependencies,
|
|
64
|
+
);
|
|
24
65
|
|
|
25
66
|
expect(offenses).toHaveLength(0);
|
|
67
|
+
});
|
|
26
68
|
|
|
27
|
-
|
|
28
|
-
|
|
69
|
+
it('should report a generic message when no deprecation_reason is provided', async () => {
|
|
70
|
+
const sourceCode = `{% deprecated_no_reason %}`;
|
|
71
|
+
|
|
72
|
+
const offenses = await runLiquidCheck(
|
|
73
|
+
DeprecatedTag,
|
|
74
|
+
sourceCode,
|
|
75
|
+
'file.liquid',
|
|
76
|
+
mockDependencies,
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
expect(offenses).toHaveLength(1);
|
|
80
|
+
expect(offenses[0].message).toEqual(`Deprecated tag 'deprecated_no_reason'.`);
|
|
29
81
|
});
|
|
30
82
|
|
|
31
|
-
it('should
|
|
83
|
+
it('should report multiple offenses when multiple deprecated tags are used', async () => {
|
|
32
84
|
const sourceCode = `
|
|
33
85
|
{% include 'foo.liquid' %}
|
|
34
86
|
{% assign greeting = "hello world" %}
|
|
35
87
|
{% include 'greeting.liquid' %}
|
|
36
88
|
`;
|
|
37
|
-
const offenses = await runLiquidCheck(DeprecatedTag, sourceCode);
|
|
38
89
|
|
|
39
|
-
|
|
40
|
-
|
|
90
|
+
const offenses = await runLiquidCheck(
|
|
91
|
+
DeprecatedTag,
|
|
92
|
+
sourceCode,
|
|
93
|
+
'file.liquid',
|
|
94
|
+
mockDependencies,
|
|
95
|
+
);
|
|
41
96
|
|
|
42
|
-
expect(offenses
|
|
43
|
-
expect(offenses[
|
|
97
|
+
expect(offenses).toHaveLength(2);
|
|
98
|
+
expect(offenses[0].message).toEqual(`Deprecated tag 'include': Use the 'render' tag instead.`);
|
|
99
|
+
expect(offenses[1].message).toEqual(`Deprecated tag 'include': Use the 'render' tag instead.`);
|
|
44
100
|
|
|
45
101
|
const highlights = highlightedOffenses({ 'file.liquid': sourceCode }, offenses);
|
|
46
|
-
expect(highlights).
|
|
47
|
-
expect(highlights[0]).toBe('include');
|
|
48
|
-
expect(highlights[1]).toBe('include');
|
|
102
|
+
expect(highlights).toEqual(['include', 'include']);
|
|
49
103
|
});
|
|
50
104
|
|
|
51
|
-
it('should
|
|
52
|
-
const sourceCode =
|
|
53
|
-
const offenses = await runLiquidCheck(DeprecatedTag, sourceCode);
|
|
105
|
+
it('should highlight only the tag name', async () => {
|
|
106
|
+
const sourceCode = `{% include 'foo.liquid' %}`;
|
|
54
107
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
108
|
+
const offenses = await runLiquidCheck(
|
|
109
|
+
DeprecatedTag,
|
|
110
|
+
sourceCode,
|
|
111
|
+
'file.liquid',
|
|
112
|
+
mockDependencies,
|
|
113
|
+
);
|
|
61
114
|
|
|
62
115
|
expect(offenses).toHaveLength(1);
|
|
63
|
-
expect(offenses[0].message).toEqual(`Use the 'render' tag instead of 'include'`);
|
|
64
|
-
|
|
65
116
|
const highlights = highlightedOffenses({ 'file.liquid': sourceCode }, offenses);
|
|
66
117
|
expect(highlights).toEqual(['include']);
|
|
67
118
|
});
|
|
@@ -7,7 +7,7 @@ export const DeprecatedTag: LiquidCheckDefinition = {
|
|
|
7
7
|
name: 'Deprecated Tag',
|
|
8
8
|
docs: {
|
|
9
9
|
description: 'This check is aimed at eliminating the use of deprecated tags.',
|
|
10
|
-
url: 'https://
|
|
10
|
+
url: 'https://documentation.platformos.com/developer-guide/platformos-check/checks/deprecated-tag',
|
|
11
11
|
recommended: true,
|
|
12
12
|
},
|
|
13
13
|
type: SourceCodeType.LiquidHtml,
|
|
@@ -17,29 +17,34 @@ export const DeprecatedTag: LiquidCheckDefinition = {
|
|
|
17
17
|
},
|
|
18
18
|
|
|
19
19
|
create(context) {
|
|
20
|
+
if (!context.platformosDocset) {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
return {
|
|
21
25
|
async LiquidTag(node) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
26
|
+
const tags = await context.platformosDocset!.tags();
|
|
27
|
+
|
|
28
|
+
const deprecatedTag = tags.find((t) => t.deprecated && t.name === node.name);
|
|
29
|
+
|
|
30
|
+
if (!deprecatedTag) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const source = node.source.substring(node.position.start);
|
|
35
|
+
const tagNameIndex = source.indexOf(node.name);
|
|
36
|
+
const startIndex = node.position.start + tagNameIndex;
|
|
37
|
+
const endIndex = startIndex + node.name.length;
|
|
38
|
+
|
|
39
|
+
const message = deprecatedTag.deprecation_reason
|
|
40
|
+
? `Deprecated tag '${node.name}': ${deprecatedTag.deprecation_reason}`
|
|
41
|
+
: `Deprecated tag '${node.name}'.`;
|
|
42
|
+
|
|
43
|
+
context.report({
|
|
44
|
+
message,
|
|
45
|
+
startIndex,
|
|
46
|
+
endIndex,
|
|
47
|
+
});
|
|
43
48
|
},
|
|
44
49
|
};
|
|
45
50
|
},
|
|
@@ -11,7 +11,7 @@ export const DuplicateFunctionArguments: LiquidCheckDefinition = {
|
|
|
11
11
|
description:
|
|
12
12
|
'This check ensures that no duplicate argument names are provided when invoking partial as a function.',
|
|
13
13
|
recommended: true,
|
|
14
|
-
url: 'https://
|
|
14
|
+
url: 'https://documentation.platformos.com/developer-guide/platformos-check/checks/duplicate-function-arguments',
|
|
15
15
|
},
|
|
16
16
|
type: SourceCodeType.LiquidHtml,
|
|
17
17
|
severity: Severity.WARNING,
|
|
@@ -10,7 +10,7 @@ describe('Module: DuplicateRenderPartialArguments', () => {
|
|
|
10
10
|
describe('detection', () => {
|
|
11
11
|
it('should report duplicate arguments in render tags', async () => {
|
|
12
12
|
const sourceCode = `
|
|
13
|
-
{% render '
|
|
13
|
+
{% render 'partial', param1: 'value1', param2: 'value2', param1: 'value3' %}
|
|
14
14
|
`;
|
|
15
15
|
|
|
16
16
|
const offenses = await runCheck(sourceCode);
|
|
@@ -24,7 +24,7 @@ describe('Module: DuplicateRenderPartialArguments', () => {
|
|
|
24
24
|
|
|
25
25
|
it('should report multiple duplicate arguments in render tags', async () => {
|
|
26
26
|
const sourceCode = `
|
|
27
|
-
{% render '
|
|
27
|
+
{% render 'partial', param1: 'value1', param2: 'value2', param1: 'value3', param2: 'value4', param1: 'value5' %}
|
|
28
28
|
`;
|
|
29
29
|
|
|
30
30
|
const offenses = await runCheck(sourceCode);
|
|
@@ -40,7 +40,7 @@ describe('Module: DuplicateRenderPartialArguments', () => {
|
|
|
40
40
|
|
|
41
41
|
it('should not report when render tag is using `with/for` alias syntax', async () => {
|
|
42
42
|
const sourceCode = `
|
|
43
|
-
{% render '
|
|
43
|
+
{% render 'partial' with 'string' as param1, param1: 'value1' %}
|
|
44
44
|
`;
|
|
45
45
|
|
|
46
46
|
const offenses = await runCheck(sourceCode);
|
|
@@ -52,7 +52,7 @@ describe('Module: DuplicateRenderPartialArguments', () => {
|
|
|
52
52
|
|
|
53
53
|
describe('suggestions', () => {
|
|
54
54
|
it('should correctly suggest fixing all duplicate arguments except for the first', async () => {
|
|
55
|
-
const sourceCode = `{% render '
|
|
55
|
+
const sourceCode = `{% render 'partial', param1: 'value1', param2: 'value2', param1: 'value3', param1: 'value4' %}`;
|
|
56
56
|
const offenses = await runCheck(sourceCode);
|
|
57
57
|
|
|
58
58
|
expect(offenses).toHaveLength(2);
|
|
@@ -60,18 +60,18 @@ describe('Module: DuplicateRenderPartialArguments', () => {
|
|
|
60
60
|
expect(offenses[1].start.index).toBe(sourceCode.indexOf("param1: 'value4'"));
|
|
61
61
|
const suggestionResult = applySuggestions(sourceCode, offenses[0]);
|
|
62
62
|
expect(suggestionResult).toEqual([
|
|
63
|
-
`{% render '
|
|
63
|
+
`{% render 'partial', param1: 'value1', param2: 'value2', param1: 'value4' %}`,
|
|
64
64
|
]);
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
it('should suggest removing duplicates when with / for alias is used', async () => {
|
|
68
|
-
const sourceCode = `{% render '
|
|
68
|
+
const sourceCode = `{% render 'partial' with 'string' as param2, param1: 'value1', param2: 'value2' %}`;
|
|
69
69
|
const offenses = await runCheck(sourceCode);
|
|
70
70
|
|
|
71
71
|
expect(offenses).toHaveLength(1);
|
|
72
72
|
const suggestionResult = applySuggestions(sourceCode, offenses[0]);
|
|
73
73
|
expect(suggestionResult).toEqual([
|
|
74
|
-
`{% render '
|
|
74
|
+
`{% render 'partial' with 'string' as param2, param1: 'value1' %}`,
|
|
75
75
|
]);
|
|
76
76
|
});
|
|
77
77
|
});
|
|
@@ -79,7 +79,7 @@ describe('Module: DuplicateRenderPartialArguments', () => {
|
|
|
79
79
|
describe('edge cases', () => {
|
|
80
80
|
it('should not report when there are no duplicate arguments', async () => {
|
|
81
81
|
const sourceCode = `
|
|
82
|
-
{% render '
|
|
82
|
+
{% render 'partial', param1: 'value1', param2: 'value2', param3: 'value3' %}
|
|
83
83
|
`;
|
|
84
84
|
|
|
85
85
|
const offenses = await runCheck(sourceCode);
|
|
@@ -99,8 +99,8 @@ describe('Module: DuplicateRenderPartialArguments', () => {
|
|
|
99
99
|
|
|
100
100
|
it('should handle remove duplicate param when there are multiple render tags', async () => {
|
|
101
101
|
const sourceCode = `
|
|
102
|
-
{% render '
|
|
103
|
-
{% render '
|
|
102
|
+
{% render 'partial', param1: 'value1', param2: 'value2', param3: 'value3' %}
|
|
103
|
+
{% render 'partial', param1: 'value4', param2: 'value5', param1: 'value6' %}
|
|
104
104
|
`;
|
|
105
105
|
|
|
106
106
|
const offenses = await runCheck(sourceCode);
|
|
@@ -111,8 +111,8 @@ describe('Module: DuplicateRenderPartialArguments', () => {
|
|
|
111
111
|
const suggestionResult = applySuggestions(sourceCode, offenses[0]);
|
|
112
112
|
expect(suggestionResult).toEqual([
|
|
113
113
|
`
|
|
114
|
-
{% render '
|
|
115
|
-
{% render '
|
|
114
|
+
{% render 'partial', param1: 'value1', param2: 'value2', param3: 'value3' %}
|
|
115
|
+
{% render 'partial', param1: 'value4', param2: 'value5' %}
|
|
116
116
|
`,
|
|
117
117
|
]);
|
|
118
118
|
});
|
|
@@ -11,7 +11,7 @@ export const DuplicateRenderPartialArguments: LiquidCheckDefinition = {
|
|
|
11
11
|
description:
|
|
12
12
|
'This check ensures that no duplicate argument names are provided when rendering a partial.',
|
|
13
13
|
recommended: true,
|
|
14
|
-
url: 'https://
|
|
14
|
+
url: 'https://documentation.platformos.com/developer-guide/platformos-check/checks/duplicate-render-partial-arguments',
|
|
15
15
|
},
|
|
16
16
|
type: SourceCodeType.LiquidHtml,
|
|
17
17
|
severity: Severity.WARNING,
|
|
@@ -35,7 +35,7 @@ export const GraphQLCheck: GraphQLCheckDefinition = {
|
|
|
35
35
|
|
|
36
36
|
create(context) {
|
|
37
37
|
const validateContent = async (content: string) => {
|
|
38
|
-
const graphQLSchemaString = await context.
|
|
38
|
+
const graphQLSchemaString = await context.platformosDocset?.graphQL();
|
|
39
39
|
if (!graphQLSchemaString) {
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { expect, describe, it } from 'vitest';
|
|
2
|
+
import { GraphQLVariablesCheck } from '.';
|
|
3
|
+
import { check } from '../../test';
|
|
4
|
+
|
|
5
|
+
const GRAPHQL_WITH_REQUIRED = `
|
|
6
|
+
query MyQuery($content: String!) {
|
|
7
|
+
records(filter: { table: { value: "posts" } }) {
|
|
8
|
+
results {
|
|
9
|
+
id
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
const GRAPHQL_WITH_OPTIONAL = `
|
|
16
|
+
query MyQuery($content: String) {
|
|
17
|
+
records(filter: { table: { value: "posts" } }) {
|
|
18
|
+
results {
|
|
19
|
+
id
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
describe('Module: GraphQLVariablesCheck', () => {
|
|
26
|
+
it('reports a missing required parameter', async () => {
|
|
27
|
+
const files = {
|
|
28
|
+
'app/views/partials/page.liquid': `{% graphql r = 'create' %}`,
|
|
29
|
+
'app/graphql/create.graphql': GRAPHQL_WITH_REQUIRED,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const offenses = await check(files, [GraphQLVariablesCheck]);
|
|
33
|
+
|
|
34
|
+
expect(offenses).to.have.length(1);
|
|
35
|
+
expect(offenses[0].message).to.equal(
|
|
36
|
+
'Required parameter content must be passed to GraphQL call',
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('does not report when all required parameters are provided', async () => {
|
|
41
|
+
const files = {
|
|
42
|
+
'app/views/partials/page.liquid': `{% graphql r = 'create', content: 'hello' %}`,
|
|
43
|
+
'app/graphql/create.graphql': GRAPHQL_WITH_REQUIRED,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const offenses = await check(files, [GraphQLVariablesCheck]);
|
|
47
|
+
|
|
48
|
+
expect(offenses).to.be.empty;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('does not report when the parameter is optional', async () => {
|
|
52
|
+
const files = {
|
|
53
|
+
'app/views/partials/page.liquid': `{% graphql r = 'create' %}`,
|
|
54
|
+
'app/graphql/create.graphql': GRAPHQL_WITH_OPTIONAL,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const offenses = await check(files, [GraphQLVariablesCheck]);
|
|
58
|
+
|
|
59
|
+
expect(offenses).to.be.empty;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('does not report when args is used (hash splat)', async () => {
|
|
63
|
+
const files = {
|
|
64
|
+
'app/views/partials/page.liquid': `{% graphql r = 'create', args: object %}`,
|
|
65
|
+
'app/graphql/create.graphql': GRAPHQL_WITH_REQUIRED,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const offenses = await check(files, [GraphQLVariablesCheck]);
|
|
69
|
+
|
|
70
|
+
expect(offenses).to.be.empty;
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('does not report unknown parameter when args is used', async () => {
|
|
74
|
+
const files = {
|
|
75
|
+
'app/views/partials/page.liquid': `{% graphql r = 'create', args: object, extra: 'x' %}`,
|
|
76
|
+
'app/graphql/create.graphql': GRAPHQL_WITH_REQUIRED,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const offenses = await check(files, [GraphQLVariablesCheck]);
|
|
80
|
+
|
|
81
|
+
expect(offenses).to.be.empty;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('reports an unknown parameter when args is not used', async () => {
|
|
85
|
+
const files = {
|
|
86
|
+
'app/views/partials/page.liquid': `{% graphql r = 'create', content: 'hello', unknown: 'x' %}`,
|
|
87
|
+
'app/graphql/create.graphql': GRAPHQL_WITH_REQUIRED,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const offenses = await check(files, [GraphQLVariablesCheck]);
|
|
91
|
+
|
|
92
|
+
expect(offenses).to.have.length(1);
|
|
93
|
+
expect(offenses[0].message).to.equal('Unknown parameter unknown passed to GraphQL call');
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -64,6 +64,10 @@ export const GraphQLVariablesCheck: LiquidCheckDefinition = {
|
|
|
64
64
|
args: LiquidNamedArgument[],
|
|
65
65
|
position: Position,
|
|
66
66
|
) => {
|
|
67
|
+
// `args` is a special parameter that splats a hash as all GraphQL variables
|
|
68
|
+
// at runtime — we can't know which keys will be provided statically.
|
|
69
|
+
if (args.some((arg) => arg.name === 'args')) return;
|
|
70
|
+
|
|
67
71
|
const locatedFile = await locator.locate(
|
|
68
72
|
URI.parse(context.config.rootUri),
|
|
69
73
|
'graphql',
|
|
@@ -7,9 +7,9 @@ export const ImgWidthAndHeight: LiquidCheckDefinition = {
|
|
|
7
7
|
name: 'Width and height attributes on image tags',
|
|
8
8
|
docs: {
|
|
9
9
|
description:
|
|
10
|
-
'This check is aimed at eliminating content layout shift
|
|
10
|
+
'This check is aimed at eliminating content layout shift by enforcing the use of the width and height attributes on img tags.',
|
|
11
11
|
recommended: true,
|
|
12
|
-
url: 'https://
|
|
12
|
+
url: 'https://documentation.platformos.com/developer-guide/platformos-check/checks/img-width-and-height',
|
|
13
13
|
},
|
|
14
14
|
type: SourceCodeType.LiquidHtml,
|
|
15
15
|
severity: Severity.ERROR,
|