Skip to content

Declare a JSON schema in 'default' for each rule #222

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

Closed
wants to merge 4 commits into from
Closed
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
4 changes: 3 additions & 1 deletion rules/assertion-arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,16 @@ const schema = [{
enum: [
'always',
'never'
]
],
default: null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined would be better

}
}
}];

module.exports = {
create,
meta: {
type: 'problem',
docs: {
url: util.getDocsUrl(__filename)
},
Expand Down
4 changes: 3 additions & 1 deletion rules/assertion-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ const schema = [{
enum: [
'always',
'never'
]
],
default: 'always'
}];

module.exports = {
create,
meta: {
type: 'suggestion',
docs: {
url: util.getDocsUrl(__filename, '4211212daf1bfcfff3ebc5d4efdc4ba1a87acbf1')
},
Expand Down
16 changes: 10 additions & 6 deletions rules/max-asserts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ const createAvaRule = require('../create-ava-rule');

const notAssertionMethods = ['plan', 'end'];

const MAX_NUMBER_ASSERTIONS_BY_DEFAULT = 5;

const create = context => {
const ava = createAvaRule();
const maxAssertions = context.options[0] || 5;
const maxAssertions = context.options[0] || MAX_NUMBER_ASSERTIONS_BY_DEFAULT;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you defining the default both here and in the schema?

let assertionCount = 0;
let nodeToReport = null;

Expand Down Expand Up @@ -55,16 +57,18 @@ const create = context => {
});
};

const schema = [{
type: 'integer'
}];

module.exports = {
create,
meta: {
type: 'suggestion',
docs: {
url: util.getDocsUrl(__filename)
},
schema
schema: [{
title: 'Maximum number of assertions for each test',
type: 'integer',
minimum: 0,
default: MAX_NUMBER_ASSERTIONS_BY_DEFAULT
}]
}
};
1 change: 1 addition & 0 deletions rules/no-async-fn-without-await.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const create = context => {
module.exports = {
create,
meta: {
type: 'problem',
docs: {
url: util.getDocsUrl(__filename)
}
Expand Down
1 change: 1 addition & 0 deletions rules/no-cb-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const create = context => {
module.exports = {
create,
meta: {
type: 'suggestion',
docs: {
url: util.getDocsUrl(__filename)
}
Expand Down
1 change: 1 addition & 0 deletions rules/no-duplicate-modifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const create = context => {
module.exports = {
create,
meta: {
type: 'problem',
docs: {
url: util.getDocsUrl(__filename)
}
Expand Down
2 changes: 2 additions & 0 deletions rules/no-identical-title.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ const create = context => {
module.exports = {
create,
meta: {
// This is actually a `problem` as AVA will not allow tests with identical titles
type: 'problem',
docs: {
url: util.getDocsUrl(__filename)
}
Expand Down
14 changes: 13 additions & 1 deletion rules/no-ignored-test-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,21 @@ const create = context => {
};

const schema = [{
title: 'The `files` option is an array of strings representing the files glob that AVA will use to find test files.',
$comment: 'The default value of the `files` option is from `package.json` or `ava.config.js`.',
type: 'object',
properties: {
files: {
type: 'array'
type: 'array',
minItems: 0,
uniqueItems: true,
items: {
type: 'string'
},
examples: [
['lib/**/*.test.js', 'utils/**/*.test.js']
],
default: undefined
}
}
}];
Expand All @@ -94,6 +105,7 @@ module.exports = {
docs: {
url: util.getDocsUrl(__filename)
},
type: 'problem',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be placed above docs. Same with the other places.

schema
}
};
14 changes: 13 additions & 1 deletion rules/no-import-test-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,21 @@ const create = context => {
};

const schema = [{
title: 'The `files` option is an array of strings representing the files glob that AVA will use to find test files.',
$comment: 'The default value of the `files` option is from `package.json` or `ava.config.js`.',
type: 'object',
properties: {
files: {
type: 'array'
type: 'array',
minItems: 0,
uniqueItems: true,
items: {
type: 'string'
},
examples: [
['lib/**/*.test.js', 'utils/**/*.test.js']
],
default: undefined
}
}
}];
Expand All @@ -83,6 +94,7 @@ module.exports = {
docs: {
url: util.getDocsUrl(__filename)
},
type: 'problem',
schema
}
};
1 change: 1 addition & 0 deletions rules/no-invalid-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const create = context => {
module.exports = {
create,
meta: {
type: 'problem',
docs: {
url: util.getDocsUrl(__filename)
}
Expand Down
1 change: 1 addition & 0 deletions rules/no-nested-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const create = context => {
module.exports = {
create,
meta: {
type: 'problem',
docs: {
url: util.getDocsUrl(__filename)
}
Expand Down
1 change: 1 addition & 0 deletions rules/no-only-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const create = context => {
module.exports = {
create,
meta: {
type: 'problem',
docs: {
url: util.getDocsUrl(__filename)
},
Expand Down
3 changes: 2 additions & 1 deletion rules/no-skip-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
meta: {
docs: {
url: util.getDocsUrl(__filename)
}
},
type: 'problem'
}
};
1 change: 1 addition & 0 deletions rules/no-skip-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const create = context => {
module.exports = {
create,
meta: {
type: 'problem',
docs: {
url: util.getDocsUrl(__filename)
},
Expand Down
1 change: 1 addition & 0 deletions rules/no-statement-after-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const create = context => {
module.exports = {
create,
meta: {
type: 'problem',
docs: {
url: util.getDocsUrl(__filename)
}
Expand Down
3 changes: 2 additions & 1 deletion rules/no-todo-implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
meta: {
docs: {
url: util.getDocsUrl(__filename)
}
},
type: 'problem'
}
};
3 changes: 2 additions & 1 deletion rules/no-todo-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
meta: {
docs: {
url: util.getDocsUrl(__filename)
}
},
type: 'suggestion'
}
};
1 change: 1 addition & 0 deletions rules/no-unknown-modifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const create = context => {
module.exports = {
create,
meta: {
type: 'problem',
docs: {
url: util.getDocsUrl(__filename)
}
Expand Down
1 change: 1 addition & 0 deletions rules/prefer-async-await.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const create = context => {
module.exports = {
create,
meta: {
type: 'suggestion',
docs: {
url: util.getDocsUrl(__filename)
}
Expand Down
1 change: 1 addition & 0 deletions rules/prefer-power-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const create = context => {
module.exports = {
create,
meta: {
type: 'suggestion',
docs: {
url: util.getDocsUrl(__filename)
}
Expand Down
1 change: 1 addition & 0 deletions rules/test-ended.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const create = context => {
module.exports = {
create,
meta: {
type: 'problem',
docs: {
url: util.getDocsUrl(__filename)
}
Expand Down
3 changes: 3 additions & 0 deletions rules/test-title.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const create = context => {
};

const schema = [{
type: 'string',
default: 'if-multiple',
enum: [
'always',
'if-multiple'
Expand All @@ -43,6 +45,7 @@ const schema = [{
module.exports = {
create,
meta: {
type: 'suggestion',
docs: {
url: util.getDocsUrl(__filename)
},
Expand Down
1 change: 1 addition & 0 deletions rules/use-t-well.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ const create = context => {
module.exports = {
create,
meta: {
type: 'problem',
docs: {
url: util.getDocsUrl(__filename)
}
Expand Down
1 change: 1 addition & 0 deletions rules/use-t.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const create = context => {
module.exports = {
create,
meta: {
type: 'suggestion',
docs: {
url: util.getDocsUrl(__filename)
}
Expand Down
1 change: 1 addition & 0 deletions rules/use-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const create = context => ({
module.exports = {
create,
meta: {
type: 'suggestion',
docs: {
url: util.getDocsUrl(__filename)
}
Expand Down
1 change: 1 addition & 0 deletions rules/use-true-false.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const create = context => {
module.exports = {
create,
meta: {
type: 'suggestion',
docs: {
url: util.getDocsUrl(__filename)
}
Expand Down