vuejs / vue-eslint-parser

The ESLint custom parser for `.vue` files.
MIT License
435 stars 74 forks source link

Add exported meta object #190

Closed TatsuyaYamamoto closed 1 year ago

TatsuyaYamamoto commented 1 year ago

Related issue: nothing

This PR’s purpose is to support ESLint flat config.

Loading vue-eslint-parser in flat config, ESLint check parser’s name and version in meta object. https://github.com/eslint/eslint/blob/main/lib/config/flat-config-array.js#L196 https://github.com/eslint/eslint/blob/main/lib/config/flat-config-array.js#L45-L76

vue-eslint-parser can be used in the flat config by exporting the meta object like other packages:

TatsuyaYamamoto commented 1 year ago

https://github.com/vuejs/vue-eslint-parser/actions/runs/4810002085/jobs/8565427992?pr=190

Error: Cannot find module './package.json'

I'll fix this test

TatsuyaYamamoto commented 1 year ago

@ota-meshi

Please advise. What path should I use to refer to package.json ?

When testing, “index.ts” should refer to package.json with ". /package.json”, but after build, “index.js” should refer to package.json with ". /package.json”.

Should I bind the version string with rollup at build time?

ota-meshi commented 1 year ago

How about writing it like this:

    get version() {
        return require("./package.json").version;
    }
ota-meshi commented 1 year ago

Should I bind the version string with rollup at build time?

I think it would be better if possible. I think using getters may seem like magic 😅

TatsuyaYamamoto commented 1 year ago

@ota-meshi passed the tests in my local env!