1
1
mirror of https://github.com/theoludwig/eslint-config-conventions.git synced 2024-09-09 00:25:53 +02:00

refactor: usage of node:test instead of tap

This commit is contained in:
Théo LUDWIG 2023-07-02 15:46:14 +02:00
parent b1bd574d42
commit 528a31316d
Signed by: theoludwig
GPG Key ID: ADFE5A563D718F3B
3 changed files with 23 additions and 23 deletions

8
.taprc
View File

@ -1,8 +0,0 @@
ts: false
jsx: false
flow: false
check-coverage: true
coverage: true
test-ignore:
- 'test/fixtures'

View File

@ -1,14 +1,20 @@
const tap = require('tap')
const test = require('node:test')
const assert = require('node:assert/strict')
const config = require('../index.js')
/**
* @param {unknown} object
* @returns {boolean}
*/
const isObject = (object) => {
return typeof object === 'object' && object !== null
}
tap.test('test basic properties of config', async (t) => {
t.ok(isObject(config.parserOptions))
t.ok(isObject(config.env))
t.ok(isObject(config.rules))
t.ok(isObject(config.overrides))
test('test basic properties of config', async () => {
assert.ok(isObject(config))
assert.ok(isObject(config.parserOptions))
assert.ok(isObject(config.env))
assert.ok(isObject(config.rules))
assert.ok(isObject(config.overrides))
})

View File

@ -1,5 +1,7 @@
const test = require('node:test')
const assert = require('node:assert/strict')
const { ESLint } = require('eslint')
const tap = require('tap')
const eslint = new ESLint({
ignore: false,
@ -7,31 +9,31 @@ const eslint = new ESLint({
overrideConfigFile: 'eslintrc.json'
})
tap.test('ensure we validate correctly JavaScript files', async (t) => {
test('ensure we validate correctly JavaScript files', async () => {
const [noErrors] = await eslint.lintFiles(
'test/fixtures/javascript-no-errors.js'
)
const [withErrors] = await eslint.lintFiles(
'test/fixtures/javascript-with-errors.js'
)
t.equal(noErrors.errorCount, 0)
t.equal(withErrors.errorCount, 3)
assert.strictEqual(noErrors?.errorCount, 0)
assert.strictEqual(withErrors?.errorCount, 3)
})
tap.test('ensure we validate correctly TypeScript files', async (t) => {
test('ensure we validate correctly TypeScript files', async () => {
const [noErrors] = await eslint.lintFiles(
'test/fixtures/typescript-no-errors.ts'
)
const [withErrors] = await eslint.lintFiles(
'test/fixtures/javascript-with-errors.js'
)
t.equal(noErrors.errorCount, 0)
t.equal(withErrors.errorCount, 3)
assert.strictEqual(noErrors?.errorCount, 0)
assert.strictEqual(withErrors?.errorCount, 3)
})
tap.test('ensure we allow top-level await', async (t) => {
test('ensure we allow top-level await', async () => {
const [lintResult] = await eslint.lintFiles(
'test/fixtures/top-level-await.mjs'
)
t.equal(lintResult.errorCount, 0)
assert.strictEqual(lintResult?.errorCount, 0)
})