sindresorhus/eslint-plugin-unicorn

Rule proposal: Prevent common typos in comments

Closed

#949 opened on Dec 21, 2020

 (9 comments) (2 reactions) (0 assignees)JavaScript (468 forks)user submission
help wantednew rule

Repository metrics

Stars
 (5,022 stars)
PR merge metrics
 (Avg merge 1d 16h) (399 merged PRs in 30d)

Description

People often write node.js, NodeJS, etc, instead of Node.js. Would be nice to have a rule to detect such mistakes in code comments.

Just like the prevent-abbreviations rule, we could let users either add their own additions or completely replace the built-ins.

The rule format could be like this:

[
	{
		test: /\bnode\.?js\b/gi,
		value: 'Node.js'
	},
	{
		test: /\bStack\s?Overflow\b/gi,
		value: 'Stack Overflow'
	},
	{
		test: /\bjavascript\b/gi,
		value: 'JavaScript'
	},
	{
		test: [/\bmac\s?OS(?!\s?X)\b/gi, /(mac\s?)?OS\s?X/gi],
		value: 'macOS'
	},
	{
		test: /\bYou\s?Tube\b/gi,
		value: 'YouTube'
	},
	{
		test: /\bGit\s?Hub\b/gi,
		value: 'GitHub'
	}
];

Some more:

ios => iOS reddit => Reddit Gulp.js => Gulp gulp.js => Gulp Grunt.js => Grunt grunt.js => Grunt svg => SVG url => URL css => CSS html => HTML png => PNG jpg => JPG jpeg => JPEG NPM => npm Npm => npm bitcoin => Bitcoin Devops => DevOps Url => URL JQuery => jQuery IOS => iOS Typescript => TypeScript typescript => TypeScript

Opinionated ones: application => app applications => apps


Suggestions welcome for more.

Contributor guide