Files
twenty_crm/packages/eslint-plugin-twenty-ts/src/tests/matching-state-variable.spec.ts
Charles Bochet dba6f93826 Fix tests server
2023-09-17 08:41:46 -07:00

48 lines
1.1 KiB
TypeScript

import { RuleTester } from "@typescript-eslint/rule-tester";
import matchingStateVariableRule from "../rules/matching-state-variable";
const ruleTester = new RuleTester({
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: __dirname,
ecmaFeatures: {
jsx: true,
},
},
});
ruleTester.run('matching-state-variable', matchingStateVariableRule, {
valid: [
{
code: 'const variable = useRecoilValue(variableState);',
},
{
code: 'const [variable, setVariable] = useRecoilState(variableState);',
},
],
invalid: [
{
code: 'const myValue = useRecoilValue(variableState);',
errors: [
{
messageId: 'invalidVariableName',
},
],
output: 'const variable = useRecoilValue(variableState);',
},
{
code: 'const [myValue, setMyValue] = useRecoilState(variableState);',
errors: [
{
messageId: 'invalidVariableName',
},
{
messageId: 'invalidSetterName',
},
],
output: 'const [variable, setVariable] = useRecoilState(variableState);',
},
],
});