Back to articles
Build a Content Quality Checker in 10 Lines of TypeScript

Build a Content Quality Checker in 10 Lines of TypeScript

via Dev.to Tutorialckmtools

import { readability , statistics , sentiment } from ' textlens ' ; const text = await Bun . file ( ' article.md ' ). text (); // or fs.readFileSync const stats = statistics ( text ); const scores = readability ( text ); const mood = sentiment ( text ); const pass = scores . consensusGrade <= 10 && stats . avgSentenceLength < 25 && mood . label !== ' negative ' ; console . log ( pass ? ' PASS ' : ' FAIL ' , `Grade ${ scores . consensusGrade } ` ); That's a working content quality gate. It reads a file, checks the grade level, sentence length, and sentiment — then passes or fails. You can run it locally, in CI, or as a pre-commit hook. Here's how each piece works. Why grade level matters The average American reads at an 8th-grade level. If your blog post scores at grade 14, you've lost most of your audience before paragraph two. Grade level isn't a judgment on your readers. It's a measure of cognitive load. Short sentences and common words reduce friction. The NYT writes at grade 6-8. S

Continue reading on Dev.to Tutorial

Opens in a new tab

Read Full Article
0 views

Related Articles