mirror of
https://github.com/theoludwig/eslint-config-conventions.git
synced 2024-12-18 21:45:04 +01:00
refactor: usage of node:test instead of tap
This commit is contained in:
parent
b1bd574d42
commit
528a31316d
8
.taprc
8
.taprc
@ -1,8 +0,0 @@
|
||||
ts: false
|
||||
jsx: false
|
||||
flow: false
|
||||
check-coverage: true
|
||||
coverage: true
|
||||
|
||||
test-ignore:
|
||||
- 'test/fixtures'
|
@ -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))
|
||||
})
|
||||
|
@ -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)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user