Files
renovate/tools/lint/rules/no-exec-shell-option.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

47 lines
1.3 KiB
TypeScript

import { RuleTester } from 'oxlint/plugins-dev';
import rule from './no-exec-shell-option.ts';
RuleTester.describe = describe;
RuleTester.it = it;
const ruleTester = new RuleTester({
languageOptions: { parserOptions: { lang: 'ts' } },
});
ruleTester.run('no-exec-shell-option', rule, {
valid: [
// other option names
`exec('ls', { cwd: '/tmp' });`,
`const opts = { shellEscape: true };`,
// destructuring is an ObjectPattern, not an ObjectExpression
`const { shell } = opts;`,
`function f({ shell }) {}`,
// numeric keys have no string name
`const opts = { 0: true };`,
// string literal key with a different name
`const opts = { 'cwd': '/tmp' };`,
],
invalid: [
{
code: `exec('ls', { shell: true });`,
errors: [{ messageId: 'noExecShellOption' }],
},
{
code: `exec('ls', { shell: '/bin/bash' });`,
errors: [{ messageId: 'noExecShellOption' }],
},
{
code: `const opts = { 'shell': true };`,
errors: [{ messageId: 'noExecShellOption' }],
},
{
code: `const opts = { cwd: '/tmp', shell: true };`,
errors: [{ messageId: 'noExecShellOption' }],
},
{
code: `const opts = { nested: { shell: true } };`,
errors: [{ messageId: 'noExecShellOption' }],
},
],
});