Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rule documentation URLs and schemas (and eslint-plugin-eslint-plugin) #294

Merged
merged 1 commit into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"extends": "holidaycheck/es2015",
"plugins": [ "node", "unicorn" ],
"extends": [
"holidaycheck/es2015",
"plugin:eslint-plugin/recommended"
],
"plugins": [
"eslint-plugin",
"node",
"unicorn"
],

"env": {
"node": true
Expand All @@ -12,6 +19,11 @@
},

"rules": {
"eslint-plugin/require-meta-docs-url": [
"error",
{ "pattern": "https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/{{name}}.md" }
],

"node/no-unsupported-features": "error",
"unicorn/prefer-includes": "error"
},
Expand Down
10 changes: 7 additions & 3 deletions lib/rules/handle-done-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Enforces handling of callbacks for async tests'
description: 'Enforces handling of callbacks for async tests',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/handle-done-callback.md'
},
schema: [
{
Expand Down Expand Up @@ -38,7 +39,7 @@ module.exports = {
}

function isReferenceHandled(reference) {
const parent = context.getNodeByRangeIndex(reference.identifier.range[0]).parent;
const parent = context.getSourceCode().getNodeByRangeIndex(reference.identifier.range[0]).parent;

return parent.type === 'CallExpression';
}
Expand All @@ -54,7 +55,10 @@ module.exports = {
const callbackVariable = findParamInScope(callbackName, scope);

if (callbackVariable && !hasHandledReferences(callbackVariable.references)) {
context.report(callback, 'Expected "{{name}}" callback to be handled.', { name: callbackName });
context.report({
node: callback,
message: 'Expected "{{name}}" callback to be handled.', data: { name: callbackName }
});
}
}

Expand Down
3 changes: 2 additions & 1 deletion lib/rules/max-top-level-suites.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'Limit the number of top-level suites in a single file'
description: 'Limit the number of top-level suites in a single file',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/max-top-level-suites.md'
},
schema: [
{
Expand Down
6 changes: 4 additions & 2 deletions lib/rules/no-async-describe.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Disallow async functions passed to describe'
description: 'Disallow async functions passed to describe',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-async-describe.md'
},
fixable: 'code'
fixable: 'code',
schema: []
},
create(context) {
const astUtils = createAstUtils(context.settings);
Expand Down
6 changes: 4 additions & 2 deletions lib/rules/no-exclusive-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Disallow exclusive tests'
}
description: 'Disallow exclusive tests',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-exclusive-tests.md'
},
schema: []
},
create(context) {
const astUtils = createAstUtils(context.settings);
Expand Down
6 changes: 4 additions & 2 deletions lib/rules/no-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ const createAstUtils = require('../util/ast');
module.exports = {
meta: {
docs: {
description: 'Disallow exports from test files'
description: 'Disallow exports from test files',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-exports.md'
},
messages: {
unexpectedExport: 'Unexpected export from a test file'
},
type: 'suggestion'
type: 'suggestion',
schema: []
},
create(context) {
const astUtils = createAstUtils(context.settings);
Expand Down
8 changes: 5 additions & 3 deletions lib/rules/no-global-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'Disallow global tests'
}
description: 'Disallow global tests',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-global-tests.md'
},
schema: []
},
create(context) {
const astUtils = createAstUtils(context.settings);
Expand All @@ -22,7 +24,7 @@ module.exports = {
const scope = context.getScope();

if (astUtils.isTestCase(node) && isGlobalScope(scope)) {
context.report(callee, 'Unexpected global mocha test.');
context.report({ node: callee, message: 'Unexpected global mocha test.' });
}
}
};
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/no-hooks-for-single-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'Disallow hooks for a single test or test suite'
description: 'Disallow hooks for a single test or test suite',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-hooks-for-single-case.md'
},
schema: [
{
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/no-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'Disallow hooks'
description: 'Disallow hooks',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-hooks.md'
},
schema: [
{
Expand Down
6 changes: 4 additions & 2 deletions lib/rules/no-identical-title.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'Disallow identical titles'
}
description: 'Disallow identical titles',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-identical-title.md'
},
schema: []
},
create(context) {
const astUtils = createAstUtils(context.settings);
Expand Down
6 changes: 4 additions & 2 deletions lib/rules/no-mocha-arrows.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ module.exports = {
type: 'suggestion',
docs: {
description:
'Disallow arrow functions as arguments to mocha functions'
'Disallow arrow functions as arguments to mocha functions',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-mocha-arrows.md'
},
fixable: 'code'
fixable: 'code',
schema: []
},
create(context) {
const astUtils = createAstUtils(context.settings);
Expand Down
6 changes: 4 additions & 2 deletions lib/rules/no-nested-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Disallow tests to be nested within other tests '
}
description: 'Disallow tests to be nested within other tests ',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-nested-tests.md'
},
schema: []
},
create(context) {
const astUtils = createAstUtils(context.settings);
Expand Down
6 changes: 4 additions & 2 deletions lib/rules/no-pending-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'Disallow pending tests'
}
description: 'Disallow pending tests',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-pending-tests.md'
},
schema: []
},
create(context) {
const astUtils = createAstUtils(context.settings);
Expand Down
6 changes: 4 additions & 2 deletions lib/rules/no-return-and-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Disallow returning in a test or hook function that uses a callback'
}
description: 'Disallow returning in a test or hook function that uses a callback',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-return-and-callback.md'
},
schema: []
},
create(context) {
const astUtils = createAstUtils(context.settings);
Expand Down
6 changes: 4 additions & 2 deletions lib/rules/no-return-from-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'Disallow returning from an async test or hook'
}
description: 'Disallow returning from an async test or hook',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-return-from-async.md'
},
schema: []
},
create(context) {
const astUtils = createAstUtils(context.settings);
Expand Down
6 changes: 4 additions & 2 deletions lib/rules/no-setup-in-describe.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'Disallow setup in describe blocks'
}
description: 'Disallow setup in describe blocks',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-setup-in-describe.md'
},
schema: []
},
create(context) {
const nesting = [];
Expand Down
6 changes: 4 additions & 2 deletions lib/rules/no-sibling-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'Disallow duplicate uses of a hook at the same level inside a describe'
}
description: 'Disallow duplicate uses of a hook at the same level inside a describe',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-sibling-hooks.md'
},
schema: []
},
create(context) {
const isUsed = [];
Expand Down
6 changes: 4 additions & 2 deletions lib/rules/no-skipped-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ const createAstUtils = require('../util/ast');
module.exports = {
meta: {
docs: {
description: 'Disallow skipped tests'
description: 'Disallow skipped tests',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-skipped-tests.md'
},
type: 'problem'
type: 'problem',
schema: []
},
create(context) {
const astUtils = createAstUtils(context.settings);
Expand Down
5 changes: 3 additions & 2 deletions lib/rules/no-synchronous-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'Disallow synchronous tests'
description: 'Disallow synchronous tests',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-synchronous-tests.md'
},
schema: [
{
Expand Down Expand Up @@ -92,7 +93,7 @@ module.exports = {
const isAsyncTest = testAsyncMethods.includes(true);

if (!isAsyncTest) {
context.report(node, 'Unexpected synchronous test.');
context.report({ node, message: 'Unexpected synchronous test.' });
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions lib/rules/no-top-level-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Disallow top-level hooks'
}
description: 'Disallow top-level hooks',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-top-level-hooks.md'
},
schema: []
},
create(context) {
const astUtils = createAstUtils(context.settings);
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/prefer-arrow-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ module.exports = {
description: 'Require using arrow functions for callbacks',
category: 'ECMAScript 6',
recommended: false,
url: 'https://eslint.org/docs/rules/prefer-arrow-callback'
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/prefer-arrow-callback.md'
},

schema: [
Expand Down
5 changes: 3 additions & 2 deletions lib/rules/valid-suite-description.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'Match suite descriptions against a pre-configured regular expression'
description: 'Match suite descriptions against a pre-configured regular expression',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/valid-suite-description.md'
},
schema: [
{
Expand Down Expand Up @@ -104,7 +105,7 @@ module.exports = {

if (isSuite(node)) {
if (!hasValidOrNoSuiteDescription(node)) {
context.report(node, message || `Invalid "${ callee.name }()" description found.`);
context.report({ node, message: message || `Invalid "${ callee.name }()" description found.` });
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions lib/rules/valid-test-description.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'Match test descriptions against a pre-configured regular expression'
description: 'Match test descriptions against a pre-configured regular expression',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/valid-test-description.md'
},
schema: [
{
Expand Down Expand Up @@ -103,7 +104,7 @@ module.exports = {

if (isTest(node)) {
if (!hasValidOrNoTestDescription(node)) {
context.report(node, message || `Invalid "${ callee.name }()" description found.`);
context.report({ node, message: message || `Invalid "${ callee.name }()" description found.` });
}
}
}
Expand Down
Loading