@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.
Files changed (337) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +4 -4
  3. package/dist/AugmentedPlatformOSDocset.d.ts +11 -0
  4. package/dist/AugmentedPlatformOSDocset.js +81 -0
  5. package/dist/AugmentedPlatformOSDocset.js.map +1 -0
  6. package/dist/JSONValidator.js +1 -1
  7. package/dist/JSONValidator.js.map +1 -1
  8. package/dist/checks/deprecated-filter/index.js +4 -41
  9. package/dist/checks/deprecated-filter/index.js.map +1 -1
  10. package/dist/checks/deprecated-tag/index.js +21 -22
  11. package/dist/checks/deprecated-tag/index.js.map +1 -1
  12. package/dist/checks/duplicate-function-arguments/index.js +1 -1
  13. package/dist/checks/duplicate-function-arguments/index.js.map +1 -1
  14. package/dist/checks/duplicate-render-partial-arguments/index.js +1 -1
  15. package/dist/checks/duplicate-render-partial-arguments/index.js.map +1 -1
  16. package/dist/checks/graphql/index.js +1 -1
  17. package/dist/checks/graphql/index.js.map +1 -1
  18. package/dist/checks/graphql-variables/index.js +4 -0
  19. package/dist/checks/graphql-variables/index.js.map +1 -1
  20. package/dist/checks/img-width-and-height/index.js +1 -1
  21. package/dist/checks/img-width-and-height/index.js.map +1 -1
  22. package/dist/checks/index.d.ts +3 -3
  23. package/dist/checks/index.js +4 -79
  24. package/dist/checks/index.js.map +1 -1
  25. package/dist/checks/json-syntax-error/index.js +1 -1
  26. package/dist/checks/json-syntax-error/index.js.map +1 -1
  27. package/dist/checks/liquid-html-syntax-error/checks/InvalidLoopArguments.js +1 -1
  28. package/dist/checks/liquid-html-syntax-error/checks/InvalidLoopArguments.js.map +1 -1
  29. package/dist/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.d.ts +19 -0
  30. package/dist/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.js +79 -0
  31. package/dist/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.js.map +1 -0
  32. package/dist/checks/liquid-html-syntax-error/checks/UnknownTag.d.ts +3 -0
  33. package/dist/checks/liquid-html-syntax-error/checks/UnknownTag.js +32 -0
  34. package/dist/checks/liquid-html-syntax-error/checks/UnknownTag.js.map +1 -0
  35. package/dist/checks/liquid-html-syntax-error/index.js +23 -5
  36. package/dist/checks/liquid-html-syntax-error/index.js.map +1 -1
  37. package/dist/checks/matching-translations/index.d.ts +2 -2
  38. package/dist/checks/matching-translations/index.js +114 -90
  39. package/dist/checks/matching-translations/index.js.map +1 -1
  40. package/dist/checks/metadata-params/index.js +6 -3
  41. package/dist/checks/metadata-params/index.js.map +1 -1
  42. package/dist/checks/missing-asset/index.js +1 -1
  43. package/dist/checks/missing-asset/index.js.map +1 -1
  44. package/dist/checks/missing-partial/index.d.ts +6 -0
  45. package/dist/checks/missing-partial/index.js +70 -0
  46. package/dist/checks/missing-partial/index.js.map +1 -0
  47. package/dist/checks/orphaned-partial/index.js +4 -4
  48. package/dist/checks/orphaned-partial/index.js.map +1 -1
  49. package/dist/checks/parser-blocking-script/index.js +10 -36
  50. package/dist/checks/parser-blocking-script/index.js.map +1 -1
  51. package/dist/checks/parser-blocking-script/suggestions.d.ts +1 -2
  52. package/dist/checks/parser-blocking-script/suggestions.js +1 -11
  53. package/dist/checks/parser-blocking-script/suggestions.js.map +1 -1
  54. package/dist/checks/reserved-doc-param-names/index.js +6 -5
  55. package/dist/checks/reserved-doc-param-names/index.js.map +1 -1
  56. package/dist/checks/translation-key-exists/index.js +1 -1
  57. package/dist/checks/translation-key-exists/index.js.map +1 -1
  58. package/dist/checks/unclosed-html-element/index.js +5 -1
  59. package/dist/checks/unclosed-html-element/index.js.map +1 -1
  60. package/dist/checks/undefined-object/index.js +13 -31
  61. package/dist/checks/undefined-object/index.js.map +1 -1
  62. package/dist/checks/unique-doc-param-names/index.js +1 -1
  63. package/dist/checks/unique-doc-param-names/index.js.map +1 -1
  64. package/dist/checks/unknown-filter/index.js +3 -3
  65. package/dist/checks/unknown-filter/index.js.map +1 -1
  66. package/dist/checks/unknown-property/index.js +1 -1
  67. package/dist/checks/unknown-property/index.js.map +1 -1
  68. package/dist/checks/unrecognized-render-partial-arguments/index.js +2 -2
  69. package/dist/checks/unrecognized-render-partial-arguments/index.js.map +1 -1
  70. package/dist/checks/unused-assign/index.js +1 -1
  71. package/dist/checks/unused-assign/index.js.map +1 -1
  72. package/dist/checks/unused-doc-param/index.js +1 -1
  73. package/dist/checks/unused-doc-param/index.js.map +1 -1
  74. package/dist/checks/utils.js +1 -1
  75. package/dist/checks/utils.js.map +1 -1
  76. package/dist/checks/valid-content-for-arguments/index.js +1 -1
  77. package/dist/checks/valid-content-for-arguments/index.js.map +1 -1
  78. package/dist/checks/valid-doc-param-types/index.js +4 -4
  79. package/dist/checks/valid-doc-param-types/index.js.map +1 -1
  80. package/dist/checks/valid-html-translation/index.d.ts +2 -2
  81. package/dist/checks/valid-html-translation/index.js +4 -4
  82. package/dist/checks/valid-html-translation/index.js.map +1 -1
  83. package/dist/checks/valid-json/index.js +1 -1
  84. package/dist/checks/valid-json/index.js.map +1 -1
  85. package/dist/checks/valid-render-partial-argument-types/index.js +2 -2
  86. package/dist/checks/valid-render-partial-argument-types/index.js.map +1 -1
  87. package/dist/checks/variable-name/index.js +1 -1
  88. package/dist/checks/variable-name/index.js.map +1 -1
  89. package/dist/context-utils.d.ts +18 -7
  90. package/dist/context-utils.js +68 -109
  91. package/dist/context-utils.js.map +1 -1
  92. package/dist/disabled-checks/index.js +4 -2
  93. package/dist/disabled-checks/index.js.map +1 -1
  94. package/dist/doc-generator/DocBlockGenerator.d.ts +16 -0
  95. package/dist/doc-generator/DocBlockGenerator.js +464 -0
  96. package/dist/doc-generator/DocBlockGenerator.js.map +1 -0
  97. package/dist/doc-generator/index.d.ts +1 -0
  98. package/dist/doc-generator/index.js +6 -0
  99. package/dist/doc-generator/index.js.map +1 -0
  100. package/dist/find-root.d.ts +7 -10
  101. package/dist/find-root.js +10 -17
  102. package/dist/find-root.js.map +1 -1
  103. package/dist/fixes/autofix.d.ts +4 -4
  104. package/dist/fixes/autofix.js +2 -2
  105. package/dist/fixes/autofix.js.map +1 -1
  106. package/dist/fixes/correctors/index.js +4 -0
  107. package/dist/fixes/correctors/index.js.map +1 -1
  108. package/dist/index.d.ts +5 -5
  109. package/dist/index.js +50 -17
  110. package/dist/index.js.map +1 -1
  111. package/dist/jsonc/parse.d.ts +1 -1
  112. package/dist/jsonc/parse.js +1 -1
  113. package/dist/liquid-doc/arguments.d.ts +7 -8
  114. package/dist/liquid-doc/arguments.js +28 -29
  115. package/dist/liquid-doc/arguments.js.map +1 -1
  116. package/dist/liquid-doc/liquidDoc.d.ts +1 -1
  117. package/dist/liquid-doc/liquidDoc.js.map +1 -1
  118. package/dist/liquid-doc/utils.d.ts +3 -3
  119. package/dist/liquid-doc/utils.js +14 -3
  120. package/dist/liquid-doc/utils.js.map +1 -1
  121. package/dist/path.d.ts +1 -0
  122. package/dist/path.js +16 -1
  123. package/dist/path.js.map +1 -1
  124. package/{src/test/MockTheme.ts → dist/test/MockApp.d.ts} +2 -3
  125. package/dist/test/MockApp.js +16 -0
  126. package/dist/test/MockApp.js.map +1 -0
  127. package/dist/test/MockFileSystem.d.ts +3 -3
  128. package/dist/test/MockFileSystem.js +6 -6
  129. package/dist/test/MockFileSystem.js.map +1 -1
  130. package/dist/test/index.d.ts +1 -1
  131. package/dist/test/index.js +1 -1
  132. package/dist/test/index.js.map +1 -1
  133. package/dist/test/test-helper.d.ts +10 -9
  134. package/dist/test/test-helper.js +15 -106
  135. package/dist/test/test-helper.js.map +1 -1
  136. package/dist/to-schema.d.ts +1 -1
  137. package/dist/to-source-code.d.ts +3 -2
  138. package/dist/to-source-code.js +20 -0
  139. package/dist/to-source-code.js.map +1 -1
  140. package/dist/tsconfig.tsbuildinfo +1 -1
  141. package/dist/types/platformos-liquid-docs.d.ts +128 -0
  142. package/dist/types/platformos-liquid-docs.js +3 -0
  143. package/dist/types/platformos-liquid-docs.js.map +1 -0
  144. package/dist/types/schemas/index.d.ts +0 -2
  145. package/dist/types/schemas/index.js.map +1 -1
  146. package/dist/types.d.ts +26 -67
  147. package/dist/types.js +3 -5
  148. package/dist/types.js.map +1 -1
  149. package/dist/utils/block.js.map +1 -1
  150. package/dist/utils/index.d.ts +0 -1
  151. package/dist/utils/index.js +0 -1
  152. package/dist/utils/index.js.map +1 -1
  153. package/dist/yaml/parse.d.ts +5 -0
  154. package/dist/yaml/parse.js +94 -0
  155. package/dist/yaml/parse.js.map +1 -0
  156. package/package.json +4 -3
  157. package/src/{AugmentedThemeDocset.spec.ts → AugmentedPlatformOSDocset.spec.ts} +47 -34
  158. package/src/AugmentedPlatformOSDocset.ts +89 -0
  159. package/src/JSONValidator.ts +1 -1
  160. package/src/checks/deprecated-filter/index.spec.ts +76 -248
  161. package/src/checks/deprecated-filter/index.ts +5 -53
  162. package/src/checks/deprecated-tag/index.spec.ts +85 -34
  163. package/src/checks/deprecated-tag/index.ts +27 -22
  164. package/src/checks/duplicate-function-arguments/index.ts +1 -1
  165. package/src/checks/duplicate-render-partial-arguments/index.spec.ts +12 -12
  166. package/src/checks/duplicate-render-partial-arguments/index.ts +1 -1
  167. package/src/checks/graphql/index.ts +1 -1
  168. package/src/checks/graphql-variables/index.spec.ts +95 -0
  169. package/src/checks/graphql-variables/index.ts +4 -0
  170. package/src/checks/img-width-and-height/index.ts +2 -2
  171. package/src/checks/index.ts +11 -80
  172. package/src/checks/invalid-hash-assign-target/index.spec.ts +27 -27
  173. package/src/checks/json-syntax-error/index.ts +2 -2
  174. package/src/checks/liquid-html-syntax-error/checks/InvalidBooleanExpression.spec.ts +0 -11
  175. package/src/checks/liquid-html-syntax-error/checks/InvalidLoopArguments.spec.ts +1 -2
  176. package/src/checks/liquid-html-syntax-error/checks/InvalidLoopArguments.ts +2 -2
  177. package/src/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.spec.ts +259 -0
  178. package/src/checks/liquid-html-syntax-error/checks/InvalidTagSyntax.ts +89 -0
  179. package/src/checks/liquid-html-syntax-error/checks/UnknownTag.spec.ts +293 -0
  180. package/src/checks/liquid-html-syntax-error/checks/UnknownTag.ts +43 -0
  181. package/src/checks/liquid-html-syntax-error/index.spec.ts +1 -6
  182. package/src/checks/liquid-html-syntax-error/index.ts +26 -5
  183. package/src/checks/matching-translations/index.spec.ts +187 -354
  184. package/src/checks/matching-translations/index.ts +117 -107
  185. package/src/checks/metadata-params/index.ts +6 -8
  186. package/src/checks/missing-asset/index.ts +1 -1
  187. package/src/checks/{missing-template → missing-partial}/index.spec.ts +6 -6
  188. package/src/checks/{missing-template → missing-partial}/index.ts +12 -26
  189. package/src/checks/orphaned-partial/index.ts +3 -3
  190. package/src/checks/parser-blocking-script/index.spec.ts +0 -118
  191. package/src/checks/parser-blocking-script/index.ts +3 -33
  192. package/src/checks/parser-blocking-script/suggestions.ts +1 -28
  193. package/src/checks/translation-key-exists/index.ts +1 -1
  194. package/src/checks/unclosed-html-element/index.ts +5 -1
  195. package/src/checks/undefined-object/index.spec.ts +32 -111
  196. package/src/checks/undefined-object/index.ts +15 -34
  197. package/src/checks/unique-doc-param-names/index.ts +1 -1
  198. package/src/checks/unknown-filter/index.spec.ts +2 -2
  199. package/src/checks/unknown-filter/index.ts +3 -3
  200. package/src/checks/unknown-property/index.ts +1 -1
  201. package/src/checks/unrecognized-render-partial-arguments/index.spec.ts +5 -5
  202. package/src/checks/unrecognized-render-partial-arguments/index.ts +2 -5
  203. package/src/checks/unused-assign/index.spec.ts +0 -30
  204. package/src/checks/unused-assign/index.ts +2 -2
  205. package/src/checks/unused-doc-param/index.ts +1 -1
  206. package/src/checks/utils.ts +1 -1
  207. package/src/checks/valid-doc-param-types/index.ts +4 -4
  208. package/src/checks/valid-html-translation/index.spec.ts +42 -32
  209. package/src/checks/valid-html-translation/index.ts +7 -7
  210. package/src/checks/valid-json/index.ts +2 -2
  211. package/src/checks/valid-render-partial-argument-types/index.spec.ts +13 -13
  212. package/src/checks/valid-render-partial-argument-types/index.ts +2 -5
  213. package/src/checks/variable-name/index.ts +1 -1
  214. package/src/context-utils.spec.ts +49 -77
  215. package/src/context-utils.ts +81 -129
  216. package/src/disabled-checks/index.spec.ts +26 -26
  217. package/src/disabled-checks/index.ts +2 -2
  218. package/src/disabled-checks/test-checks.ts +4 -4
  219. package/src/find-root.ts +12 -22
  220. package/src/fixes/autofix.spec.ts +2 -2
  221. package/src/fixes/autofix.ts +4 -4
  222. package/src/fixes/correctors/index.ts +4 -0
  223. package/src/ignore.spec.ts +4 -5
  224. package/src/index.ts +51 -21
  225. package/src/jsonc/parse.ts +1 -1
  226. package/src/liquid-doc/arguments.spec.ts +19 -45
  227. package/src/liquid-doc/arguments.ts +35 -42
  228. package/src/liquid-doc/liquidDoc.spec.ts +1 -1
  229. package/src/liquid-doc/liquidDoc.ts +1 -2
  230. package/src/liquid-doc/utils.ts +17 -8
  231. package/src/path.ts +16 -0
  232. package/src/test/MockApp.ts +17 -0
  233. package/src/test/MockFileSystem.spec.ts +10 -11
  234. package/src/test/MockFileSystem.ts +6 -6
  235. package/src/test/contain-offense.spec.ts +11 -3
  236. package/src/test/index.ts +1 -1
  237. package/src/test/test-helper.ts +43 -145
  238. package/src/to-source-code.ts +20 -1
  239. package/src/types/{theme-liquid-docs.ts → platformos-liquid-docs.ts} +8 -13
  240. package/src/types.ts +29 -92
  241. package/src/utils/index.ts +0 -1
  242. package/src/visitor.spec.ts +2 -2
  243. package/src/yaml/parse.ts +111 -0
  244. package/src/AugmentedThemeDocset.ts +0 -137
  245. package/src/checks/app-block-missing-schema/index.spec.ts +0 -121
  246. package/src/checks/app-block-missing-schema/index.ts +0 -46
  247. package/src/checks/app-block-valid-tags/index.spec.ts +0 -96
  248. package/src/checks/app-block-valid-tags/index.ts +0 -54
  249. package/src/checks/asset-preload/index.spec.ts +0 -78
  250. package/src/checks/asset-preload/index.ts +0 -65
  251. package/src/checks/asset-size-app-block-css/index.spec.ts +0 -88
  252. package/src/checks/asset-size-app-block-css/index.ts +0 -78
  253. package/src/checks/asset-size-app-block-javascript/index.spec.ts +0 -66
  254. package/src/checks/asset-size-app-block-javascript/index.ts +0 -78
  255. package/src/checks/asset-size-css/index.spec.ts +0 -166
  256. package/src/checks/asset-size-css/index.ts +0 -160
  257. package/src/checks/asset-size-javascript/index.spec.ts +0 -184
  258. package/src/checks/asset-size-javascript/index.ts +0 -144
  259. package/src/checks/block-id-usage/index.spec.ts +0 -76
  260. package/src/checks/block-id-usage/index.ts +0 -72
  261. package/src/checks/cdn-preconnect/index.spec.ts +0 -40
  262. package/src/checks/cdn-preconnect/index.ts +0 -43
  263. package/src/checks/content-for-header-modification/index.spec.ts +0 -65
  264. package/src/checks/content-for-header-modification/index.ts +0 -72
  265. package/src/checks/deprecate-bgsizes/index.spec.ts +0 -41
  266. package/src/checks/deprecate-bgsizes/index.ts +0 -49
  267. package/src/checks/deprecate-lazysizes/index.spec.ts +0 -26
  268. package/src/checks/deprecate-lazysizes/index.ts +0 -58
  269. package/src/checks/deprecated-filter/fixes.ts +0 -264
  270. package/src/checks/deprecated-fonts-on-sections-and-blocks/deprecated-fonts-data.ts +0 -1343
  271. package/src/checks/deprecated-fonts-on-sections-and-blocks/index.spec.ts +0 -613
  272. package/src/checks/deprecated-fonts-on-sections-and-blocks/index.ts +0 -284
  273. package/src/checks/deprecated-fonts-on-settings-schema/index.spec.ts +0 -102
  274. package/src/checks/deprecated-fonts-on-settings-schema/index.ts +0 -66
  275. package/src/checks/duplicate-content-for-arguments/index.spec.ts +0 -98
  276. package/src/checks/duplicate-content-for-arguments/index.ts +0 -43
  277. package/src/checks/empty-block-content/index.spec.ts +0 -117
  278. package/src/checks/empty-block-content/index.ts +0 -60
  279. package/src/checks/hardcoded-routes/index.spec.ts +0 -58
  280. package/src/checks/hardcoded-routes/index.ts +0 -100
  281. package/src/checks/json-missing-block/index.spec.ts +0 -435
  282. package/src/checks/json-missing-block/index.ts +0 -56
  283. package/src/checks/json-missing-block/missing-block-utils.ts +0 -147
  284. package/src/checks/liquid-free-settings/index.spec.ts +0 -180
  285. package/src/checks/liquid-free-settings/index.ts +0 -79
  286. package/src/checks/missing-content-for-arguments/index.spec.ts +0 -144
  287. package/src/checks/missing-content-for-arguments/index.ts +0 -46
  288. package/src/checks/pagination-size/index.spec.ts +0 -158
  289. package/src/checks/pagination-size/index.ts +0 -104
  290. package/src/checks/remote-asset/index.spec.ts +0 -280
  291. package/src/checks/remote-asset/index.ts +0 -238
  292. package/src/checks/reserved-doc-param-names/index.spec.ts +0 -62
  293. package/src/checks/reserved-doc-param-names/index.ts +0 -57
  294. package/src/checks/schema-presets-block-order/index.spec.ts +0 -344
  295. package/src/checks/schema-presets-block-order/index.ts +0 -154
  296. package/src/checks/schema-presets-static-blocks/index.spec.ts +0 -145
  297. package/src/checks/schema-presets-static-blocks/index.ts +0 -126
  298. package/src/checks/static-stylesheet-and-javascript-tags/index.spec.ts +0 -257
  299. package/src/checks/static-stylesheet-and-javascript-tags/index.ts +0 -48
  300. package/src/checks/unique-settings-id/index.spec.ts +0 -24
  301. package/src/checks/unique-settings-id/index.ts +0 -84
  302. package/src/checks/unique-settings-id/test-data.ts +0 -1191
  303. package/src/checks/unique-static-block-id/index.spec.ts +0 -55
  304. package/src/checks/unique-static-block-id/index.ts +0 -60
  305. package/src/checks/unrecognized-content-for-arguments/index.spec.ts +0 -145
  306. package/src/checks/unrecognized-content-for-arguments/index.ts +0 -55
  307. package/src/checks/valid-block-target/index.spec.ts +0 -1396
  308. package/src/checks/valid-block-target/index.ts +0 -142
  309. package/src/checks/valid-content-for-argument-types/index.spec.ts +0 -382
  310. package/src/checks/valid-content-for-argument-types/index.ts +0 -42
  311. package/src/checks/valid-content-for-arguments/index.spec.ts +0 -107
  312. package/src/checks/valid-content-for-arguments/index.ts +0 -98
  313. package/src/checks/valid-local-blocks/index.spec.ts +0 -286
  314. package/src/checks/valid-local-blocks/index.ts +0 -100
  315. package/src/checks/valid-local-blocks/valid-block-utils.ts +0 -97
  316. package/src/checks/valid-schema/index.spec.ts +0 -174
  317. package/src/checks/valid-schema/index.ts +0 -41
  318. package/src/checks/valid-schema-name/index.spec.ts +0 -112
  319. package/src/checks/valid-schema-name/index.ts +0 -75
  320. package/src/checks/valid-settings-key/index.spec.ts +0 -321
  321. package/src/checks/valid-settings-key/index.ts +0 -144
  322. package/src/checks/valid-static-block-type/index.spec.ts +0 -38
  323. package/src/checks/valid-static-block-type/index.ts +0 -58
  324. package/src/checks/valid-visible-if/index.spec.ts +0 -619
  325. package/src/checks/valid-visible-if/index.ts +0 -184
  326. package/src/checks/valid-visible-if/visible-if-utils.ts +0 -158
  327. package/src/tags/content-for.ts +0 -25
  328. package/src/to-schema.ts +0 -231
  329. package/src/types/schemas/index.ts +0 -5
  330. package/src/types/schemas/preset.ts +0 -52
  331. package/src/types/schemas/section.ts +0 -86
  332. package/src/types/schemas/setting.ts +0 -320
  333. package/src/types/schemas/template.ts +0 -34
  334. package/src/types/schemas/theme-block.ts +0 -34
  335. package/src/types/theme-schemas.ts +0 -80
  336. package/src/utils/block.ts +0 -300
  337. package/src/utils/markup.ts +0 -10
