Created
May 14, 2019 09:59
-
-
Save andrewborisov/a6f71b05f16d49b41fa75acb0ec5ce0f to your computer and use it in GitHub Desktop.
creating-ts-lint-rule project
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
import { lintHelper, getErrorLine } from './lint-helper'; | |
const ruleName = 'module-imports-order'; | |
describe('module imports order rule', () => { | |
it('should not fail with wrong import order', () => { | |
const sourceFile = ` | |
import * as React from 'react';git push -u origin master | |
import { SomeGlobalModule } from '@/utils/some-util'; | |
import { SomeGlobalModule } from '@/modules/some-global-module1'; | |
import { SomeGlobalModule } from '@/modules/some-global-module2'; | |
import { SomeGlobalModule } from '@/components/some-global-module3'; | |
import { SomeLocalModule } from '../../folder/some-local-module'; | |
import { SomeLocalModule } from '../folder/some-local-module'; | |
import { SomeLocalModule } from './folder/some-local-module'; | |
import '../icon.svg'; | |
import './styles.scss'; | |
`; | |
const result = lintHelper({ sourceFile, ruleName }); | |
expect(result.errorCount).toBe(0); | |
}); | |
it('should fail because of @/util/ is higher than node_module', () => { | |
const sourceFile = ` | |
import { SomeGlobalModule } from '@/utils/some-util'; | |
import * as React from 'react'; | |
import { SomeGlobalModule } from '@/modules/some-global-module1'; | |
import { SomeGlobalModule } from '@/modules/some-global-module2'; | |
import { SomeGlobalModule } from '@/components/some-global-module3'; | |
import { SomeLocalModule } from '../../folder/some-local-module'; | |
import { SomeLocalModule } from '../folder/some-local-module'; | |
import { SomeLocalModule } from './folder/some-local-module'; | |
import '../icon.svg'; | |
import './styles.scss'; | |
`; | |
const result = lintHelper({ sourceFile, ruleName }); | |
expect(result.errorCount).toBe(1); | |
}); | |
// A lot of other tests in real version | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment