@shopify/theme-check-common
Advanced tools
Comparing version 2.8.0 to 2.9.0
# @shopify/theme-check-common | ||
## 2.9.0 | ||
### Minor Changes | ||
- 457f9cb: Add CaptureOnContentForBlock check | ||
- edb7f2e: Standardized variable number formatting | ||
## 2.7.0 | ||
@@ -4,0 +11,0 @@ |
@@ -12,2 +12,3 @@ "use strict"; | ||
const cdn_preconnect_1 = require("./cdn-preconnect"); | ||
const capture_on_content_for_block_1 = require("./capture-on-content-for-block"); | ||
const content_for_header_modification_1 = require("./content-for-header-modification"); | ||
@@ -46,8 +47,9 @@ const deprecate_bgsizes_1 = require("./deprecate-bgsizes"); | ||
asset_size_javascript_1.AssetSizeJavaScript, | ||
capture_on_content_for_block_1.CaptureOnContentForBlock, | ||
cdn_preconnect_1.CdnPreconnect, | ||
content_for_header_modification_1.ContentForHeaderModification, | ||
deprecate_bgsizes_1.DeprecateBgsizes, | ||
deprecate_lazysizes_1.DeprecateLazysizes, | ||
deprecated_filter_1.DeprecatedFilter, | ||
deprecated_tag_1.DeprecatedTag, | ||
deprecate_lazysizes_1.DeprecateLazysizes, | ||
img_width_and_height_1.ImgWidthAndHeight, | ||
@@ -66,10 +68,10 @@ json_syntax_error_1.JSONSyntaxError, | ||
undefined_object_1.UndefinedObject, | ||
unique_static_block_id_1.UniqueStaticBlockId, | ||
unknown_filter_1.UnknownFilter, | ||
unused_assign_1.UnusedAssign, | ||
valid_html_translation_1.ValidHTMLTranslation, | ||
valid_json_1.ValidJSON, | ||
valid_schema_1.ValidSchema, | ||
valid_json_1.ValidJSON, | ||
valid_static_block_type_1.ValidStaticBlockType, | ||
variable_name_1.VariableName, | ||
valid_static_block_type_1.ValidStaticBlockType, | ||
unique_static_block_id_1.UniqueStaticBlockId, | ||
]; | ||
@@ -76,0 +78,0 @@ /** |
@@ -6,2 +6,3 @@ "use strict"; | ||
const file_utils_1 = require("../../utils/file-utils"); | ||
const markup_1 = require("../../utils/markup"); | ||
exports.ValidStaticBlockType = { | ||
@@ -28,4 +29,3 @@ meta: { | ||
} | ||
const [blockType] = node.markup.split(','); | ||
if (blockType.replace(/["']/g, '') !== 'block') { | ||
if (!(0, markup_1.isContentForBlock)(node.markup)) { | ||
return; | ||
@@ -41,2 +41,3 @@ } | ||
if (!fileExists) { | ||
const [blockType] = node.markup.split(','); | ||
const nodeInSource = node.source.substring(node.position.start); | ||
@@ -43,0 +44,0 @@ const contentForBlockStartIndex = nodeInSource.indexOf(blockType); |
@@ -52,3 +52,5 @@ "use strict"; | ||
} | ||
const suggestion = formatTypes[context.settings.format].call(null, node.markup.name); | ||
const suggestion = formatTypes[context.settings.format] | ||
.call(null, node.markup.name) | ||
.replace(/(\d+)[-_](?=[a-z])/g, '$1'); | ||
return { | ||
@@ -55,0 +57,0 @@ valid: node.markup.name === suggestion, |
{ | ||
"name": "@shopify/theme-check-common", | ||
"version": "2.8.0", | ||
"version": "2.9.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -10,2 +10,3 @@ import { ConfigTarget, JSONCheckDefinition, LiquidCheckDefinition } from '../types'; | ||
import { CdnPreconnect } from './cdn-preconnect'; | ||
import { CaptureOnContentForBlock } from './capture-on-content-for-block'; | ||
import { ContentForHeaderModification } from './content-for-header-modification'; | ||
@@ -45,8 +46,9 @@ import { DeprecateBgsizes } from './deprecate-bgsizes'; | ||
AssetSizeJavaScript, | ||
CaptureOnContentForBlock, | ||
CdnPreconnect, | ||
ContentForHeaderModification, | ||
DeprecateBgsizes, | ||
DeprecateLazysizes, | ||
DeprecatedFilter, | ||
DeprecatedTag, | ||
DeprecateLazysizes, | ||
ImgWidthAndHeight, | ||
@@ -65,10 +67,10 @@ JSONSyntaxError, | ||
UndefinedObject, | ||
UniqueStaticBlockId, | ||
UnknownFilter, | ||
UnusedAssign, | ||
ValidHTMLTranslation, | ||
ValidJSON, | ||
ValidSchema, | ||
ValidJSON, | ||
ValidStaticBlockType, | ||
VariableName, | ||
ValidStaticBlockType, | ||
UniqueStaticBlockId, | ||
]; | ||
@@ -75,0 +77,0 @@ |
import { LiquidCheckDefinition, Severity, SourceCodeType } from '../../types'; | ||
import { doesFileExist } from '../../utils/file-utils'; | ||
import { isContentForBlock } from '../../utils/markup'; | ||
@@ -29,5 +30,3 @@ export const ValidStaticBlockType: LiquidCheckDefinition = { | ||
const [blockType] = node.markup.split(','); | ||
if (blockType.replace(/["']/g, '') !== 'block') { | ||
if (!isContentForBlock(node.markup)) { | ||
return; | ||
@@ -47,2 +46,3 @@ } | ||
if (!fileExists) { | ||
const [blockType] = node.markup.split(','); | ||
const nodeInSource = node.source.substring(node.position.start); | ||
@@ -49,0 +49,0 @@ const contentForBlockStartIndex = nodeInSource.indexOf(blockType); |
@@ -45,2 +45,19 @@ import { expect, describe, it } from 'vitest'; | ||
}); | ||
it('should report an error when a variable containing numbers uses wrong format', async () => { | ||
const sourceCode = `{% assign first_3_d_model = "value" %}`; | ||
const offenses = await runLiquidCheck(VariableName, sourceCode); | ||
expect(offenses).to.have.length(1); | ||
expect(offenses[0].message).to.equal("The variable 'first_3_d_model' uses wrong naming format"); | ||
}); | ||
it('should not report an error when a variable containing numbers is using correct format', async () => { | ||
const sourceCode = `{% assign first_3d_model = "value" %}`; | ||
const offenses = await runLiquidCheck(VariableName, sourceCode); | ||
expect(offenses).to.be.empty; | ||
}); | ||
}); |
@@ -65,6 +65,5 @@ import { | ||
const suggestion = formatTypes[context.settings.format as FormatTypes].call( | ||
null, | ||
node.markup.name, | ||
); | ||
const suggestion = formatTypes[context.settings.format as FormatTypes] | ||
.call(null, node.markup.name) | ||
.replace(/(\d+)[-_](?=[a-z])/g, '$1'); | ||
@@ -71,0 +70,0 @@ return { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
864427
346
15698