@@ -1,15 +1,48 @@
1
- import { URI, Utils } from 'vscode-uri';
2
- import { AbstractFileSystem, FileTuple, FileType, UriString } from '@platformos/platformos-common';
3
- import { parseJSON } from './json';
4
- import { join } from './path';
1
+ import { load } from 'js-yaml';
5
2
  import {
6
- MetafieldCategory,
7
- MetafieldDefinitionMap,
8
- SourceCodeType,
9
- Theme,
10
- Translations,
11
- } from './types';
12
- import { isError } from './utils';
3
+ AbstractFileSystem,
4
+ FileTuple,
5
+ FileType,
6
+ TranslationProvider,
7
+ UriString,
8
+ } from '@platformos/platformos-common';
9
+ import { URI } from 'vscode-uri';
10
+ import { join } from './path';
11
+ import { SourceCodeType, App, Translations } from './types';
12
+
13
+ /**
14
+ * Returns a function that loads and merges ALL translation files for a given
15
+ * locale within a specific translations base directory URI
16
+ * (e.g. `file:///app/translations` or
17
+ * `file:///modules/common-styling/public/translations`).
18
+ *
19
+ * Covers both the single-file layout (`{base}/{locale}.yml`) and the split-file
20
+ * layout (`{base}/{locale}/*.yml`).
21
+ *
22
+ * Only files whose first YAML key matches `locale` are included — this mirrors
23
+ * how platformOS determines a file's locale from its content, not its path.
24
+ *
25
+ * In-memory editor buffers take precedence over the filesystem so that unsaved
26
+ * changes are reflected immediately.
27
+ */
28
+ export const makeGetTranslationsForBase = (fs: AbstractFileSystem, app: App) => {
29
+ const provider = new TranslationProvider(fs);
30
+ const cache = new Map<string, Promise<Translations>>();
31
+
32
+ return (translationBaseUri: string, locale: string): Promise<Translations> => {
33
+ const key = `${translationBaseUri}::${locale}`;
34
+ if (!cache.has(key)) {
35
+ const contentOverride = (uri: string): string | undefined =>
36
+ app.find((sc) => sc.type === SourceCodeType.YAML && sc.uri === uri)?.source;
37
+
38
+ cache.set(
39
+ key,
40
+ provider.loadAllTranslationsForBase(URI.parse(translationBaseUri), locale, contentOverride),
41
+ );
42
+ }
43
+ return cache.get(key)!;
44
+ };
45
+ };
13
46
 
