mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-23 12:02:10 +03:00
60 lines
1.1 KiB
TypeScript
60 lines
1.1 KiB
TypeScript
|
import { TSESLint } from '@typescript-eslint/utils';
|
||
|
|
||
|
import { rule, RULE_NAME } from './no-navigate-prefer-link';
|
||
|
|
||
|
const ruleTester = new TSESLint.RuleTester({
|
||
|
parser: require.resolve('@typescript-eslint/parser'),
|
||
|
});
|
||
|
|
||
|
ruleTester.run(RULE_NAME, rule, {
|
||
|
valid: [
|
||
|
{
|
||
|
code: 'if(someVar) { navigate("/"); }',
|
||
|
},
|
||
|
{
|
||
|
code: '<Link to="/"><Button>Click me</Button></Link>',
|
||
|
parserOptions: {
|
||
|
ecmaFeatures: {
|
||
|
jsx: true,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
code: '<Button onClick={() =>{ navigate("/"); doSomething(); }} />',
|
||
|
parserOptions: {
|
||
|
ecmaFeatures: {
|
||
|
jsx: true,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
],
|
||
|
invalid: [
|
||
|
{
|
||
|
code: '<Button onClick={() => navigate("/")} />',
|
||
|
errors: [
|
||
|
{
|
||
|
messageId: 'preferLink',
|
||
|
},
|
||
|
],
|
||
|
parserOptions: {
|
||
|
ecmaFeatures: {
|
||
|
jsx: true,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
code: '<Button onClick={() => { navigate("/");} } />',
|
||
|
errors: [
|
||
|
{
|
||
|
messageId: 'preferLink',
|
||
|
},
|
||
|
],
|
||
|
parserOptions: {
|
||
|
ecmaFeatures: {
|
||
|
jsx: true,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
],
|
||
|
});
|