mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-31 09:41:46 +00:00
e44c9a2070
* ci: move custom oxlint rules to typescript and alternative API * ci: add to test sharding
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import { RuleTester } from 'oxlint/plugins-dev';
|
|
import rule from './no-tools-import.ts';
|
|
|
|
RuleTester.describe = describe;
|
|
RuleTester.it = it;
|
|
|
|
const ruleTester = new RuleTester({
|
|
languageOptions: { parserOptions: { lang: 'ts' } },
|
|
});
|
|
|
|
ruleTester.run('no-tools-import', rule, {
|
|
valid: [
|
|
`import { foo } from './foo.ts';`,
|
|
`import { foo } from '../util/foo.ts';`,
|
|
// `tools` without a trailing slash is not a directory import
|
|
`import { foo } from './tools.ts';`,
|
|
`import { foo } from 'some-tools';`,
|
|
// does not start a path segment
|
|
`import { foo } from 'mytools/foo.ts';`,
|
|
// no source
|
|
`export const foo = 1;`,
|
|
`export { foo };`,
|
|
// dynamic import with a non-literal source
|
|
`const p = import('../' + name);`,
|
|
`const p = import('./foo.ts');`,
|
|
],
|
|
invalid: [
|
|
{
|
|
code: `import { foo } from 'tools/foo.ts';`,
|
|
errors: [{ messageId: 'noToolsImport' }],
|
|
},
|
|
{
|
|
code: `import { foo } from '../tools/foo.ts';`,
|
|
errors: [{ messageId: 'noToolsImport' }],
|
|
},
|
|
{
|
|
code: `import { foo } from '../../tools/lint/foo.ts';`,
|
|
errors: [{ messageId: 'noToolsImport' }],
|
|
},
|
|
{
|
|
code: `export { foo } from './tools/foo.ts';`,
|
|
errors: [{ messageId: 'noToolsImport' }],
|
|
},
|
|
{
|
|
code: `export * from '../tools/foo.ts';`,
|
|
errors: [{ messageId: 'noToolsImport' }],
|
|
},
|
|
{
|
|
code: `const p = import('../tools/foo.ts');`,
|
|
errors: [{ messageId: 'noToolsImport' }],
|
|
},
|
|
],
|
|
});
|