14
47
  export type FileExists = (uri: string) => Promise<boolean>;
15
48
 
@@ -33,71 +66,49 @@ export const makeFileSize = (fs: AbstractFileSystem) =>
33
66
  }
34
67
  };
35
68
 
36
- export const makeGetDefaultLocaleFileUri = getDefaultLocaleFileUriFactoryFactory('default.json');
37
- export const makeGetDefaultSchemaLocaleFileUri =
38
- getDefaultLocaleFileUriFactoryFactory('.default.schema.json');
39
- function getDefaultLocaleFileUriFactoryFactory(postfix = '.default.json') {
40
- return function getDefaultLocaleFileUriFactory(fs: AbstractFileSystem) {
41
- return (rootUri: string) => getDefaultLocaleFile(fs, rootUri, postfix);
42
- };
43
- }
69
+ export const makeGetDefaultLocaleFileUri = (fs: AbstractFileSystem) => (rootUri: string) =>
70
+ getDefaultLocaleFile(fs, rootUri);
44
71
 
45
- export const makeGetDefaultLocale = getDefaultLocaleFactoryFactory('.default.json');
46
- export const makeGetDefaultSchemaLocale = getDefaultLocaleFactoryFactory('.default.schema.json');
47
- function getDefaultLocaleFactoryFactory(postfix = '.default.json') {
48
- return function getDefaultLocaleFactory(fs: AbstractFileSystem, rootUri: string) {
49
- return cached(() => getDefaultLocale(fs, rootUri, postfix));
50
- };
51
- }
72
+ export const makeGetDefaultLocale = (fs: AbstractFileSystem, rootUri: string) =>
73
+ cached(() => getDefaultLocale(fs, rootUri));
52
74
 
