Skip to content

Commit 17fd916

Browse files
committed
feat: capitalize default pattern of require-meta-docs-description rule
1 parent dd9df61 commit 17fd916

31 files changed

+284
-42
lines changed

eslint.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export default tseslint.config([
4242
'@eslint-community/eslint-comments/no-unused-disable': 'error',
4343
'@eslint-community/eslint-comments/require-description': 'error',
4444

45+
'unicorn/expiring-todo-comments': 'off',
4546
'unicorn/consistent-function-scoping': 'off',
4647
'unicorn/no-array-callback-reference': 'off',
4748
'unicorn/no-array-for-each': 'off',

lib/rules/consistent-output.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const rule: Rule.RuleModule = {
1717
type: 'suggestion',
1818
docs: {
1919
description:
20-
'enforce consistent use of `output` assertions in rule tests',
20+
'Enforce consistent use of `output` assertions in rule tests',
2121
category: 'Tests',
2222
recommended: false,
2323
url: 'https://github.com/eslint-community/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/consistent-output.md',

lib/rules/fixer-return.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const rule: Rule.RuleModule = {
3636
meta: {
3737
type: 'problem',
3838
docs: {
39-
description: 'require fixer functions to return a fix',
39+
description: 'Require fixer functions to return a fix',
4040
category: 'Rules',
4141
recommended: true,
4242
url: 'https://github.com/eslint-community/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/fixer-return.md',

lib/rules/meta-property-ordering.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const rule: Rule.RuleModule = {
2727
meta: {
2828
type: 'suggestion',
2929
docs: {
30-
description: 'enforce the order of meta properties',
30+
description: 'Enforce the order of meta properties',
3131
category: 'Rules',
3232
recommended: false,
3333
url: 'https://github.com/eslint-community/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/meta-property-ordering.md',

lib/rules/no-deprecated-context-methods.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const rule: Rule.RuleModule = {
3838
type: 'suggestion',
3939
docs: {
4040
description:
41-
'disallow usage of deprecated methods on rule context objects',
41+
'Disallow usage of deprecated methods on rule context objects',
4242
category: 'Rules',
4343
recommended: true,
4444
url: 'https://github.com/eslint-community/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/no-deprecated-context-methods.md',

lib/rules/no-deprecated-report-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const rule: Rule.RuleModule = {
1515
type: 'suggestion',
1616
docs: {
1717
description:
18-
'disallow the version of `context.report()` with multiple arguments',
18+
'Disallow the version of `context.report()` with multiple arguments',
1919
category: 'Rules',
2020
recommended: true,
2121
url: 'https://github.com/eslint-community/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/no-deprecated-report-api.md',

lib/rules/no-identical-tests.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/**
2+
* @fileoverview disallow identical tests
3+
* @author 薛定谔的猫<[email protected]>
4+
*/
5+
6+
'use strict';
7+
8+
const utils = require('../utils');
9+
10+
// ------------------------------------------------------------------------------
11+
// Rule Definition
12+
// ------------------------------------------------------------------------------
13+
14+
/** @type {import('eslint').Rule.RuleModule} */
15+
module.exports = {
16+
meta: {
17+
type: 'problem',
18+
docs: {
19+
description: 'Disallow identical tests',
20+
category: 'Tests',
21+
recommended: true,
22+
url: 'https://github.com/eslint-community/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/no-identical-tests.md',
23+
},
24+
fixable: 'code',
25+
schema: [],
26+
messages: {
27+
identical: 'This test case is identical to another case.',
28+
},
29+
},
30+
31+
create(context) {
32+
// ----------------------------------------------------------------------
33+
// Public
34+
// ----------------------------------------------------------------------
35+
const sourceCode = context.sourceCode || context.getSourceCode(); // TODO: just use context.sourceCode when dropping eslint < v9
36+
37+
// ----------------------------------------------------------------------
38+
// Helpers
39+
// ----------------------------------------------------------------------
40+
/**
41+
* Create a unique cache key
42+
* @param {object} test
43+
* @returns {string}
44+
*/
45+
function toKey(test) {
46+
if (test.type !== 'ObjectExpression') {
47+
return JSON.stringify([test.type, sourceCode.getText(test)]);
48+
}
49+
return JSON.stringify([
50+
test.type,
51+
...test.properties.map((p) => sourceCode.getText(p)).sort(),
52+
]);
53+
}
54+
55+
return {
56+
Program(ast) {
57+
utils.getTestInfo(context, ast).forEach((testRun) => {
58+
[testRun.valid, testRun.invalid].forEach((tests) => {
59+
const cache = new Set();
60+
tests.forEach((test) => {
61+
const key = toKey(test);
62+
if (cache.has(key)) {
63+
context.report({
64+
node: test,
65+
messageId: 'identical',
66+
fix(fixer) {
67+
const start = sourceCode.getTokenBefore(test);
68+
const end = sourceCode.getTokenAfter(test);
69+
return fixer.removeRange(
70+
// should remove test's trailing comma
71+
[
72+
start.range[1],
73+
end.value === ',' ? end.range[1] : test.range[1],
74+
],
75+
);
76+
},
77+
});
78+
} else {
79+
cache.add(key);
80+
}
81+
});
82+
});
83+
});
84+
},
85+
};
86+
},
87+
};

lib/rules/no-missing-message-ids.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const rule: Rule.RuleModule = {
1919
type: 'problem',
2020
docs: {
2121
description:
22-
'disallow `messageId`s that are missing from `meta.messages`',
22+
'Disallow `messageId`s that are missing from `meta.messages`',
2323
category: 'Rules',
2424
recommended: true,
2525
url: 'https://github.com/eslint-community/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/no-missing-message-ids.md',

lib/rules/no-missing-placeholders.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const rule: Rule.RuleModule = {
2323
meta: {
2424
type: 'problem',
2525
docs: {
26-
description: 'disallow missing placeholders in rule report messages',
26+
description: 'Disallow missing placeholders in rule report messages',
2727
category: 'Rules',
2828
recommended: true,
2929
url: 'https://github.com/eslint-community/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/no-missing-placeholders.md',

lib/rules/no-only-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const rule: Rule.RuleModule = {
1111
meta: {
1212
type: 'problem',
1313
docs: {
14-
description: 'disallow the test case property `only`',
14+
description: 'Disallow the test case property `only`',
1515
category: 'Tests',
1616
recommended: true,
1717
url: 'https://github.com/eslint-community/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/no-only-tests.md',

0 commit comments

Comments
 (0)