-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20fe2fb
commit 62952b5
Showing
7 changed files
with
768 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { it } from 'vitest' | ||
import { RuleTester } from 'eslint' | ||
import { rule } from '../rules/calc-arguments' | ||
|
||
const ruleTester = new RuleTester() | ||
|
||
it('calc-arguments', () => { | ||
// @ts-ignore | ||
ruleTester.run('calc-arguments', rule, { | ||
valid: [ | ||
{ | ||
code: `calc('large', 'small')`, | ||
}, | ||
{ | ||
code: `calc('2rem', '1rem')`, | ||
}, | ||
], | ||
|
||
invalid: [ | ||
{ | ||
code: `calc('small', 'large')`, | ||
errors: [ | ||
{ | ||
message: '"large" should come before "small".', | ||
type: 'Literal', | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `calc('large small')`, | ||
errors: [ | ||
{ | ||
message: 'Use function arguments instead of whitespaces.', | ||
type: 'Literal', | ||
}, | ||
], | ||
}, | ||
], | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import calcArguments from './rules/calc-arguments' | ||
import { rule as calcArguments } from './rules/calc-arguments' | ||
|
||
export let rules = { | ||
export const rules = { | ||
'calc-arguments': calcArguments, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ESLintUtils } from '@typescript-eslint/utils' | ||
|
||
const getDocsUrl = (name: string): string => | ||
`https://github.com/dnbexperience/eslint-plugin-eufemia/blob/main/docs/rules/${name}.md` | ||
|
||
export const createRule: ReturnType<typeof ESLintUtils.RuleCreator> = ( | ||
...args | ||
) => ESLintUtils.RuleCreator(getDocsUrl)(...args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.