File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
packages/theme-check-common/src/checks/unsupported-doc-tag Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 11import { isSnippet , isBlock } from '../../to-schema' ;
22import { LiquidCheckDefinition , Severity , SourceCodeType } from '../../types' ;
33import { filePathSupportsLiquidDoc } from '../../liquid-doc/utils' ;
4+ import { LiquidRawTag , NodeTypes , LiquidHtmlNode } from '@shopify/liquid-html-parser' ;
45
56export const UnsupportedDocTag : LiquidCheckDefinition = {
67 meta : {
@@ -19,18 +20,28 @@ export const UnsupportedDocTag: LiquidCheckDefinition = {
1920
2021 create ( context ) {
2122 const docTagName = 'doc' ;
23+ const snippetTagName = 'snippet' ;
2224
2325 if ( filePathSupportsLiquidDoc ( context . file . uri ) ) {
2426 return { } ;
2527 }
2628
2729 return {
28- async LiquidRawTag ( node ) {
30+ async LiquidRawTag ( node : LiquidRawTag , ancestors : LiquidHtmlNode [ ] ) {
2931 if ( node . name !== docTagName ) {
3032 return ;
3133 }
34+
35+ const isInsideSnippetTag = ancestors . some ( ( ancestor ) => {
36+ return ancestor . type === NodeTypes . LiquidTag && ancestor . name === snippetTagName ;
37+ } ) ;
38+
39+ if ( isInsideSnippetTag ) {
40+ return ;
41+ }
42+
3243 context . report ( {
33- message : `The \`${ docTagName } \` tag can only be used within a snippet or block.` ,
44+ message : `The \`${ docTagName } \` tag can only be used within an inline snippet, snippet or block.` ,
3445 startIndex : node . position . start ,
3546 endIndex : node . position . end ,
3647 suggest : [
You can’t perform that action at this time.
0 commit comments