53
- export const makeGetDefaultTranslations = getDefaultTranslationsFactoryFactory('.default.json');
54
- export const makeGetDefaultSchemaTranslations =
55
- getDefaultTranslationsFactoryFactory('.default.schema.json');
56
- // prettier-ignore
57
- function getDefaultTranslationsFactoryFactory(postfix = '.default.json') {
58
- return function getDefaultTranslationsFactory(fs: AbstractFileSystem, theme: Theme, rootUri: string) {
59
- return cached(() => getDefaultTranslations(fs, theme, rootUri, postfix));
60
- };
61
- }
75
+ export const makeGetDefaultTranslations = (fs: AbstractFileSystem, app: App, rootUri: string) =>
76
+ cached(() => getDefaultTranslations(fs, app, rootUri));
62
77
 
63
78
  async function getDefaultLocaleFile(
64
79
  fs: AbstractFileSystem,
65
80
  rootUri: string,
66
- postfix = '.default.json',
67
- ) {
68
- const files = await fs.readDirectory(join(rootUri, 'locales'));
69
- return files.find(([uri]) => uri.endsWith(postfix))?.[0];
70
- }
71
-
72
- async function getDefaultLocale(
73
- fs: AbstractFileSystem,
74
- rootUri: string,
75
- postfix: string,
76
- ): Promise<string> {
81
+ ): Promise<string | undefined> {
82
+ const enYmlUri = join(rootUri, 'app/translations/en.yml');
77
83
  try {
78
- const defaultLocaleFile = await getDefaultLocaleFile(fs, rootUri, postfix);
79
- if (!defaultLocaleFile) return 'en';
80
- const defaultLocaleFileName = Utils.basename(URI.parse(defaultLocaleFile));
81
- return defaultLocaleFileName.split('.')[0];
82
- } catch (error) {
83
- console.error(error);
84
- return 'en';
84
+ await fs.stat(enYmlUri);
85
+ return enYmlUri;
86
+ } catch {
87
+ return undefined;
85
88
  }
86
89
  }
