Skip to content

Commit

Permalink
Add meta object to the plugin (#2149)
Browse files Browse the repository at this point in the history
Co-authored-by: Flo Edelmann <florian-edelmann@online.de>
  • Loading branch information
ota-meshi and FloEdelmann committed May 8, 2023
1 parent c65c3a9 commit 9184384
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/index.js
Expand Up @@ -6,6 +6,7 @@
'use strict'

module.exports = {
meta: require('./meta'),
rules: {
'array-bracket-newline': require('./rules/array-bracket-newline'),
'array-bracket-spacing': require('./rules/array-bracket-spacing'),
Expand Down
3 changes: 3 additions & 0 deletions lib/meta.js
@@ -0,0 +1,3 @@
'use strict'
const { name, version } = require('../package.json')
module.exports = { name, version }
5 changes: 1 addition & 4 deletions lib/processor.js
Expand Up @@ -126,10 +126,7 @@ module.exports = {

supportsAutofix: true,

meta: {
name: 'eslint-plugin-vue',
version: require('../package.json').version
}
meta: require('./meta')
}

/**
Expand Down
20 changes: 20 additions & 0 deletions tests/lib/meta.js
@@ -0,0 +1,20 @@
'use strict'

const assert = require('assert')
const plugin = require('../..')
const expectedMeta = {
name: 'eslint-plugin-vue',
version: require('../../package.json').version
}

describe('Test for meta object', () => {
it('A plugin should have a meta object.', () => {
assert.deepStrictEqual(plugin.meta, expectedMeta)
})

for (const [name, processor] of Object.entries(plugin.processors)) {
it(`"${name}" processor should have a meta object.`, () => {
assert.deepStrictEqual(processor.meta, expectedMeta)
})
}
})
1 change: 1 addition & 0 deletions tools/update-lib-index.js
Expand Up @@ -25,6 +25,7 @@ const content = `/*
'use strict'
module.exports = {
meta: require('./meta'),
rules: {
${rules
.map((rule) => `'${rule.name}': require('./rules/${rule.name}')`)
Expand Down

0 comments on commit 9184384

Please sign in to comment.