-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathutils.js
35 lines (31 loc) · 892 Bytes
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import path from 'path';
import { RuleTester as EslintRuleTester } from 'eslint';
import { test } from 'mocha';
/* pattern taken from eslint-plugin-import */
export function addFilenameOption (testCase) {
return {
...testCase,
// TODO: Find a way to remove this.
filename: path.resolve(__dirname, './files/foo.js'),
};
}
/**
* Customizing ESLint rule tester to be run by Mocha.
* @see https://eslint.org/docs/latest/integrate/nodejs-api#customizing-ruletester
*/
EslintRuleTester.describe = (text, method) => {
EslintRuleTester.it.title = text;
return method.call(this);
};
EslintRuleTester.it = (text, method) => {
test(EslintRuleTester.it.title + ': ' + text, method);
};
export const RuleTester = () => {
return new EslintRuleTester({
parserOptions: {
sourceType: 'module',
ecmaVersion: 6,
ecmaFeatures: { jsx: true },
},
});
};