mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
test: add tests for eslint rules
This adds tests for the custom eslint rules in this repository, using the `RuleTester` test utility bundled with eslint. PR-URL: https://github.com/nodejs/node/pull/16138 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
34c47ed486
commit
cd5ee52d70
11 changed files with 319 additions and 0 deletions
26
test/parallel/test-eslint-alphabetize-errors.js
Normal file
26
test/parallel/test-eslint-alphabetize-errors.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
'use strict';
|
||||
|
||||
require('../common');
|
||||
|
||||
const RuleTester = require('../../tools/eslint').RuleTester;
|
||||
const rule = require('../../tools/eslint-rules/alphabetize-errors');
|
||||
|
||||
new RuleTester().run('alphabetize-errors', rule, {
|
||||
valid: [
|
||||
`
|
||||
E('AAA', 'foo');
|
||||
E('BBB', 'bar');
|
||||
E('CCC', 'baz');
|
||||
`
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
code: `
|
||||
E('BBB', 'bar');
|
||||
E('AAA', 'foo');
|
||||
E('CCC', 'baz');
|
||||
`,
|
||||
errors: [{ message: 'Out of ASCIIbetical order - BBB >= AAA', line: 3 }]
|
||||
}
|
||||
]
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue