Files
renovate/tools/lint/rules/no-tools-import.spec.ts
Sebastian Poxhofer e44c9a2070 ci(oxlint): move custom oxlint rules to typescript and alternative API (#45337)
* ci: move custom oxlint rules to typescript and alternative API

* ci: add  to test sharding
2026-08-19 05:37:56 +00:00

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' }],
},
],
});