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 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..9d26936 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); }); @@ -53,5 +56,11 @@ 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', () => { + 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 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",