@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,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 in themes.',
19
- url: 'https://shopify.dev/docs/storefronts/themes/tools/theme-check/checks/deprecated-filter',
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.themeDocset) {
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.themeDocset!.filters();
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
- describe.skip('Module: DeprecatedTag', () => {
6
- it('should report an offense when include tag is used', async () => {
7
- const sourceCode = `
8
- {% include 'templates/foo.liquid' %}
9
- `;
10
- const offenses = await runLiquidCheck(DeprecatedTag, sourceCode);
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 of 'include'`);
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 render tag is used', async () => {
20
- const sourceCode = `
21
- {% render 'templates/foo.liquid' %}
22
- `;
23
- const offenses = await runLiquidCheck(DeprecatedTag, sourceCode);
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
- const highlights = highlightedOffenses({ 'file.liquid': sourceCode }, offenses);
28
- expect(highlights).toHaveLength(0);
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 suggest replacing include tag with render tag', async () => {
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
- expect(offenses).toHaveLength(2);
40
- if (!offenses[0].suggest || !offenses[1].suggest) return;
90
+ const offenses = await runLiquidCheck(
91
+ DeprecatedTag,
92
+ sourceCode,
93
+ 'file.liquid',
94
+ mockDependencies,
95
+ );
41
96
 
42
- expect(offenses[0].suggest[0].message).toEqual(`Replace 'include' with 'render'`);
43
- expect(offenses[1].suggest[0].message).toEqual(`Replace 'include' with 'render'`);
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).toHaveLength(2);
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 report multiple offenses when multiple include tags are used in the same line', async () => {
52
- const sourceCode = "{% include 'foo.liquid' %} Some text {% include 'bar.liquid' %}";
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
- expect(offenses).toHaveLength(2);
56
- });
57
-
58
- it('should report offenses when include tags are nested', async () => {
59
- const sourceCode = "{% if true %} {% include 'foo.liquid' %} {% endif %}";
60
- const offenses = await runLiquidCheck(DeprecatedTag, sourceCode);
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://shopify.dev/docs/storefronts/themes/tools/theme-check/checks/deprecated-tag',
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
- // commenting this out to stop include from getting flagged
23
- // if (node.name === 'include') {
24
- // const start = node.source.substring(node.position.start);
25
- // const includeStartIndex = start.indexOf('include');
26
- // const includeEndIndex = includeStartIndex + 'include'.length;
27
- // const includeStart = node.position.start + includeStartIndex;
28
- // const includeEnd = node.position.start + includeEndIndex;
29
- // context.report({
30
- // message: `Use the 'render' tag instead of 'include'`,
31
- // startIndex: includeStart,
32
- // endIndex: includeEnd,
33
- // suggest: [
34
- // {
35
- // message: `Replace 'include' with 'render'`,
36
- // fix: (corrector) => {
37
- // corrector.replace(includeStart, includeEnd, 'render');
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://shopify.dev/docs/storefronts/themes/tools/theme-check/checks/duplicate-function-arguments',
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 'snippet', param1: 'value1', param2: 'value2', param1: 'value3' %}
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 'snippet', param1: 'value1', param2: 'value2', param1: 'value3', param2: 'value4', param1: 'value5' %}
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 'snippet' with 'string' as param1, param1: 'value1' %}
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 'snippet', param1: 'value1', param2: 'value2', param1: 'value3', param1: 'value4' %}`;
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 'snippet', param1: 'value1', param2: 'value2', param1: 'value4' %}`,
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 'snippet' with 'string' as param2, param1: 'value1', param2: 'value2' %}`;
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 'snippet' with 'string' as param2, param1: 'value1' %}`,
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 'snippet', param1: 'value1', param2: 'value2', param3: 'value3' %}
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 'snippet', param1: 'value1', param2: 'value2', param3: 'value3' %}
103
- {% render 'snippet', param1: 'value4', param2: 'value5', param1: 'value6' %}
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 'snippet', param1: 'value1', param2: 'value2', param3: 'value3' %}
115
- {% render 'snippet', param1: 'value4', param2: 'value5' %}
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://shopify.dev/docs/storefronts/themes/tools/theme-check/checks/duplicate-render-partial-arguments',
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.themeDocset?.graphQL();
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 in themes by enforcing the use of the width and height attributes on img tags.',
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://shopify.dev/docs/storefronts/themes/tools/theme-check/checks/img-width-and-height',
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,