2022-02-19 16:05:21 +01:00
|
|
|
const { ESLint } = require('eslint')
|
2022-03-19 14:28:00 +01:00
|
|
|
const tap = require('tap')
|
2022-02-19 16:05:21 +01:00
|
|
|
|
2022-02-20 12:36:37 +01:00
|
|
|
const eslint = new ESLint({
|
|
|
|
ignore: false,
|
|
|
|
useEslintrc: false,
|
|
|
|
overrideConfigFile: 'eslintrc.json'
|
|
|
|
})
|
|
|
|
|
2022-03-19 14:28:00 +01:00
|
|
|
tap.test('ensure we validate correctly JavaScript files', async (t) => {
|
2022-02-19 16:05:21 +01:00
|
|
|
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)
|
|
|
|
})
|
|
|
|
|
2022-03-19 14:28:00 +01:00
|
|
|
tap.test('ensure we validate correctly TypeScript files', async (t) => {
|
2022-02-19 16:05:21 +01:00
|
|
|
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)
|
|
|
|
})
|
|
|
|
|
2022-03-19 14:28:00 +01:00
|
|
|
tap.test('ensure we allow top-level await', async (t) => {
|
2022-02-19 16:05:21 +01:00
|
|
|
const [lintResult] = await eslint.lintFiles(
|
|
|
|
'test/fixtures/top-level-await.mjs'
|
|
|
|
)
|
|
|
|
t.equal(lintResult.errorCount, 0)
|
|
|
|
})
|