87
90
 
91
+ async function getDefaultLocale(_fs: AbstractFileSystem, _rootUri: string): Promise<string> {
92
+ // In platformOS, en.yml is always the reference translation file
93
+ return 'en';
94
+ }
95
+
88
96
  async function getDefaultTranslations(
89
97
  fs: AbstractFileSystem,
90
- theme: Theme,
98
+ app: App,
91
99
  rootUri: string,
92
- postfix: string,
93
100
  ): Promise<Translations> {
94
101
  try {
95
- const bufferTranslations = getDefaultTranslationsFromBuffer(theme, postfix);
102
+ const bufferTranslations = getDefaultTranslationsFromBuffer(app);
96
103
  if (bufferTranslations) return bufferTranslations;
97
- const defaultLocaleFile = await getDefaultLocaleFile(fs, rootUri, postfix);
104
+ const defaultLocaleFile = await getDefaultLocaleFile(fs, rootUri);
98
105
  if (!defaultLocaleFile) return {};
99
- const defaultTranslationsFile = await fs.readFile(defaultLocaleFile);
100
- return parseJSON(defaultTranslationsFile, {});
106
+ const yamlContent = await fs.readFile(defaultLocaleFile);
107
+ const data = load(yamlContent) as Record<string, any>;
108
+ if (!data || typeof data !== 'object') return {};
109
+ // YAML translation files wrap content under the locale key: { en: { hello: 'Hello' } }
110
+ const localeKey = Object.keys(data)[0];
111
+ return (localeKey && data[localeKey]) ?? {};
101
112
  } catch (error) {
102
113
  console.error(error);
103
114
  return {};
@@ -105,17 +116,19 @@ async function getDefaultTranslations(
105
116
  }
106
117
 
107
118
  /** It might be that you have an open buffer, we prefer translations from there if available */
108
- function getDefaultTranslationsFromBuffer(theme: Theme, postfix: string): Translations | undefined {
109
- const defaultTranslationsSourceCode = theme.find(
110
- (sourceCode) =>
111
- sourceCode.type === SourceCodeType.JSON &&
112
- sourceCode.uri.match(/locales/) &&
113
- sourceCode.uri.endsWith(postfix),
119
+ function getDefaultTranslationsFromBuffer(app: App): Translations | undefined {
120
+ const defaultTranslationsSourceCode = app.find(
121
+ (sourceCode) => sourceCode.type === SourceCodeType.YAML && sourceCode.uri.endsWith('/en.yml'),
114
122
  );
115
123
  if (!defaultTranslationsSourceCode) return undefined;
116
- const translations = parseJSON(defaultTranslationsSourceCode.source);
117
- if (isError(translations)) return undefined;
118
- return translations;
124
+ try {
125
+ const data = load(defaultTranslationsSourceCode.source) as Record<string, any>;
126
+ if (!data || typeof data !== 'object') return undefined;
127
+ const localeKey = Object.keys(data)[0];
128
+ return (localeKey && data[localeKey]) ?? undefined;
129
+ } catch {
130
+ return undefined;
131
+ }
119
132
  }
120
133
 
121
134
  function cached<T>(fn: () => Promise<T>): () => Promise<T>;
@@ -157,64 +170,3 @@ const ignoredFolders = ['.git', 'node_modules', 'dist', 'build', 'tmp', 'vendor'
157
170
  function isIgnored([uri, type]: FileTuple) {
158
171
  return type === FileType.Directory && ignoredFolders.some((folder) => uri.endsWith(folder));
159
172
  }
160
-
161
- export const FETCHED_METAFIELD_CATEGORIES: MetafieldCategory[] = [
162
- 'article',
163
- 'blog',
164
- 'collection',
165
- 'company',
166
- 'company_location',
167
- 'location',
168
- 'market',
169
- 'order',
170
- 'page',
171
- 'product',
172
- 'variant',
173
- 'shop',
174
- ];
175
-
176
- export const makeGetMetafieldDefinitions = (fs: AbstractFileSystem) =>
177
- async function (rootUri: string): Promise<MetafieldDefinitionMap> {
178
- const definitions = {
179
- article: [],
180
- blog: [],
181
- collection: [],
182
- company: [],
183
- company_location: [],
184
- location: [],
185
- market: [],
186
- order: [],
187
- page: [],
188
- product: [],
189
- variant: [],
190
- shop: [],
191
- } as MetafieldDefinitionMap;
192
-
193
- try {
194
- const content = await fs.readFile(join(rootUri, '.shopify', 'metafields.json'));
195
- const json = parseJSON(content);
196
-
197
- if (isError(json)) return definitions;
198
-
199
- return FETCHED_METAFIELD_CATEGORIES.reduce((definitions, group) => {
200
- try {
201
- definitions[group] = json[group].map((definition: any) => ({
202
- key: definition.key,
203
- name: definition.name,
204
- namespace: definition.namespace,
205
- description: definition.description,
206
- type: {
207
- category: definition.type.category,
208
- name: definition.type.name,
209
- },
210
- }));
211
- } catch (error) {
212
- // If there are errors in the file, we ignore it
213
- }
214
-
215
- return definitions;
216
- }, definitions);
217
- } catch (err) {
218
- return definitions;
219
- }
220
- };
@@ -34,10 +34,10 @@ describe('Module: DisabledChecks', () => {
34
34
  describe(`Comment variant`, () => {
35
35
  it('should disable checks for the entire document if comment is placed on the first line', async () => {
36
36
  for (const buildComment of commentTypes) {
37
- const file = `${buildComment('theme-check-disable LiquidFilter')}
37
+ const file = `${buildComment('platformos-check-disable LiquidFilter')}
38
38
  {% comment %}
39
39
  This is some comment about the file...
40
- Adding a comment here should not mess with theme-check-disable
40
+ Adding a comment here should not mess with platformos-check-disable
41
41
  {% endcomment %}
42
42
  {{ 'asset' | random_filter }}
43
43
  {% render 'something' %}`;
@@ -50,7 +50,7 @@ describe('Module: DisabledChecks', () => {
50
50
 
51
51
  it('should disable all checks even if comment has additional spaces', async () => {
52
52
  for (const buildComment of commentTypes) {
53
- const file = `${buildComment(' theme-check-disable ')}
53
+ const file = `${buildComment(' platformos-check-disable ')}
54
54
  {{ 'asset' | random_filter }}
55
55
  {% render 'something' %}`;
56
56
 
@@ -63,10 +63,10 @@ describe('Module: DisabledChecks', () => {
63
63
  for (const buildComment of commentTypes) {
64
64
  const file = `{{ 'asset-1' | random_filter }}
65
65
  {% render 'something-1' %}
66
- ${buildComment('theme-check-disable')}
66
+ ${buildComment('platformos-check-disable')}
67
67
  {{ 'asset-2' | random_filter }}
68
68
  {% render 'something-2' %}
69
- ${buildComment('theme-check-enable')}
69
+ ${buildComment('platformos-check-enable')}
70
70
  {{ 'asset-3' | random_filter }}`;
71
71
 
72
72
  const offenses = await check({ 'code.liquid': file }, checks);
@@ -79,10 +79,10 @@ ${buildComment('theme-check-enable')}
79
79
 
80
80
  it('should disable a specific check if check is included in the comment', async () => {
81
81
  for (const buildComment of commentTypes) {
82
- const file = `${buildComment('theme-check-disable LiquidFilter')}
82
+ const file = `${buildComment('platformos-check-disable LiquidFilter')}
83
83
  {{ 'asset-1' | random_filter }}
84
84
  {% render 'something' %}
85
- ${buildComment('theme-check-enable LiquidFilter')}
85
+ ${buildComment('platformos-check-enable LiquidFilter')}
86
86
  {{ 'asset-2' | random_filter }}`;
87
87
 
88
88
  const offenses = await check({ 'code.liquid': file }, checks);
@@ -94,10 +94,10 @@ ${buildComment('theme-check-enable LiquidFilter')}
94
94
 
95
95
  it('should disable multiple checks if checks are separated by a comma (and maybe some spaces)', async () => {
96
96
  for (const buildComment of commentTypes) {
97
- const file = `${buildComment('theme-check-disable LiquidFilter, RenderMarkup')}
97
+ const file = `${buildComment('platformos-check-disable LiquidFilter, RenderMarkup')}
98
98
  {{ 'asset-1' | random_filter }}
99
99
  {% render 'something' %}
100
- ${buildComment('theme-check-enable LiquidFilter,RenderMarkup')}
100
+ ${buildComment('platformos-check-enable LiquidFilter,RenderMarkup')}
101
101
  {{ 'asset-2' | random_filter }}`;
102
102
 
103
103
  const offenses = await check({ 'code.liquid': file }, checks);
@@ -108,13 +108,13 @@ ${buildComment('theme-check-enable LiquidFilter,RenderMarkup')}
108
108
 
109
109
  it('should enable specific checks individually', async () => {
110
110
  for (const buildComment of commentTypes) {
111
- const file = `${buildComment('theme-check-disable LiquidFilter, RenderMarkup')}
111
+ const file = `${buildComment('platformos-check-disable LiquidFilter, RenderMarkup')}
112
112
  {{ 'asset-1' | random_filter }}
113
113
  {% render 'something-1' %}
114
- ${buildComment('theme-check-enable RenderMarkup')}
114
+ ${buildComment('platformos-check-enable RenderMarkup')}
115
115
  {{ 'asset-2' | random_filter }}
116
116
  {% render 'something-2' %}
117
- ${buildComment('theme-check-enable LiquidFilter')}
117
+ ${buildComment('platformos-check-enable LiquidFilter')}
118
118
  {{ 'asset-3' | random_filter }}
119
119
  {% render 'something-3' %}`;
120
120
 
@@ -129,10 +129,10 @@ ${buildComment('theme-check-enable LiquidFilter')}
129
129
  describe('Mix of general and specific commands', () => {
130
130
  it('should not reenable specific check when all checks have been disabled before', async () => {
131
131
  for (const buildComment of commentTypes) {
132
- const file = `${buildComment('theme-check-disable')}
132
+ const file = `${buildComment('platformos-check-disable')}
133
133
  {{ 'asset-1' | random_filter }}
134
134
  {% render 'something-1' %}
135
- ${buildComment('theme-check-enable RenderMarkup')}
135
+ ${buildComment('platformos-check-enable RenderMarkup')}
136
136
  {{ 'asset-2' | random_filter }}
137
137
  {% render 'something-2' %}`;
138
138
  const offenses = await check({ 'code.liquid': file }, checks);
@@ -142,10 +142,10 @@ ${buildComment('theme-check-enable RenderMarkup')}
142
142
 
143
143
  it('should reenable all checks when specific ones have been disabled before', async () => {
144
144
  for (const buildComment of commentTypes) {
145
- const file = `${buildComment('theme-check-disable LiquidFilter, RenderMarkup')}
145
+ const file = `${buildComment('platformos-check-disable LiquidFilter, RenderMarkup')}
146
146
  {{ 'asset-3' | random_filter }}
147
147
  {% render 'something-3' %}
148
- ${buildComment('theme-check-enable')}
148
+ ${buildComment('platformos-check-enable')}
149
149
  {{ 'asset-4' | random_filter }}
150
150
  {% render 'something-4' %}`;
151
151
 
@@ -159,7 +159,7 @@ ${buildComment('theme-check-enable')}
159
159
 
160
160
  describe('disable next line', () => {
161
161
  it('should disable the next line if there is one', async () => {
162
- const file = `{% # theme-check-disable-next-line %}
162
+ const file = `{% # platformos-check-disable-next-line %}
163
163
  {% render 'something' %}
164
164
  {% render 'other-thing' %}`;
165
165
 
@@ -168,8 +168,8 @@ ${buildComment('theme-check-enable')}
168
168
  expectRenderMarkupOffense(offenses, 'other-thing.liquid');
169
169
  });
170
170
 
171
- it("should not disable the liquid tag's children node if theme check is disabled", async () => {
172
- const file = `{% # theme-check-disable-next-line %}
171
+ it("should not disable the liquid tag's children node if platformos-check is disabled", async () => {
172
+ const file = `{% # platformos-check-disable-next-line %}
173
173
  {% if condition %}
174
174
  {% render 'something' %}
175
175
  {% endif %}
@@ -183,7 +183,7 @@ ${buildComment('theme-check-enable')}
183
183
 
184
184
  it('should disable the next line inside a liquid tag if there is one', async () => {
185
185
  const file = `{% liquid
186
- # theme-check-disable-next-line
186
+ # platformos-check-disable-next-line
187
187
  render 'something'
188
188
  render 'other-thing'
189
189
  %}`;
@@ -193,10 +193,10 @@ ${buildComment('theme-check-enable')}
193
193
  expectRenderMarkupOffense(offenses, 'other-thing.liquid');
194
194
  });
195
195
 
196
- it("should disable the parent node's next node if theme check is disabled as the last child node", async () => {
196
+ it("should disable the parent node's next node if platformos-check is disabled as the last child node", async () => {
197
197
  const file = `{% liquid
198
198
  if condition
199
- # theme-check-disable-next-line
199
+ # platformos-check-disable-next-line
200
200
  elsif other_condition
201
201
  endif
202
202
  %}`;
@@ -210,11 +210,11 @@ ${buildComment('theme-check-enable')}
210
210
  );
211
211
  });
212
212
 
213
- it('should not disable any checks if theme-check is disabled at the end', async () => {
213
+ it('should not disable any checks if platformos-check is disabled at the end', async () => {
214
214
  const file = `{% liquid
215
215
  echo hello
216
216
  echo everyone
217
- # theme-check-disable-next-line
217
+ # platformos-check-disable-next-line
218
218
  %}`;
219
219
 
220
220
  const offenses = await check({ 'code.liquid': file }, [UndefinedObject]);
@@ -232,7 +232,7 @@ ${buildComment('theme-check-enable')}
232
232
  });
233
233
 
234
234
  it('should disable the next line if the content is an HTML tag with liquid', async () => {
235
- const file = `{% # theme-check-disable-next-line %}
235
+ const file = `{% # platformos-check-disable-next-line %}
236
236
  <div class="{{ foo }}"></div>
237
237
  <div class="{{ bar }}"></div>`;
238
238
 
@@ -246,7 +246,7 @@ ${buildComment('theme-check-enable')}
246
246
  });
247
247
 
248
248
  it('should not disable the next line if the specified rule does not exist', async () => {
249
- const file = `{% # theme-check-disable-next-line FAKE_RULE %}
249
+ const file = `{% # platformos-check-disable-next-line FAKE_RULE %}
250
250
  <div class="{{ foo }}"></div>`;
251
251
 
252
252
  const offenses = await check({ 'code.liquid': file }, [UndefinedObject]);
@@ -24,7 +24,7 @@ export function createDisabledChecksModule() {
24
24
  node: LiquidTag | LiquidRawTag,
25
25
  ) {
26
26
  const [_, command, checksJoined] =
27
- value.trim().match(/^(?:theme\-check\-(disable-next-line|disable|enable)) ?(.*)/) || [];
27
+ value.trim().match(/^(?:platformos\-check\-(disable-next-line|disable|enable)) ?(.*)/) || [];
28
28
 
29
29
  const checks = checksJoined ? checksJoined.split(/,[ ]*/) : [SPECIFIC_CHECK_NOT_DEFINED];
30
30
 
@@ -133,7 +133,7 @@ export function findNextLinePosition(
133
133
  * E.g. The following disables check for `elsif` tag
134
134
  *
135
135
  * {% if condition %}
136
- * {% #theme-check-disable-next-line %}
136
+ * {% # platformos-check-disable-next-line %}
137
137
  * {% elsif other_condition %}
138
138
  * {{ prouduct }}
139
139
  * {% endif %}
@@ -45,14 +45,14 @@ export const RenderMarkup: LiquidCheckDefinition = {
45
45
  create(context) {
46
46
  return {
47
47
  async RenderMarkup(node) {
48
- if (node.snippet.type === NodeTypes.VariableLookup) {
48
+ if (node.partial.type === NodeTypes.VariableLookup) {
49
49
  return;
50
50
  }
51
51
 
52
52
  context.report({
53
- message: `'${node.snippet.value}.liquid' can not be rendered`,
54
- startIndex: node.snippet.position.start,
55
- endIndex: node.snippet.position.end,
53
+ message: `'${node.partial.value}.liquid' can not be rendered`,
54
+ startIndex: node.partial.position.start,
55
+ endIndex: node.partial.position.end,
56
56
  });
57
57
  },
58
58
  };
package/src/find-root.ts CHANGED
@@ -5,13 +5,11 @@ type FileExists = (uri: string) => Promise<boolean>;
5
5
 
6
6
  async function isRoot(dir: UriString, fileExists: FileExists) {
7
7
  return or(
8
- // .pos config file and app directory exists
9
- and(
10
- fileExists(path.join(dir, '.pos')),
11
- fileExists(path.join(dir, 'app')),
12
- fileExists(path.join(dir, 'modules')),
13
- fileExists(path.join(dir, '.git')),
14
- ),
8
+ fileExists(path.join(dir, '.pos')),
9
+ fileExists(path.join(dir, '.platformos-check.yml')),
10
+ fileExists(path.join(dir, 'app')),
11
+ // modules/ is a root indicator only when not inside app/ (app/modules/ is a valid subdirectory)
12
+ and(fileExists(path.join(dir, 'modules')), Promise.resolve(path.basename(dir) !== 'app')),
15
13
  );
16
14
  }
17
15
 
@@ -25,24 +23,16 @@ async function or(...promises: Promise<boolean>[]) {
25
23
  return bools.reduce((a, b) => a || b, false);
26
24
  }
27
25
 
28
- async function not(ap: Promise<boolean>) {
29
- const a = await ap;
30
- return !a;
31
- }
32
-
33
26
  /**
34
- * Returns the "root" of a theme or theme app extension. The root is the
35
- * directory that contains a `.theme-check.yml` file, a `.git` directory, or a
36
- * `shopify.extension.toml` file.
37
- *
38
- * There are cases where .theme-check.yml is not defined and we have to infer the root.
39
- * We'll assume that the root is the directory that contains a `snippets` directory.
27
+ * Returns the root of a platformOS app. The root is the directory that contains
28
+ * a `.pos` sentinel file, a `.platformos-check.yml` config file, an `app/` directory,
29
+ * or a `modules/` directory (when not inside `app/`).
40
30
  *
41
- * So you can think of this function as the function that infers where a .theme-check.yml
42
- * should be.
31
+ * Note: `modules/` inside `app/` (i.e. `app/modules/`) is a valid subdirectory and
32
+ * should not be treated as a root indicator.
43
33
  *
44
- * Note: that this is not the theme root. The config file might have a `root` entry in it
45
- * that points to somewhere else.
34
+ * Note: this is not the app root itself. The config file might have a `root` entry that
35
+ * points to somewhere else.
46
36
  */
47
37
  export async function findRoot(curr: UriString, fileExists: FileExists): Promise<UriString | null> {
48
38
  const currIsRoot = await isRoot(curr, fileExists);
@@ -4,7 +4,7 @@ import { Offense, SourceCodeType } from '../types';
4
4
 
5
5
  describe('Module: autofix', () => {
6
6
  it('should apply a list of all safe changes', async () => {
7
- const mockTheme = {
7
+ const mockApp = {
8
8
  'a.liquid': 'Banana world',
9
9
  'b.json': prettyJSON({ a: 'b' }),
10
10
  };
@@ -69,7 +69,7 @@ describe('Module: autofix', () => {
69
69
  },
70
70
  ];
71
71
 
72
- const fixed = await autofix(mockTheme, offenses);
72
+ const fixed = await autofix(mockApp, offenses);
73
73
  expect(fixed['a.liquid']).to.eql('Bananananana world');
74
74
  expect(fixed['b.json']).to.eql(
75
75
  prettyJSON({
@@ -1,4 +1,4 @@
1
- import { FixApplicator, Offense, SourceCodeType, Theme } from '../types';
1
+ import { FixApplicator, Offense, SourceCodeType, App } from '../types';
2
2
  import { WithRequired } from '../utils/types';
3
3
  import { createCorrector } from './correctors';
4
4
  import { flattenFixes } from './utils';
@@ -8,13 +8,13 @@ type FixableOffense<S extends SourceCodeType> = S extends SourceCodeType
8
8
  : never;
9
9
 
10
10
  /**
11
- * Takes a theme, list of offenses and a fixApplicator and runs all the
12
- * safe ones on the theme.
11
+ * Takes an app, list of offenses and a fixApplicator and runs all the
12
+ * safe ones on the app.
13
13
  *
14
14
  * Note that offense.fix is assumed to be safe, unlike offense.suggest
15
15
  * options.
16
16
  */
17
- export async function autofix(sourceCodes: Theme, offenses: Offense[], applyFixes: FixApplicator) {
17
+ export async function autofix(sourceCodes: App, offenses: Offense[], applyFixes: FixApplicator) {
18
18
  const fixableOffenses = offenses.filter(
19
19
  (offense): offense is FixableOffense<SourceCodeType> => 'fix' in offense && !!offense.fix,
20
20
  );
@@ -18,6 +18,10 @@ export function createCorrector<S extends SourceCodeType>(
18
18
  }
19
19
  case SourceCodeType.GraphQL:
20
20
  return new GraphQLCorrector(source) as Corrector<typeof sourceCodeType>;
21
+ case SourceCodeType.YAML: {
22
+ // YAML autofix is not yet supported; this case should not be reached
23
+ throw new Error('YAML autofix is not supported');
24
+ }
21
25
  default: {
22
26
  return assertNever(sourceCodeType);
23
27
  }
@@ -47,7 +47,7 @@ describe('Function: isIgnored', () => {
47
47
  const result = isIgnored(
48
48
  toUri('app/views/partials/foo.liquid'),
49
49
  config({
50
- checkIgnore: ['!snippets/*'],
50
+ checkIgnore: ['!other-dir/*'],
51
51
  globalIgnore: [],
52
52
  }),
53
53
  checkDef,
@@ -73,7 +73,7 @@ describe('Function: isIgnored', () => {
73
73
  const result = isIgnored(
74
74
  toUri('app/views/partials/foo.liquid'),
75
75
  config({
76
- checkIgnore: ['other-snippets/*.liquid'],
76
+ checkIgnore: ['other-dir/*.liquid'],
77
77
  globalIgnore: [],
78
78
  }),
79
79
  checkDef,
@@ -165,10 +165,10 @@ describe('Function: isIgnored', () => {
165
165
 
166
166
  it('should work with only global ignore as well', () => {
167
167
  const result = isIgnored(
168
- toUri('layout/theme.liquid'),
168
+ toUri('app/views/layouts/layout.liquid'),
169
169
  config({
170
170
  checkIgnore: [],
171
- globalIgnore: ['layout/theme.liquid'],
171
+ globalIgnore: ['app/views/layouts/layout.liquid'],
172
172
  }),
173
173
  );
174
174
 
@@ -188,7 +188,6 @@ function config({
188
188
  globalIgnore?: string[];
189
189
  }): Config {
190
190
  return {
191
- context: 'theme',
192
191
  settings: {
193
192
  MockCheck: {
194
193
  enabled: true,