From 378985f4cdc4dfe1dedf4ab130f4df5d160a4991 Mon Sep 17 00:00:00 2001
From: freearhey <7253922+freearhey@users.noreply.github.com>
Date: Sat, 8 Feb 2025 07:05:10 +0300
Subject: [PATCH 1/2] Update tests
---
.../channels-lint/single_quotes.channels.xml | 4 +++
.../input/channels-lint/valid.channels.xml | 4 +++
tests/commands/channels/lint.test.ts | 27 +++++++++++++++++++
3 files changed, 35 insertions(+)
create mode 100644 tests/__data__/input/channels-lint/single_quotes.channels.xml
create mode 100644 tests/__data__/input/channels-lint/valid.channels.xml
diff --git a/tests/__data__/input/channels-lint/single_quotes.channels.xml b/tests/__data__/input/channels-lint/single_quotes.channels.xml
new file mode 100644
index 000000000..a95422cd8
--- /dev/null
+++ b/tests/__data__/input/channels-lint/single_quotes.channels.xml
@@ -0,0 +1,4 @@
+
+
+ Bravo 2
+
\ No newline at end of file
diff --git a/tests/__data__/input/channels-lint/valid.channels.xml b/tests/__data__/input/channels-lint/valid.channels.xml
new file mode 100644
index 000000000..8c499450a
--- /dev/null
+++ b/tests/__data__/input/channels-lint/valid.channels.xml
@@ -0,0 +1,4 @@
+
+
+ Bravo's
+
\ No newline at end of file
diff --git a/tests/commands/channels/lint.test.ts b/tests/commands/channels/lint.test.ts
index 2ba65d808..501b69890 100644
--- a/tests/commands/channels/lint.test.ts
+++ b/tests/commands/channels/lint.test.ts
@@ -53,4 +53,31 @@ describe('channels:lint', () => {
expect((error as ExecError).stdout).toContain('2 error(s)')
}
})
+
+ it('will show a message if the file contains single quotes', () => {
+ try {
+ const cmd =
+ 'npm run channels:lint --- tests/__data__/input/channels-lint/single_quotes.channels.xml'
+ const stdout = execSync(cmd, { encoding: 'utf8' })
+ if (process.env.DEBUG === 'true') console.log(cmd, stdout)
+ process.exit(1)
+ } catch (error) {
+ expect((error as ExecError).status).toBe(1)
+ expect((error as ExecError).stdout).toContain('single_quotes.channels.xml')
+ expect((error as ExecError).stdout).toContain(
+ '1:14 Single quotes cannot be used in attributes'
+ )
+ }
+ })
+
+ it('does not display errors if there are none', () => {
+ try {
+ const cmd = 'npm run channels:lint --- tests/__data__/input/channels-lint/valid.channels.xml'
+ const stdout = execSync(cmd, { encoding: 'utf8' })
+ if (process.env.DEBUG === 'true') console.log(cmd, stdout)
+ } catch (error) {
+ if (process.env.DEBUG === 'true') console.log((error as ExecError).stdout)
+ process.exit(1)
+ }
+ })
})
From b0feab33ec360895cc3c067ed6d4aa9079491d8b Mon Sep 17 00:00:00 2001
From: freearhey <7253922+freearhey@users.noreply.github.com>
Date: Sat, 8 Feb 2025 07:05:35 +0300
Subject: [PATCH 2/2] Update lint.mts
---
scripts/commands/channels/lint.mts | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/scripts/commands/channels/lint.mts b/scripts/commands/channels/lint.mts
index ad27fcb6a..6dd12108c 100644
--- a/scripts/commands/channels/lint.mts
+++ b/scripts/commands/channels/lint.mts
@@ -76,6 +76,18 @@ async function main() {
localErrors = localErrors.concat(error.details)
}
+ xml.split('\n').forEach((line: string, lineIndex: number) => {
+ const found = line.match(/='/)
+ if (found) {
+ const colIndex = found.index || 0
+ localErrors.push({
+ line: lineIndex + 1,
+ col: colIndex + 1,
+ message: 'Single quotes cannot be used in attributes'
+ })
+ }
+ })
+
if (localErrors.length) {
console.log(`\n${chalk.underline(filepath)}`)
localErrors.forEach((error: ErrorDetail) => {