Skip to content

Commit 94d87d4

Browse files
committed
test: add tests for define.lint
1 parent 18e89fb commit 94d87d4

5 files changed

Lines changed: 31 additions & 1 deletion

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ node_modules
88
dist/
99
test-results
1010

11+
# Temp files
12+
test-temp-*
13+
1114
# IDE
1215
.vscode/*
1316
!.vscode/settings.json
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { writeFile } from 'node:fs/promises';
2+
import path from 'node:path';
3+
import { test } from '#test-helpers';
4+
import { expect } from 'rstack/test';
5+
6+
test('should run lint with define.lint config', ({ execCli }) => {
7+
execCli('lint src/index.js');
8+
});
9+
10+
test('should fail when lint reports errors', async ({ cwd, execCli, logHelper }) => {
11+
const filePath = path.join(cwd, 'src/test-temp-error.js');
12+
await writeFile(filePath, 'debugger;');
13+
expect(() => execCli('lint src/test-temp-error.js')).toThrow();
14+
await logHelper.expectLog(`Unexpected 'debugger' statement`);
15+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { define } from 'rstack';
2+
3+
define.lint([
4+
{ ignores: ['!src/test-temp-error.js'] },
5+
{
6+
files: ['src/**/*.js'],
7+
rules: {
8+
'no-debugger': 'error',
9+
},
10+
},
11+
]);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('hello');

packages/rstack/test/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"allowImportingTsExtensions": true,
55
"noEmit": true,
66
"rootDir": "..",
7-
"types": ["node", "rstack/test/globals"],
7+
"types": ["node"],
88
"paths": {
99
"rstack": ["../src/index.ts"],
1010
"rstack/lint": ["../src/lint.ts"],

0 commit comments

Comments
 (0)