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
Showing
8 changed files
with
134 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { TSESTree } from '@typescript-eslint/types' | ||
|
||
import { createRule } from '../utils' | ||
|
||
const NAME = 'import-declaration-newline' | ||
|
||
// TODO: make schema | ||
const value = createRule({ | ||
create(context) { | ||
return { | ||
Program() { | ||
const sourceCode = context.getSourceCode() | ||
const comments = sourceCode.getAllComments() | ||
|
||
comments.forEach((comment) => { | ||
if (comment.value.includes(context.settings.url as string)) { | ||
return | ||
} | ||
|
||
context.report({ | ||
messageId: 'default', | ||
loc: comment.loc, | ||
}) | ||
}) | ||
}, | ||
} | ||
}, | ||
defaultOptions: [], | ||
meta: { | ||
docs: { | ||
description: 'Ensure all TODOs and FIXMEs have an issue link attached to them', | ||
recommended: false, | ||
requiresTypeChecking: false, | ||
}, | ||
messages: { | ||
default: 'All TODOs and FIXMEs have an issue link attached to them', | ||
}, | ||
schema: [], | ||
type: 'problem', | ||
}, | ||
name: NAME, | ||
}) | ||
|
||
export default { | ||
name: NAME, | ||
value, | ||
} | ||
|
Empty file.
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,48 @@ | ||
/* eslint-disable sort-keys-fix/sort-keys-fix */ | ||
|
||
import rule from '../../rules/document-todos' | ||
import { | ||
ruleTester, | ||
TSX_FILE_PATH, | ||
} from '../utils' | ||
|
||
ruleTester.run(rule.name, rule.value, { | ||
invalid: [ | ||
{ | ||
code: ` | ||
// TODO: comment above the function https://rimac-automobili.atlassian.net/jira/software/c/projects/QIA/boards/34/backlog?view=detail&selectedIssue=QIA-965&epics=visible&issueLimit=100 | ||
const Component = () => { | ||
/** | ||
* This is a comment block | ||
* TODO: and this is his todo https://rimac-automobili.atlassian.net/jira/software/c/projects/QIA/boards/34/backlog?view=detail&selectedIssue=QIA-965&epics=visible&issueLimit=100 | ||
*/ | ||
const router = useRouter() | ||
// FIXME: comment above the return | ||
return ( | ||
<div | ||
props={true} | ||
// TODO: and this is his todo https://rimac-automobili.atlassian.net/jira/software/c/projects/QIA/boards/34/backlog?view=detail&selectedIssue=QIA-965&epics=visible&issueLimit=100 | ||
style={{ height: '50px' }} | ||
> | ||
{/* TODO: this is a different jsx comment */} | ||
<p>Hello</p> | ||
</div> | ||
) | ||
} | ||
`, | ||
filename: TSX_FILE_PATH, | ||
settings: { | ||
url: 'https://rimac-automobili.atlassian.net/jira/software/c/projects/' | ||
}, | ||
errors: [ | ||
{ | ||
column: 1, | ||
line: 2, | ||
messageId: 'default', | ||
}, | ||
], | ||
} | ||
], | ||
valid: [], | ||
}) |
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,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"jsx": "preserve", | ||
"target": "es5", | ||
"module": "commonjs", | ||
"strict": true, | ||
"esModuleInterop": true, | ||
"types": [], | ||
"lib": [ | ||
"es2015", | ||
"es2017", | ||
"esnext" | ||
], | ||
"experimentalDecorators": true | ||
}, | ||
"include": [ | ||
"./fixtures/file.tsx" | ||
] | ||
} |
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 @@ | ||
export const TSX_FILE_PATH = './fixtures/file.tsx' |
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,2 @@ | ||
export * from './constants' | ||
export * from './ruleTester' |
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,15 @@ | ||
import * as path from 'path' | ||
|
||
import { ESLintUtils } from '@typescript-eslint/utils' | ||
|
||
export const ruleTester = new ESLintUtils.RuleTester({ | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 2015, | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
project: './tsconfig.json', | ||
tsconfigRootDir: path.resolve(__dirname, '..'), | ||
}, | ||
}) |
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 |
---|---|---|
|
@@ -14,6 +14,6 @@ | |
"experimentalDecorators": true | ||
}, | ||
"include": [ | ||
"fixtures" | ||
"fixtures/file.ts" | ||
] | ||
} |