-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom validator for comma errors #141
- Loading branch information
1 parent
f19d221
commit 72d3793
Showing
7 changed files
with
59 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Custom script to validate CSS syntax by Rolle | ||
// https://github.com/stylelint/stylelint/issues/3053 | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const cssFiles = fs.readdirSync('.').filter(file => file.endsWith('.css')); | ||
let errorFound = false; | ||
|
||
cssFiles.forEach(file => { | ||
const lines = fs.readFileSync(file, 'utf8').split('\n'); | ||
lines.forEach((line, index) => { | ||
// Check if the line ends with a comma and the next line starts with "{" | ||
const trimmedLine = line.trim(); | ||
const nextLine = lines[index + 1] ? lines[index + 1].trim() : ''; | ||
if (trimmedLine.endsWith(',') && nextLine.startsWith('{')) { | ||
errorFound = true; | ||
console.error(`❌ Trailing comma error in file ${file} on line ${index + 1}`); | ||
} | ||
}); | ||
}); | ||
|
||
if (!errorFound) { | ||
console.log('✅ No trailing comma errors found. CSS validation passed.'); | ||
process.exit(0); | ||
} else { | ||
console.error('❌ CSS validation failed due to trailing commas.'); | ||
process.exit(1); | ||
} |