From e440e5fb7d0c63f8befc9b1a8489356f0822ab0a Mon Sep 17 00:00:00 2001 From: Jens Oliver Meiert Date: Mon, 19 Aug 2024 12:06:00 +0200 Subject: [PATCH 1/4] feat: add support for Twig [and Nunjucks] files in ObsoHTML Included `.twig` file detection and added tests for obsolete elements within Twig templates. This enhances the tool's capability to handle and inspect more file types. Signed-off-by: Jens Oliver Meiert --- bin/obsohtml.js | 2 +- bin/obsohtml.test.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/obsohtml.js b/bin/obsohtml.js index 9deb731..9df74bb 100755 --- a/bin/obsohtml.js +++ b/bin/obsohtml.js @@ -78,7 +78,7 @@ function walkDirectory(directory, verbose) { if (file !== 'node_modules') { walkDirectory(fullPath, verbose); } - } else if (fullPath.endsWith('.html') || fullPath.endsWith('.htm') || fullPath.endsWith('.php') || fullPath.endsWith('.js') || fullPath.endsWith('.ts')) { + } else if (fullPath.endsWith('.html') || fullPath.endsWith('.htm') || fullPath.endsWith('.php') || fullPath.endsWith('.njk') || fullPath.endsWith('.twig') || fullPath.endsWith('.js') || fullPath.endsWith('.ts')) { findObsolete(fullPath); } } catch (err) { diff --git a/bin/obsohtml.test.js b/bin/obsohtml.test.js index 94479d6..2d20493 100644 --- a/bin/obsohtml.test.js +++ b/bin/obsohtml.test.js @@ -7,6 +7,7 @@ describe('ObsoHTML', () => { const tempFile = path.join(tempDir, 'test.html'); const tempFileWithAttributes = path.join(tempDir, 'test_with_attributes.html'); const tempFileWithMinimizedAttributes = path.join(tempDir, 'test_with_minimized_attributes.html'); + const tempTwigFile = path.join(tempDir, 'test.twig'); beforeAll(() => { // Create a temporary directory and files @@ -16,6 +17,7 @@ describe('ObsoHTML', () => { fs.writeFileSync(tempFile, 'Test
Test
'); fs.writeFileSync(tempFileWithAttributes, 'TestTest'); fs.writeFileSync(tempFileWithMinimizedAttributes, 'Test
'); + fs.writeFileSync(tempTwigFile, 'Test'); }); afterAll(() => { @@ -23,6 +25,7 @@ describe('ObsoHTML', () => { fs.unlinkSync(tempFile); fs.unlinkSync(tempFileWithAttributes); fs.unlinkSync(tempFileWithMinimizedAttributes); + fs.unlinkSync(tempTwigFile); fs.rmdirSync(tempDir); }); @@ -54,4 +57,9 @@ describe('ObsoHTML', () => { const result = spawnSync('node', ['bin/obsohtml.js', '-f', tempDir], { encoding: 'utf-8' }); expect(result.stdout).toContain("Found obsolete attribute 'noshade'"); }); + + test('Detect obsolete elements in Twig file', () => { + const result = spawnSync('node', ['bin/obsohtml.js', '-f', tempDir], { encoding: 'utf-8' }); + expect(result.stdout).toContain("Found obsolete element 'isindex'"); + }); }); \ No newline at end of file From 460061fae838c58bcb145ccfe0b2f6f2ef48c982 Mon Sep 17 00:00:00 2001 From: Jens Oliver Meiert Date: Mon, 19 Aug 2024 12:06:08 +0200 Subject: [PATCH 2/4] feat: add support for Nunjucks and Twig in ObsoHTML MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated the README to reflect the addition of Nunjucks and Twig file scanning. This enhances the script’s capability to identify deprecated HTML within these templating languages. Signed-off-by: Jens Oliver Meiert --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f32a41a..a897cc2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ObsoHTML, the Obsolete HTML Checker -ObsoHTML is a Node.js script designed to scan HTML, PHP, JavaScript, and TypeScript files for obsolete or proprietary HTML attributes and elements (in scripts, it would catch JSX syntax). It helps you identify and update deprecated HTML code to be more sure to use web standards. +ObsoHTML is a Node.js script designed to scan HTML, PHP, Nunjucks, Twig, JavaScript, and TypeScript files for obsolete or proprietary HTML attributes and elements (in scripts, it would catch JSX syntax). It helps you identify and update deprecated HTML code to be more sure to use web standards. ## Usage From 4dc67612ccfaa22168b248216faf9760e268ea3f Mon Sep 17 00:00:00 2001 From: Jens Oliver Meiert Date: Mon, 19 Aug 2024 12:06:14 +0200 Subject: [PATCH 3/4] feat: bump version to 1.6.0 Update the package and lock file versions from 1.5.0 to 1.6.0. This change ensures alignment across the project files and prepares for the next release. Signed-off-by: Jens Oliver Meiert --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 07623b4..3d5253c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@j9t/obsohtml", - "version": "1.5.0", + "version": "1.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@j9t/obsohtml", - "version": "1.5.0", + "version": "1.6.0", "license": "CC-BY-SA-4.0", "dependencies": { "chalk": "^5.3.0", diff --git a/package.json b/package.json index 1c4882d..8f3200b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@j9t/obsohtml", "description": "Find obsolete HTML elements and attributes", "author": "Jens Oliver Meiert", - "version": "1.5.0", + "version": "1.6.0", "license": "CC-BY-SA-4.0", "repository": { "type": "git", From 511121b4f2e89562614a87446d80bc1d1160ff36 Mon Sep 17 00:00:00 2001 From: Jens Oliver Meiert Date: Mon, 19 Aug 2024 12:07:34 +0200 Subject: [PATCH 4/4] feat: enhance tests for obsolete attributes Added a check to ensure that the 'nowrap' attribute is not incorrectly flagged as obsolete in test cases. This increases the reliability of the ObsoHTML script and ensures more accurate detection of obsolete HTML attributes. Signed-off-by: Jens Oliver Meiert --- bin/obsohtml.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/obsohtml.test.js b/bin/obsohtml.test.js index 2d20493..9d26936 100644 --- a/bin/obsohtml.test.js +++ b/bin/obsohtml.test.js @@ -56,6 +56,7 @@ describe('ObsoHTML', () => { test('Detect obsolete minimized attributes', () => { const result = spawnSync('node', ['bin/obsohtml.js', '-f', tempDir], { encoding: 'utf-8' }); expect(result.stdout).toContain("Found obsolete attribute 'noshade'"); + expect(result.stdout).not.toContain("Found obsolete attribute 'nowrap'"); }); test('Detect obsolete elements in Twig file', () => {