Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add meta object to the plugin #2149

Merged
merged 2 commits into from May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 Expand Up @@ -244,7 +245,7 @@
'.vue': require('./processor')
},
environments: {
// TODO Remove in the next major version

Check warning on line 248 in lib/index.js

View workflow job for this annotation

GitHub Actions / Lint

Unexpected 'todo' comment: 'TODO Remove in the next major version'
/** @deprecated */
'setup-compiler-macros': {
globals: {
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