From 456e3ee495ec35934733f003fd3a134967606bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Trzepi=C5=84ski?= Date: Wed, 16 Oct 2024 13:14:18 +0200 Subject: [PATCH] Added no restricted propreties rule [WWW-1215] (#25) --- configs/mainConfig/mainConfig.cjs | 2 ++ .../mainConfig/noRestrictedPropertiesRule.cjs | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 configs/mainConfig/noRestrictedPropertiesRule.cjs diff --git a/configs/mainConfig/mainConfig.cjs b/configs/mainConfig/mainConfig.cjs index 3bedce9..abbad87 100644 --- a/configs/mainConfig/mainConfig.cjs +++ b/configs/mainConfig/mainConfig.cjs @@ -7,6 +7,7 @@ const preferDestructuringRule = require('./preferDestructuringRule.cjs'); const noRestrictedImportsRule = require('./noRestrictedImportsRule.cjs'); const stringEnumRule = require('./stringEnumRule.cjs'); const noEmptyFunctionsRule = require('./noEmptyFunctionsRule.cjs'); +const noRestrictedPropertiesRule = require('./noRestrictedPropertiesRule.cjs'); module.exports = { plugins, @@ -62,5 +63,6 @@ module.exports = { '@typescript-eslint/no-use-before-define': [ERROR, { functions: false }], 'typescript-sort-keys/interface': WARN, 'unused-imports/no-unused-imports': ERROR, + 'no-restricted-properties': noRestrictedPropertiesRule, }, }; diff --git a/configs/mainConfig/noRestrictedPropertiesRule.cjs b/configs/mainConfig/noRestrictedPropertiesRule.cjs new file mode 100644 index 0000000..44aed4a --- /dev/null +++ b/configs/mainConfig/noRestrictedPropertiesRule.cjs @@ -0,0 +1,18 @@ +const { ERROR } = require('../../consts/common.cjs'); + +const testingLibraryRestrictedProperties = [ + 'getByRole', + 'getAllByRole', + 'findByRole', + 'findAllByRole', + 'queryByRole', + 'queryAllByRole', +]; +module.exports = [ + ERROR, + ...testingLibraryRestrictedProperties.map(property => ({ + property, + message: + 'This query is not allowed as it has low performance. Please use other queries instead.', + })), +];