зеркало из https://github.com/mozilla/fxa.git
fix(eslint): Add no test.slow() rule
This commit is contained in:
Родитель
e682d570e5
Коммит
8b2feea293
|
@ -33,6 +33,7 @@ module.exports = {
|
||||||
'no-empty': 0,
|
'no-empty': 0,
|
||||||
'no-eval': 2,
|
'no-eval': 2,
|
||||||
'fxa/no-exclusive-tests': 2,
|
'fxa/no-exclusive-tests': 2,
|
||||||
|
'fxa/no-test-slow': 0,
|
||||||
'no-irregular-whitespace': 2,
|
'no-irregular-whitespace': 2,
|
||||||
'no-loop-func': 0,
|
'no-loop-func': 0,
|
||||||
'no-multi-spaces': 0,
|
'no-multi-spaces': 0,
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
module.exports = {
|
||||||
|
create: function (context) {
|
||||||
|
return {
|
||||||
|
CallExpression(node) {
|
||||||
|
if (
|
||||||
|
node.callee.type === 'MemberExpression' &&
|
||||||
|
node.callee.object.name === 'test' &&
|
||||||
|
node.callee.property.name === 'slow'
|
||||||
|
) {
|
||||||
|
context.report({
|
||||||
|
node,
|
||||||
|
message:
|
||||||
|
'Avoid using test.slow() in your test, change the default timeout.',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
|
@ -0,0 +1,28 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const RuleTester = require('eslint').RuleTester;
|
||||||
|
const rule = require('../lib/rules/no-test-slow');
|
||||||
|
|
||||||
|
const ruleTester = new RuleTester();
|
||||||
|
|
||||||
|
const fromError = {
|
||||||
|
message: 'Avoid using test.slow() in your test, change the default timeout.',
|
||||||
|
};
|
||||||
|
|
||||||
|
ruleTester.run('no-test-slow', rule, {
|
||||||
|
valid: ["test.describe('test')"],
|
||||||
|
invalid: [
|
||||||
|
{
|
||||||
|
code: `test.slow();`,
|
||||||
|
errors: [fromError],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: `test.slow('condition', 'reason');`,
|
||||||
|
errors: [fromError],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
|
@ -4,6 +4,7 @@ module.exports = {
|
||||||
browser: true,
|
browser: true,
|
||||||
},
|
},
|
||||||
extends: ['eslint:recommended', 'plugin:playwright/recommended'],
|
extends: ['eslint:recommended', 'plugin:playwright/recommended'],
|
||||||
|
plugins: ['fxa'],
|
||||||
globals: {
|
globals: {
|
||||||
globalThis: false, // not writeable
|
globalThis: false, // not writeable
|
||||||
},
|
},
|
||||||
|
@ -12,6 +13,7 @@ module.exports = {
|
||||||
'@typescript-eslint/ban-ts-comment': 'off',
|
'@typescript-eslint/ban-ts-comment': 'off',
|
||||||
'@typescript-eslint/ban-types': 'warn',
|
'@typescript-eslint/ban-types': 'warn',
|
||||||
'playwright/no-skipped-test': ['error', { allowConditional: true }],
|
'playwright/no-skipped-test': ['error', { allowConditional: true }],
|
||||||
|
'fxa/no-test-slow': 'warn',
|
||||||
'no-console': ['error', { allow: ['log'] }], // console errors cause side effects in CircleCI (FXA-8773)
|
'no-console': ['error', { allow: ['log'] }], // console errors cause side effects in CircleCI (FXA-8773)
|
||||||
'no-unused-vars': 'off',
|
'no-unused-vars': 'off',
|
||||||
},
|
},
|
||||||
|
|
Загрузка…
Ссылка в новой задаче