Skip to content

Commit

Permalink
add meta.type ("problem" or "suggestion") for use by `eslint --fix-…
Browse files Browse the repository at this point in the history
…type` or formatters and add missing "fixable: code" to `no-skipped-tests`
  • Loading branch information
brettz9 committed Apr 23, 2020
1 parent b2d8c9e commit 3cbfd77
Show file tree
Hide file tree
Showing 22 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/rules/no-nested-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ it('something', function () {
});
});
```
Something like this could be easily happen by accident where the outer test case was actually meant to be a suite instead of a test.
Something like this could easily happen by accident where the outer test case was actually meant to be a suite instead of a test.
This rule reports such nested test cases in order to prevent problems where those nested tests are skipped silently.

## Rule Details
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/handle-done-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const find = require('ramda/src/find');
const astUtils = require('../util/ast');

module.exports = {
meta: {
type: 'problem'
},
create(context) {
function isAsyncFunction(functionExpression) {
return functionExpression.params.length === 1;
Expand Down
1 change: 1 addition & 0 deletions lib/rules/max-top-level-suites.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const defaultSuiteLimit = 1;

module.exports = {
meta: {
type: 'suggestion',
schema: [
{
type: 'object',
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-async-describe.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const { additionalSuiteNames } = require('../util/settings');

module.exports = {
meta: {
type: 'problem',
fixable: 'code'
},
create(context) {
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-exclusive-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const { getAdditionalTestFunctions } = require('../util/settings');
const astUtils = require('../util/ast');

module.exports = {
meta: {
type: 'problem'
},
create(context) {
let mochaTestFunctions = [
'it',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-global-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
const astUtils = require('../util/ast');

module.exports = {
meta: {
type: 'suggestion'
},
create(context) {
function isGlobalScope(scope) {
return scope.type === 'global' || scope.type === 'module';
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-hooks-for-single-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function newDescribeLayer(describeNode) {

module.exports = {
meta: {
type: 'suggestion',
schema: [
{
type: 'object',
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const astUtil = require('../util/ast');

module.exports = {
meta: {
type: 'suggestion',
schema: [
{
type: 'object',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-identical-title.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ function isFirstArgLiteral(node) {
}

module.exports = {
meta: {
type: 'suggestion'
},
create(context) {
const titleLayers = [ newLayer() ];
const settings = context.settings;
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-mocha-arrows.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const astUtils = require('../util/ast');

module.exports = {
meta: {
type: 'suggestion',
fixable: 'code'
},
create(context) {
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-nested-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const astUtils = require('../util/ast');
const { additionalSuiteNames } = require('../util/settings');

module.exports = {
meta: {
type: 'problem'
},
create(context) {
const settings = context.settings;
let testNestingLevel = 0;
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-pending-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
const astUtils = require('../util/ast');

module.exports = {
meta: {
type: 'suggestion'
},
create(context) {
function isPendingMochaTest(node) {
return astUtils.isTestCase(node) &&
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-return-and-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ function reportIfFunctionWithBlock(context, node, doneName) {
}

module.exports = {
meta: {
type: 'problem'
},
create(context) {
function check(node) {
if (node.params.length === 0 || !astUtils.hasParentMochaFunctionCall(node)) {
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-return-from-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ function reportIfFunctionWithBlock(context, node) {
}

module.exports = {
meta: {
type: 'suggestion'
},
create(context) {
function check(node) {
if (!node.async || !astUtils.hasParentMochaFunctionCall(node)) {
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-setup-in-describe.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const DESCRIBE = 2;
const PURE = 3;

module.exports = {
meta: {
type: 'suggestion'
},
create(context) {
const nesting = [];
const settings = context.settings;
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-sibling-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ function newDescribeLayer(describeNode) {
}

module.exports = {
meta: {
type: 'suggestion'
},
create(context) {
const isUsed = [];
const settings = context.settings;
Expand Down
4 changes: 4 additions & 0 deletions lib/rules/no-skipped-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ function isCallToMochaXFunction(callee) {
}

module.exports = {
meta: {
fixable: 'code',
type: 'problem'
},
create(context) {
const settings = context.settings;
const additionalTestFunctions = getAdditionalTestFunctions(settings);
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-synchronous-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function doesReturnPromise(functionExpression) {

module.exports = {
meta: {
type: 'suggestion',
schema: [
{
type: 'object',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-top-level-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const astUtil = require('../util/ast');
const { additionalSuiteNames } = require('../util/settings');

module.exports = {
meta: {
type: 'problem'
},
create(context) {
const settings = context.settings;
const testSuiteStack = [];
Expand Down
2 changes: 2 additions & 0 deletions lib/rules/prefer-arrow-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ function hasDuplicateParams(paramsList) {

module.exports = {
meta: {
type: 'suggestion',

docs: {
description: 'require using arrow functions for callbacks',
category: 'ECMAScript 6',
Expand Down
1 change: 1 addition & 0 deletions lib/rules/valid-suite-description.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const messageSchema = {

module.exports = {
meta: {
type: 'suggestion',
schema: [
{
oneOf: [ patternSchema, {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/valid-test-description.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const messageSchema = {

module.exports = {
meta: {
type: 'suggestion',
schema: [
{
oneOf: [ patternSchema, {
Expand Down

0 comments on commit 3cbfd77

Please sign in to comment.