Skip to content

Commit c55a956

Browse files
authored
Docs: ensure rule doc titles match rule descriptions (#147)
* Start rule doc titles with a capital letter * Test to ensure rule doc titles include the description from rule.meta.docs.description
1 parent e825c56 commit c55a956

15 files changed

+24
-16
lines changed

docs/rules/meta-property-ordering.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# enforce ordering of meta properties in rule source (meta-property-ordering)
1+
# Enforce the order of meta properties (meta-property-ordering)
22

33
⚒️ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#-fix) can automatically fix some of the problems reported by this rule.
44

docs/rules/no-deprecated-context-methods.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallows usage of deprecated methods on rule context objects (no-deprecated-context-methods)
1+
# Disallow usage of deprecated methods on rule context objects (no-deprecated-context-methods)
22

33
⚒️ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#-fix) can automatically fix some of the problems reported by this rule.
44

docs/rules/no-deprecated-report-api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# disallow use of the deprecated context.report() API (no-deprecated-report-api)
1+
# Disallow use of the deprecated context.report() API (no-deprecated-report-api)
22

33
✔️ The `"extends": "plugin:eslint-plugin/recommended"` property in a configuration file enables this rule.
44

docs/rules/prefer-output-null.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Disallows invalid RuleTester test cases with the output the same as the code. (prefer-output-null)
1+
# Disallow invalid RuleTester test cases with the output the same as the code. (prefer-output-null)
22

33
⚒️ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#-fix) can automatically fix some of the problems reported by this rule.
44

docs/rules/prefer-placeholders.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# disallow template literals as report messages (prefer-placeholders)
1+
# Disallow template literals as report messages (prefer-placeholders)
22

33
Report messages in rules can have placeholders surrounded by curly brackets.
44

docs/rules/prefer-replace-text.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# prefer using replaceText instead of replaceTextRange. (prefer-replace-text)
1+
# Require using replaceText instead of replaceTextRange. (prefer-replace-text)
22

33
## Rule Details
44

docs/rules/report-message-format.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# enforce a consistent format for rule report messages (report-message-format)
1+
# Enforce a consistent format for rule report messages (report-message-format)
22

33
It is sometimes desirable to maintain consistent formatting for all report messages. For example, you might want to mandate that all report messages begin with a capital letter and end with a period.
44

docs/rules/require-meta-docs-description.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# require rules to implement a meta.docs.description property (require-meta-docs-description)
1+
# Require rules to implement a meta.docs.description property with the correct format (require-meta-docs-description)
22

33
Defining a clear and consistent description for each rule helps developers understand what they're used for.
44

docs/rules/require-meta-docs-url.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# require rules to implement a meta.docs.url property (require-meta-docs-url)
1+
# Require rules to implement a meta.docs.url property (require-meta-docs-url)
22

33
⚒️ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#-fix) can automatically fix some of the problems reported by this rule.
44

docs/rules/require-meta-fixable.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# require rules to implement a meta.fixable property (require-meta-fixable)
1+
# Require rules to implement a meta.fixable property (require-meta-fixable)
22

33
✔️ The `"extends": "plugin:eslint-plugin/recommended"` property in a configuration file enables this rule.
44

docs/rules/require-meta-has-suggestions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# require suggestable rules to implement a `meta.hasSuggestions` property (require-meta-has-suggestions)
1+
# Require suggestable rules to implement a `meta.hasSuggestions` property (require-meta-has-suggestions)
22

33
A suggestable ESLint rule should specify the `meta.hasSuggestions` property with a value of `true`. This makes it easier for both humans and tooling to tell whether a rule provides suggestions. [As of ESLint 8](https://eslint.org/blog/2021/06/whats-coming-in-eslint-8.0.0#rules-with-suggestions-now-require-the-metahassuggestions-property), an exception will be thrown if a suggestable rule is missing this property.
44

docs/rules/require-meta-schema.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# require rules to implement a meta.schema property (require-meta-schema)
1+
# Require rules to implement a meta.schema property (require-meta-schema)
22

33
⚒️ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#-fix) can automatically fix some of the problems reported by this rule.
44

5-
Defining a schema for each rule allows eslint to validate that configuration options are passed correctly. Even when there are no options for a rule, a schema should still be defined (as an empty array) so that eslint can validate that no data is passed to the rule.
5+
Defining a schema for each rule allows eslint to validate that configuration options are passed correctly. Even when there are no options for a rule, a schema should still be defined (as an empty array) so that eslint can validate that no data is mistakenly passed to the rule.
66

77
## Rule Details
88

docs/rules/require-meta-type.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# require rules to implement a meta.type property (require-meta-type)
1+
# Require rules to implement a meta.type property (require-meta-type)
22

33
ESLint v5.9.0 introduces a new `--fix-type` option for the command line interface. This option allows users to filter the type of fixes applied when using `--fix`.
44

docs/rules/test-case-property-ordering.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# enforce ordering of keys in test cases (test-case-property-ordering)
1+
# Require the properties of a test case to be placed in a consistent order (test-case-property-ordering)
22

33
⚒️ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#-fix) can automatically fix some of the problems reported by this rule.
44

tests/lib/rule-setup.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ const MESSAGES = {
1616
hasSuggestions: '💡 Some problems reported by this rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).',
1717
};
1818

19+
/**
20+
* @param {string} string - to operate on
21+
* @returns the string with a capitalized first letter
22+
*/
23+
function capitalizeFirstLetter (string) {
24+
return string.charAt(0).toUpperCase() + string.slice(1);
25+
}
26+
1927
describe('rule setup is correct', () => {
2028
it('should have a list of exported rules and rules directory that match', () => {
2129
const filePath = path.join(__dirname, '..', 'lib', 'rules');
@@ -70,7 +78,7 @@ describe('rule setup is correct', () => {
7078
describe(ruleName, () => {
7179
it('should have the right contents (title, notices, etc)', () => {
7280
// Title
73-
assert.ok(lines[0].endsWith(`(${ruleName})`), 'first line ends with rule name');
81+
assert.strictEqual(lines[0], `# ${capitalizeFirstLetter(rule.meta.docs.description)} (${ruleName})`, 'first line has rule description and name');
7482
assert.strictEqual(lines[1], '', 'second line is blank');
7583

7684
// Rule Details

0 commit comments

Comments
 (0)