Skip to content

Commit

Permalink
chore: add flat config tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aladdin-add committed Mar 12, 2024
1 parent 95ddc6f commit 56dac44
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

const { ESLint } = require('../../eslint-compat')
const plugin = require('../../../lib/index')
const assert = require('assert/strict')

Check failure on line 5 in tests/lib/configs/eslintrc.js

View workflow job for this annotation

GitHub Actions / Lint

'assert' is assigned a value but never used

// TODO: test flat configs
describe('eslintrc configs', () => {
for (const name of Object.keys(plugin.configs)) {
if (name.startsWith('flat/')) {
Expand Down
98 changes: 98 additions & 0 deletions tests/lib/configs/flat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**
* @fileoverview flat configs test
* @author 唯然<weiran.zsd@outlook.com>
*/

'use strict'

const plugin = require('../../../lib/index')
const assert = require('assert/strict')

describe('flat configs', () => {
it('should export base config', () => {
const base = plugin.configs['flat/base']
assert.ok(base)
assert.equal(typeof base, 'object')
assert.strictEqual(base.plugins.vue, plugin)
assert.strictEqual(base.rules['vue/comment-directive'], 'error')
})
it('should export essential config', () => {
const essential = plugin.configs['flat/essential']
assert.ok(essential)
assert.equal(typeof essential, 'object')
assert.strictEqual(essential.plugins.vue, plugin)
assert.strictEqual(essential.rules['vue/comment-directive'], 'error')
assert.strictEqual(
essential.rules['vue/multi-word-component-names'],
'error'
)
})

it('should export strongly-recommended config', () => {
const stronglyRecommended = plugin.configs['flat/vue2-strongly-recommended']
assert.ok(stronglyRecommended)
assert.equal(typeof stronglyRecommended, 'object')
assert.strictEqual(stronglyRecommended.plugins.vue, plugin)
assert.strictEqual(
stronglyRecommended.rules['vue/comment-directive'],
'error'
)
assert.strictEqual(
stronglyRecommended.rules['vue/multi-word-component-names'],
'error'
)
})

it('should export recommended config', () => {
const recommended = plugin.configs['flat/recommended']
assert.ok(recommended)
assert.equal(typeof recommended, 'object')
assert.strictEqual(recommended.plugins.vue, plugin)
assert.strictEqual(recommended.rules['vue/comment-directive'], 'error')
assert.strictEqual(
recommended.rules['vue/multi-word-component-names'],
'error'
)
assert.strictEqual(recommended.rules['vue/attributes-order'], 'warn')
})

it('should export vue2-essential config', () => {
const essential = plugin.configs['flat/vue2-essential']
assert.ok(essential)
assert.equal(typeof essential, 'object')
assert.strictEqual(essential.plugins.vue, plugin)
assert.strictEqual(essential.rules['vue/comment-directive'], 'error')
assert.strictEqual(
essential.rules['vue/multi-word-component-names'],
'error'
)
})

it('should export vue2-strongly-recommended config', () => {
const stronglyRecommended = plugin.configs['flat/vue2-strongly-recommended']
assert.ok(stronglyRecommended)
assert.equal(typeof stronglyRecommended, 'object')
assert.strictEqual(stronglyRecommended.plugins.vue, plugin)
assert.strictEqual(
stronglyRecommended.rules['vue/comment-directive'],
'error'
)
assert.strictEqual(
stronglyRecommended.rules['vue/multi-word-component-names'],
'error'
)
})

it('should export vue2-recommended config', () => {
const recommended = plugin.configs['flat/vue2-recommended']
assert.ok(recommended)
assert.equal(typeof recommended, 'object')
assert.strictEqual(recommended.plugins.vue, plugin)
assert.strictEqual(recommended.rules['vue/comment-directive'], 'error')
assert.strictEqual(
recommended.rules['vue/multi-word-component-names'],
'error'
)
assert.strictEqual(recommended.rules['vue/attributes-order'], 'warn')
})
})

0 comments on commit 56dac44

Please sign in to comment.