@platformos/platformos-check-common 0.0.6 → 0.0.8
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/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/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/index.js +2 -2
- 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 +20 -31
- 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 +7 -30
- 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 +2 -7
- package/dist/context-utils.js +39 -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/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 +4 -5
- package/dist/index.js +34 -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 +20 -28
- 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 +1 -1
- package/dist/liquid-doc/utils.js +4 -3
- package/dist/liquid-doc/utils.js.map +1 -1
- package/dist/path.d.ts +1 -0
- package/dist/path.js +5 -1
- package/dist/path.js.map +1 -1
- package/dist/test/MockApp.d.ts +16 -0
- 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-source-code.d.ts +4 -3
- 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 +18 -67
- package/dist/types.js +3 -5
- package/dist/types.js.map +1 -1
- package/dist/utils/file-utils.js +1 -2
- package/dist/utils/file-utils.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 +9 -9
- 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.ts +1 -1
- package/src/checks/graphql/index.ts +1 -1
- package/src/checks/img-width-and-height/index.ts +1 -1
- package/src/checks/index.ts +11 -80
- package/src/checks/invalid-hash-assign-target/index.spec.ts +14 -14
- package/src/checks/json-syntax-error/index.ts +1 -1
- 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/index.spec.ts +1 -6
- package/src/checks/liquid-html-syntax-error/index.ts +2 -2
- package/src/checks/matching-translations/index.spec.ts +89 -346
- package/src/checks/matching-translations/index.ts +24 -35
- package/src/checks/metadata-params/index.ts +5 -7
- 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 +6 -20
- 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 +3 -109
- package/src/checks/undefined-object/index.ts +8 -33
- 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 +1 -1
- 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 +1 -1
- 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 +39 -128
- package/src/disabled-checks/index.spec.ts +35 -0
- package/src/disabled-checks/index.ts +4 -2
- 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 +0 -1
- package/src/index.ts +33 -21
- package/src/jsonc/parse.ts +1 -1
- package/src/liquid-doc/arguments.spec.ts +19 -45
- package/src/liquid-doc/arguments.ts +26 -39
- package/src/liquid-doc/liquidDoc.ts +1 -2
- package/src/liquid-doc/utils.ts +4 -3
- package/src/path.ts +1 -0
- package/src/test/{MockTheme.ts → MockApp.ts} +1 -1
- package/src/test/MockFileSystem.ts +9 -6
- package/src/test/index.ts +1 -1
- package/src/test/test-helper.ts +29 -127
- package/src/to-source-code.ts +20 -1
- package/src/types/{theme-liquid-docs.ts → platformos-liquid-docs.ts} +8 -13
- package/src/types/schemas/index.ts +0 -2
- package/src/types.ts +21 -92
- package/src/utils/file-utils.ts +0 -1
- package/src/utils/index.ts +0 -1
- 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/section.ts +0 -86
- 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
package/src/test/test-helper.ts
CHANGED
|
@@ -10,44 +10,39 @@ import {
|
|
|
10
10
|
Dependencies,
|
|
11
11
|
extractDocDefinition,
|
|
12
12
|
FixApplicator,
|
|
13
|
-
isBlock,
|
|
14
|
-
isSection,
|
|
15
13
|
JSONCorrector,
|
|
16
14
|
JSONSourceCode,
|
|
17
15
|
LiquidSourceCode,
|
|
18
16
|
Offense,
|
|
19
17
|
recommended,
|
|
20
|
-
SectionSchema,
|
|
21
18
|
SourceCodeType,
|
|
22
19
|
StringCorrector,
|
|
23
|
-
|
|
24
|
-
ThemeBlockSchema,
|
|
25
|
-
toSchema,
|
|
20
|
+
App,
|
|
26
21
|
toSourceCode,
|
|
22
|
+
YAMLSourceCode,
|
|
27
23
|
} from '../index';
|
|
28
24
|
import * as path from '../path';
|
|
29
25
|
import { MockFileSystem } from './MockFileSystem';
|
|
30
|
-
import {
|
|
26
|
+
import { MockApp } from './MockApp';
|
|
31
27
|
|
|
32
28
|
export { JSONCorrector, StringCorrector };
|
|
33
29
|
|
|
34
30
|
const rootUri = path.normalize('file:/');
|
|
35
31
|
|
|
36
|
-
export function
|
|
32
|
+
export function getApp(themeDesc: MockApp): App {
|
|
37
33
|
return Object.entries(themeDesc)
|
|
38
34
|
.map(([relativePath, source]) => toSourceCode(toUri(relativePath), source))
|
|
39
|
-
.filter((x): x is LiquidSourceCode | JSONSourceCode => x !== undefined);
|
|
35
|
+
.filter((x): x is LiquidSourceCode | JSONSourceCode | YAMLSourceCode => x !== undefined);
|
|
40
36
|
}
|
|
41
37
|
|
|
42
38
|
export async function check(
|
|
43
|
-
themeDesc:
|
|
39
|
+
themeDesc: MockApp,
|
|
44
40
|
checks: CheckDefinition[] = recommended,
|
|
45
41
|
mockDependencies: Partial<Dependencies> = {},
|
|
46
42
|
checkSettings: ChecksSettings = {},
|
|
47
43
|
): Promise<Offense[]> {
|
|
48
|
-
const theme =
|
|
44
|
+
const theme = getApp(themeDesc);
|
|
49
45
|
const config: Config = {
|
|
50
|
-
context: 'theme',
|
|
51
46
|
settings: { ...checkSettings },
|
|
52
47
|
checks,
|
|
53
48
|
rootUri,
|
|
@@ -56,40 +51,8 @@ export async function check(
|
|
|
56
51
|
},
|
|
57
52
|
};
|
|
58
53
|
|
|
59
|
-
const sections = new Map(
|
|
60
|
-
theme
|
|
61
|
-
.filter((source) => isSection(source.uri))
|
|
62
|
-
.map((source) => [path.basename(source.uri, '.liquid'), source]),
|
|
63
|
-
);
|
|
64
|
-
const blocks = new Map(
|
|
65
|
-
theme
|
|
66
|
-
.filter((source) => isBlock(source.uri))
|
|
67
|
-
.map((source) => [path.basename(source.uri, '.liquid'), source]),
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Schemas are assumed to be valid in tests, hijack
|
|
72
|
-
* getBlockSchema/getSectionSchema with overrides when you want to test
|
|
73
|
-
* something otherwise
|
|
74
|
-
*/
|
|
75
|
-
const isValidSchema = async () => true;
|
|
76
|
-
|
|
77
54
|
const defaultMockDependencies: Dependencies = {
|
|
78
|
-
fs: new MockFileSystem({ '.
|
|
79
|
-
async getBlockSchema(name) {
|
|
80
|
-
const block = blocks.get(name);
|
|
81
|
-
if (!block) return undefined;
|
|
82
|
-
return toSchema(config.context, block.uri, block, isValidSchema) as Promise<
|
|
83
|
-
ThemeBlockSchema | undefined
|
|
84
|
-
>;
|
|
85
|
-
},
|
|
86
|
-
async getSectionSchema(name) {
|
|
87
|
-
const section = sections.get(name);
|
|
88
|
-
if (!section) return undefined;
|
|
89
|
-
return toSchema(config.context, section.uri, section, isValidSchema) as Promise<
|
|
90
|
-
SectionSchema | undefined
|
|
91
|
-
>;
|
|
92
|
-
},
|
|
55
|
+
fs: new MockFileSystem({ '.platformos-check.yml': '', ...themeDesc }),
|
|
93
56
|
async getDocDefinition(relativePath) {
|
|
94
57
|
const file = theme.find((file) => file.uri.endsWith(relativePath));
|
|
95
58
|
if (!file || !isLiquidHtmlNode(file.ast)) {
|
|
@@ -97,54 +60,18 @@ export async function check(
|
|
|
97
60
|
}
|
|
98
61
|
return extractDocDefinition(file.uri, file.ast);
|
|
99
62
|
},
|
|
100
|
-
|
|
63
|
+
platformosDocset: {
|
|
101
64
|
async graphQL() {
|
|
102
65
|
return null;
|
|
103
66
|
},
|
|
104
67
|
async filters() {
|
|
105
68
|
return [
|
|
106
69
|
{ name: 'item_count_for_variant' },
|
|
107
|
-
{ name: 'link_to_type' },
|
|
108
|
-
{ name: 'link_to_vendor' },
|
|
109
70
|
{ name: 'append' },
|
|
110
71
|
{ name: 'upcase' },
|
|
111
72
|
{ name: 'downcase' },
|
|
112
|
-
{ name: '
|
|
113
|
-
{
|
|
114
|
-
name: 'hex_to_rgba',
|
|
115
|
-
deprecated: true,
|
|
116
|
-
deprecation_reason: '`hex_to_rgba` has been replaced by [`color_to_rgb`](/do...',
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
name: 'currency_selector',
|
|
120
|
-
deprecated: true,
|
|
121
|
-
deprecation_reason: 'Deprecated without a direct replacement because the [cur...',
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
name: 'article_img_url',
|
|
125
|
-
deprecated: true,
|
|
126
|
-
deprecation_reason: '`article_img_url` has been replaced by [`image_url`](/d...',
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
name: 'collection_img_url',
|
|
130
|
-
deprecated: true,
|
|
131
|
-
deprecation_reason: '`collection_img_url` has been replaced by [`image_url`](...',
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
name: 'img_tag',
|
|
135
|
-
deprecated: true,
|
|
136
|
-
deprecation_reason: '`img_tag` has been replaced by [`image_tag`](/docs/api/...',
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
name: 'img_url',
|
|
140
|
-
deprecated: true,
|
|
141
|
-
deprecation_reason: '`img_url` has been replaced by [`image_url`](/docs/api/...',
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
name: 'product_img_url',
|
|
145
|
-
deprecated: true,
|
|
146
|
-
deprecation_reason: '`product_img_url` has been replaced by [`image_url`](/d...',
|
|
147
|
-
},
|
|
73
|
+
{ name: 'parameterize' },
|
|
74
|
+
{ name: 'slugify' },
|
|
148
75
|
];
|
|
149
76
|
},
|
|
150
77
|
async objects() {
|
|
@@ -169,17 +96,9 @@ export async function check(
|
|
|
169
96
|
},
|
|
170
97
|
},
|
|
171
98
|
{
|
|
172
|
-
name: '
|
|
173
|
-
access: {
|
|
174
|
-
global: false,
|
|
175
|
-
parents: [],
|
|
176
|
-
template: [],
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
name: 'block',
|
|
99
|
+
name: 'context',
|
|
181
100
|
access: {
|
|
182
|
-
global:
|
|
101
|
+
global: true,
|
|
183
102
|
parents: [],
|
|
184
103
|
template: [],
|
|
185
104
|
},
|
|
@@ -192,30 +111,6 @@ export async function check(
|
|
|
192
111
|
template: [],
|
|
193
112
|
},
|
|
194
113
|
},
|
|
195
|
-
{
|
|
196
|
-
name: 'predictive_search',
|
|
197
|
-
access: {
|
|
198
|
-
global: false,
|
|
199
|
-
parents: [],
|
|
200
|
-
template: [],
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
name: 'recommendations',
|
|
205
|
-
access: {
|
|
206
|
-
global: false,
|
|
207
|
-
parents: [],
|
|
208
|
-
template: [],
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
name: 'comment',
|
|
213
|
-
access: {
|
|
214
|
-
global: false,
|
|
215
|
-
parents: [],
|
|
216
|
-
template: [],
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
114
|
];
|
|
220
115
|
},
|
|
221
116
|
async liquidDrops() {
|
|
@@ -224,9 +119,6 @@ export async function check(
|
|
|
224
119
|
async tags() {
|
|
225
120
|
return [];
|
|
226
121
|
},
|
|
227
|
-
async systemTranslations() {
|
|
228
|
-
return { 'shopify.sentence.words_connector': ', ' };
|
|
229
|
-
},
|
|
230
122
|
},
|
|
231
123
|
};
|
|
232
124
|
|
|
@@ -238,7 +130,7 @@ export async function runLiquidCheck(
|
|
|
238
130
|
sourceCode: string,
|
|
239
131
|
fileName: string = 'file.liquid',
|
|
240
132
|
mockDependencies: Partial<Dependencies> = {},
|
|
241
|
-
existingThemeFiles?:
|
|
133
|
+
existingThemeFiles?: MockApp,
|
|
242
134
|
): Promise<Offense[]> {
|
|
243
135
|
const offenses = await check(
|
|
244
136
|
{ ...existingThemeFiles, [fileName]: sourceCode },
|
|
@@ -258,8 +150,18 @@ export async function runJSONCheck(
|
|
|
258
150
|
return offenses.filter((offense) => offense.uri === path.join(rootUri, fileName));
|
|
259
151
|
}
|
|
260
152
|
|
|
261
|
-
export async function
|
|
262
|
-
|
|
153
|
+
export async function runYAMLCheck(
|
|
154
|
+
checkDef: CheckDefinition<SourceCodeType.YAML>,
|
|
155
|
+
sourceCode: string,
|
|
156
|
+
fileName: string = 'file.yml',
|
|
157
|
+
mockDependencies: Partial<Dependencies> = {},
|
|
158
|
+
): Promise<Offense[]> {
|
|
159
|
+
const offenses = await check({ [fileName]: sourceCode }, [checkDef], mockDependencies);
|
|
160
|
+
return offenses.filter((offense) => offense.uri === path.join(rootUri, fileName));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export async function autofix(themeDesc: MockApp, offenses: Offense[]) {
|
|
164
|
+
const theme = getApp(themeDesc);
|
|
263
165
|
const fixed = { ...themeDesc };
|
|
264
166
|
|
|
265
167
|
const stringApplicator: FixApplicator = async (sourceCode, fixes) => {
|
|
@@ -272,7 +174,7 @@ export async function autofix(themeDesc: MockTheme, offenses: Offense[]) {
|
|
|
272
174
|
}
|
|
273
175
|
|
|
274
176
|
export function applyFix(
|
|
275
|
-
themeDescOrSource:
|
|
177
|
+
themeDescOrSource: MockApp | string,
|
|
276
178
|
offense: Offense,
|
|
277
179
|
): string | undefined {
|
|
278
180
|
const source =
|
|
@@ -285,7 +187,7 @@ export function applyFix(
|
|
|
285
187
|
}
|
|
286
188
|
|
|
287
189
|
export function applySuggestions(
|
|
288
|
-
themeDescOrSource:
|
|
190
|
+
themeDescOrSource: MockApp | string,
|
|
289
191
|
offense: Offense,
|
|
290
192
|
): undefined | string[] {
|
|
291
193
|
const source =
|
|
@@ -299,7 +201,7 @@ export function applySuggestions(
|
|
|
299
201
|
});
|
|
300
202
|
}
|
|
301
203
|
|
|
302
|
-
export function highlightedOffenses(themeOrSource:
|
|
204
|
+
export function highlightedOffenses(themeOrSource: MockApp | string, offenses: Offense[]) {
|
|
303
205
|
const theme =
|
|
304
206
|
typeof themeOrSource === 'string' ? { 'file.liquid': themeOrSource } : themeOrSource;
|
|
305
207
|
return offenses.map((offense) => {
|
package/src/to-source-code.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { toLiquidHtmlAST } from '@platformos/liquid-html-parser';
|
|
2
2
|
|
|
3
3
|
import { toJSONNode } from './jsonc/parse';
|
|
4
|
+
import { toYAMLNode } from './yaml/parse';
|
|
4
5
|
import * as path from './path';
|
|
5
6
|
import {
|
|
6
7
|
GraphQLDocumentNode,
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
JSONSourceCode,
|
|
10
11
|
LiquidSourceCode,
|
|
11
12
|
SourceCodeType,
|
|
13
|
+
YAMLSourceCode,
|
|
12
14
|
} from './types';
|
|
13
15
|
import { asError } from './utils/error';
|
|
14
16
|
|
|
@@ -28,6 +30,14 @@ export function toJSONAST(source: string): JSONNode | Error {
|
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
|
|
33
|
+
export function toYAMLAST(source: string): JSONNode | Error {
|
|
34
|
+
try {
|
|
35
|
+
return toYAMLNode(source);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
return asError(error);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
31
41
|
export function toGraphQLAST(source: string): GraphQLDocumentNode | Error {
|
|
32
42
|
try {
|
|
33
43
|
return {
|
|
@@ -43,9 +53,10 @@ export function toSourceCode(
|
|
|
43
53
|
uri: string,
|
|
44
54
|
source: string,
|
|
45
55
|
version?: number,
|
|
46
|
-
): LiquidSourceCode | JSONSourceCode | GraphQLSourceCode {
|
|
56
|
+
): LiquidSourceCode | JSONSourceCode | GraphQLSourceCode | YAMLSourceCode {
|
|
47
57
|
const isLiquid = uri.endsWith('.liquid');
|
|
48
58
|
const isGraphQL = uri.endsWith('.graphql');
|
|
59
|
+
const isYAML = uri.endsWith('.yml') || uri.endsWith('.yaml');
|
|
49
60
|
|
|
50
61
|
if (isLiquid) {
|
|
51
62
|
return {
|
|
@@ -63,6 +74,14 @@ export function toSourceCode(
|
|
|
63
74
|
ast: toGraphQLAST(source),
|
|
64
75
|
version,
|
|
65
76
|
};
|
|
77
|
+
} else if (isYAML) {
|
|
78
|
+
return {
|
|
79
|
+
uri: path.normalize(uri),
|
|
80
|
+
source,
|
|
81
|
+
type: SourceCodeType.YAML,
|
|
82
|
+
ast: toYAMLAST(source),
|
|
83
|
+
version,
|
|
84
|
+
};
|
|
66
85
|
} else {
|
|
67
86
|
return {
|
|
68
87
|
uri: path.normalize(uri),
|
|
@@ -1,29 +1,24 @@
|
|
|
1
|
-
import { Mode, Translations } from '..';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
2
|
+
* platformOS Liquid docset.
|
|
5
3
|
*/
|
|
6
|
-
export interface
|
|
4
|
+
export interface PlatformOSDocset {
|
|
7
5
|
/** Whether it was augmented prior to being passed. */
|
|
8
6
|
isAugmented?: boolean;
|
|
9
7
|
|
|
10
|
-
/** Returns Liquid filters available
|
|
8
|
+
/** Returns Liquid filters available in platformOS. */
|
|
11
9
|
filters(): Promise<FilterEntry[]>;
|
|
12
10
|
|
|
13
|
-
/** Returns objects (or Liquid variables) available
|
|
11
|
+
/** Returns objects (or Liquid variables) available in platformOS. */
|
|
14
12
|
objects(): Promise<ObjectEntry[]>;
|
|
15
13
|
|
|
16
|
-
/** Returns objects (excluding global variables, hidden objects, and deprecated objects) available
|
|
14
|
+
/** Returns objects (excluding global variables, hidden objects, and deprecated objects) available in platformOS. */
|
|
17
15
|
liquidDrops(): Promise<ObjectEntry[]>;
|
|
18
16
|
|
|
19
|
-
/** Returns Liquid tags available
|
|
17
|
+
/** Returns Liquid tags available in platformOS. */
|
|
20
18
|
tags(): Promise<TagEntry[]>;
|
|
21
19
|
|
|
22
20
|
/** Returns graphql root query */
|
|
23
21
|
graphQL(): Promise<string | null>;
|
|
24
|
-
|
|
25
|
-
/** Returns system translations available on themes. */
|
|
26
|
-
systemTranslations(): Promise<Translations>;
|
|
27
22
|
}
|
|
28
23
|
|
|
29
24
|
/** A URI that will uniquely describe the schema */
|
|
@@ -45,10 +40,10 @@ export interface SchemaDefinition {
|
|
|
45
40
|
fileMatch?: string[];
|
|
46
41
|
}
|
|
47
42
|
|
|
48
|
-
/** Source of JSON schemas for
|
|
43
|
+
/** Source of JSON schemas for the app. */
|
|
49
44
|
export interface JsonValidationSet {
|
|
50
45
|
/** All relevant SchemaDefinitions. */
|
|
51
|
-
schemas: (
|
|
46
|
+
schemas: () => Promise<SchemaDefinition[]>;
|
|
52
47
|
}
|
|
53
48
|
|
|
54
49
|
export interface DocsetEntry {
|
package/src/types.ts
CHANGED
|
@@ -15,15 +15,13 @@ import {
|
|
|
15
15
|
PropertyNode,
|
|
16
16
|
ValueNode,
|
|
17
17
|
} from './jsonc/types';
|
|
18
|
-
import { JsonValidationSet,
|
|
19
|
-
import { AppBlockSchema, SectionSchema, ThemeBlockSchema } from './types/theme-schemas';
|
|
18
|
+
import { JsonValidationSet, PlatformOSDocset } from './types/platformos-liquid-docs';
|
|
20
19
|
import { DocDefinition } from './liquid-doc/liquidDoc';
|
|
21
20
|
import { GraphQLCorrector } from './fixes/correctors/graphql-corrector';
|
|
22
21
|
|
|
23
22
|
export * from './jsonc/types';
|
|
24
23
|
export * from './types/schema-prop-factory';
|
|
25
|
-
export * from './types/
|
|
26
|
-
export * from './types/theme-schemas';
|
|
24
|
+
export * from './types/platformos-liquid-docs';
|
|
27
25
|
|
|
28
26
|
export const isObjectNode = (node?: ASTNode): node is ObjectNode => node?.type === 'Object';
|
|
29
27
|
export const isArrayNode = (node?: ASTNode): node is ArrayNode => node?.type === 'Array';
|
|
@@ -31,9 +29,7 @@ export const isPropertyNode = (node?: ASTNode): node is PropertyNode => node?.ty
|
|
|
31
29
|
export const isValueNode = (node?: ASTNode): node is ValueNode => node?.type === 'Value';
|
|
32
30
|
export const isLiteralNode = (node?: ASTNode): node is LiteralNode => node?.type === 'Literal';
|
|
33
31
|
|
|
34
|
-
export
|
|
35
|
-
export type Mode = (typeof Modes)[number];
|
|
36
|
-
export type Theme = SourceCode<SourceCodeType>[];
|
|
32
|
+
export type App = SourceCode<SourceCodeType>[];
|
|
37
33
|
|
|
38
34
|
export type SourceCode<T = SourceCodeType> = T extends SourceCodeType
|
|
39
35
|
? {
|
|
@@ -53,6 +49,7 @@ export enum SourceCodeType {
|
|
|
53
49
|
JSON = 'JSON',
|
|
54
50
|
LiquidHtml = 'LiquidHtml',
|
|
55
51
|
GraphQL = 'GraphQL',
|
|
52
|
+
YAML = 'YAML',
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
export type LiquidSourceCode = SourceCode<SourceCodeType.LiquidHtml>;
|
|
@@ -82,6 +79,13 @@ export type JSONCheckDefinition<S extends Schema = Schema> = CheckDefinition<
|
|
|
82
79
|
>;
|
|
83
80
|
export type JSONCheck = Check<SourceCodeType.JSON>;
|
|
84
81
|
|
|
82
|
+
export type YAMLSourceCode = SourceCode<SourceCodeType.YAML>;
|
|
83
|
+
export type YAMLCheckDefinition<S extends Schema = Schema> = CheckDefinition<
|
|
84
|
+
SourceCodeType.YAML,
|
|
85
|
+
S
|
|
86
|
+
>;
|
|
87
|
+
export type YAMLCheck = Check<SourceCodeType.YAML>;
|
|
88
|
+
|
|
85
89
|
export interface PlatformOSFile {
|
|
86
90
|
name: string;
|
|
87
91
|
module_name: string;
|
|
@@ -99,6 +103,7 @@ export type AST = {
|
|
|
99
103
|
[SourceCodeType.JSON]: JSONNode;
|
|
100
104
|
[SourceCodeType.LiquidHtml]: LiquidHtmlNode;
|
|
101
105
|
[SourceCodeType.GraphQL]: GraphQLDocumentNode;
|
|
106
|
+
[SourceCodeType.YAML]: JSONNode; // YAML shares the JSONNode AST
|
|
102
107
|
}[T];
|
|
103
108
|
};
|
|
104
109
|
|
|
@@ -107,6 +112,7 @@ export type NodeTypes = {
|
|
|
107
112
|
[SourceCodeType.JSON]: JSONNodeTypes;
|
|
108
113
|
[SourceCodeType.LiquidHtml]: LiquidHtmlNodeTypes;
|
|
109
114
|
[SourceCodeType.GraphQL]: 'Document';
|
|
115
|
+
[SourceCodeType.YAML]: JSONNodeTypes; // YAML shares JSON node types
|
|
110
116
|
}[T];
|
|
111
117
|
};
|
|
112
118
|
|
|
@@ -136,12 +142,6 @@ export type GraphQLCheckDefinition<S extends Schema = Schema> = CheckDefinition<
|
|
|
136
142
|
>;
|
|
137
143
|
|
|
138
144
|
export interface Config {
|
|
139
|
-
// I know, it's `context` in the config and `Mode` in the code...
|
|
140
|
-
// We already have something named "Context" internally when you're writing a check.
|
|
141
|
-
// I don't like "Mode" as a public API in the configs. Context sounds more Shopify-y.
|
|
142
|
-
// So we have `context: theme` and `context: app` as valid .theme-check.yml configs.
|
|
143
|
-
// I think it's rather obvious what they mean.
|
|
144
|
-
context: Mode;
|
|
145
145
|
settings: ChecksSettings;
|
|
146
146
|
checks: CheckDefinition<SourceCodeType, Schema>[];
|
|
147
147
|
rootUri: string; // e.g. file:///path-to-root
|
|
@@ -214,8 +214,6 @@ export type CheckDefinition<
|
|
|
214
214
|
*
|
|
215
215
|
* When values are given, this check will be `enabled: false` in the `all.yml` configuration
|
|
216
216
|
* and `enabled: true` within all yaml configurations with a matching filename.
|
|
217
|
-
*
|
|
218
|
-
* Note: theme-app-extension target is deprecated (Shopify-specific)
|
|
219
217
|
*/
|
|
220
218
|
targets?: ConfigTarget[];
|
|
221
219
|
|
|
@@ -302,37 +300,6 @@ type CheckLifecycleMethods<T extends SourceCodeType> = {
|
|
|
302
300
|
onCodePathEnd(file: SourceCode<T> & { ast: AST[T] }): Promise<void>;
|
|
303
301
|
};
|
|
304
302
|
|
|
305
|
-
export type MetafieldCategory =
|
|
306
|
-
| 'article'
|
|
307
|
-
| 'blog'
|
|
308
|
-
| 'collection'
|
|
309
|
-
| 'company'
|
|
310
|
-
| 'company_location'
|
|
311
|
-
| 'location'
|
|
312
|
-
| 'market'
|
|
313
|
-
| 'order'
|
|
314
|
-
| 'page'
|
|
315
|
-
| 'product'
|
|
316
|
-
| 'variant'
|
|
317
|
-
| 'shop';
|
|
318
|
-
|
|
319
|
-
export type MetafieldDefinitionMap = {
|
|
320
|
-
[key in MetafieldCategory]: MetafieldDefinition[];
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
export type MetafieldDefinition = {
|
|
324
|
-
key: string;
|
|
325
|
-
name: string;
|
|
326
|
-
namespace: string;
|
|
327
|
-
description: string;
|
|
328
|
-
type: MetafieldDefinitionType;
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
type MetafieldDefinitionType = {
|
|
332
|
-
category: string;
|
|
333
|
-
name: string;
|
|
334
|
-
};
|
|
335
|
-
|
|
336
303
|
export type Translations = {
|
|
337
304
|
[k in string]: string | Translations;
|
|
338
305
|
};
|
|
@@ -344,17 +311,8 @@ export type Translations = {
|
|
|
344
311
|
*
|
|
345
312
|
* It could be a specific range that points to a whole file
|
|
346
313
|
* {
|
|
347
|
-
* source: { uri: 'file:///templates/index.json', range: [167, 190] },
|
|
348
|
-
* target: 'file:///sections/custom-section.liquid'
|
|
349
|
-
* }
|
|
350
|
-
*
|
|
351
|
-
* It could be a specific range that points to a specific range
|
|
352
|
-
* {
|
|
353
|
-
* // e.g. `<parent-component></parent-component>`
|
|
354
314
|
* source: { uri: 'file:///app/views/partials/parent.liquid', range: [167, 190] },
|
|
355
|
-
*
|
|
356
|
-
* // e.g. window.customElements.define('parent-component', ParentComponent);
|
|
357
|
-
* target: { uri: 'file:///assets/theme.js', range: [0, undefined] }
|
|
315
|
+
* target: 'file:///app/views/partials/child.liquid'
|
|
358
316
|
* }
|
|
359
317
|
*/
|
|
360
318
|
export type Reference = {
|
|
@@ -362,9 +320,8 @@ export type Reference = {
|
|
|
362
320
|
target: Location;
|
|
363
321
|
|
|
364
322
|
type:
|
|
365
|
-
| 'direct' // explicit dependency, e.g. {% render '
|
|
366
|
-
| 'indirect' // indirect dependency
|
|
367
|
-
| 'preset'; // preset dependency
|
|
323
|
+
| 'direct' // explicit dependency, e.g. {% render 'partial' %}
|
|
324
|
+
| 'indirect'; // indirect dependency
|
|
368
325
|
};
|
|
369
326
|
|
|
370
327
|
export type Range = [start: number, end: number]; // represents a range in the source code
|
|
@@ -380,41 +337,16 @@ export interface Dependencies {
|
|
|
380
337
|
fs: AbstractFileSystem;
|
|
381
338
|
|
|
382
339
|
/** The typing information */
|
|
383
|
-
|
|
340
|
+
platformosDocset?: PlatformOSDocset;
|
|
384
341
|
|
|
385
|
-
/** The
|
|
342
|
+
/** The JSON schemas */
|
|
386
343
|
jsonValidationSet?: JsonValidationSet;
|
|
387
344
|
|
|
388
|
-
/** Returns the typing information for the theme's metafields */
|
|
389
|
-
getMetafieldDefinitions?: (rootUri: UriString) => Promise<MetafieldDefinitionMap>;
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* Asynchronously get the block schema for 'blocks/${name}.liquid'
|
|
393
|
-
* May return undefined when the theme isn't preloaded.
|
|
394
|
-
* See {@link ThemeBlockSchema} for more information
|
|
395
|
-
*/
|
|
396
|
-
getBlockSchema?: (name: string) => Promise<ThemeBlockSchema | undefined>;
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* Asynchronously get the section schema for 'section/${name}.liquid'
|
|
400
|
-
* May return undefined when the theme isn't preloaded or if there are none.
|
|
401
|
-
* See {@link SectionSchema} for more information
|
|
402
|
-
*/
|
|
403
|
-
getSectionSchema?: (name: string) => Promise<SectionSchema | undefined>;
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* (In theme app extension mode)
|
|
407
|
-
* Asynchronously get the block schema for 'blocks/${name}.liquid'
|
|
408
|
-
* May return undefined when the theme isn't preloaded.
|
|
409
|
-
* See {@link AppBlockSchema} for more information
|
|
410
|
-
*/
|
|
411
|
-
getAppBlockSchema?: (name: string) => Promise<AppBlockSchema | undefined>;
|
|
412
|
-
|
|
413
345
|
/**
|
|
414
346
|
* Asynchronously get the Liquid HTML AST for a file.
|
|
415
|
-
* May return undefined when the
|
|
347
|
+
* May return undefined when the app isn't preloaded.
|
|
416
348
|
*
|
|
417
|
-
* Used in
|
|
349
|
+
* Used in checks for cross-file checks rather than going through fs.
|
|
418
350
|
*/
|
|
419
351
|
getDocDefinition?: (relativePath: string) => Promise<DocDefinition | undefined>;
|
|
420
352
|
|
|
@@ -436,10 +368,7 @@ export interface AugmentedDependencies extends Dependencies {
|
|
|
436
368
|
fileExists: (uri: UriString) => Promise<boolean>;
|
|
437
369
|
fileSize: (uri: UriString) => Promise<number>;
|
|
438
370
|
getDefaultLocale: () => Promise<string>;
|
|
439
|
-
getDefaultSchemaLocale: () => Promise<string>;
|
|
440
371
|
getDefaultTranslations(): Promise<Translations>;
|
|
441
|
-
getDefaultSchemaTranslations(): Promise<Translations>;
|
|
442
|
-
mode: Mode;
|
|
443
372
|
}
|
|
444
373
|
|
|
445
374
|
type StaticContextProperties<T extends SourceCodeType> = T extends SourceCodeType
|
|
@@ -461,6 +390,7 @@ export type Corrector<T extends SourceCodeType> = T extends SourceCodeType
|
|
|
461
390
|
[SourceCodeType.JSON]: JSONCorrector;
|
|
462
391
|
[SourceCodeType.LiquidHtml]: StringCorrector;
|
|
463
392
|
[SourceCodeType.GraphQL]: GraphQLCorrector;
|
|
393
|
+
[SourceCodeType.YAML]: StringCorrector; // no YAML autofix yet; StringCorrector as placeholder
|
|
464
394
|
}[T]
|
|
465
395
|
: never;
|
|
466
396
|
|
|
@@ -613,5 +543,4 @@ export enum Severity {
|
|
|
613
543
|
export enum ConfigTarget {
|
|
614
544
|
All = 'all',
|
|
615
545
|
Recommended = 'recommended',
|
|
616
|
-
ThemeAppExtension = 'theme-app-extension',
|
|
617
546
|
}
|
package/src/utils/file-utils.ts
CHANGED
package/src/utils/index.ts
CHANGED