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

Linting in code base with mixed js/ts sources #75

Closed
richardsimko opened this issue Jun 4, 2020 · 3 comments
Closed

Linting in code base with mixed js/ts sources #75

richardsimko opened this issue Jun 4, 2020 · 3 comments

Comments

@richardsimko
Copy link

richardsimko commented Jun 4, 2020

Is there any way to use this plugin to lint a code base with mixed JS and TS sources for the Vue files?

Basically a follow-up to this issue typescript-eslint/typescript-eslint#1835 where the reporter was recommended to check here. I'm in the same situation where we're trying to migrate a project from JS to TS and currently there doesn't seem to be a way to enable the TS rules only for files where <script lang="ts"> is used.

@darionco
Copy link

darionco commented Sep 17, 2020

+1
I am migrating a Vue project from JS to TS and not having this ability is making it difficult to lint all of my files since some are TS and some are JS.

Maybe allowing the parserOptions.parser to be an object could be useful:

{
    "parser": "vue-eslint-parser",
    "parserOptions": {
        "parser": {
            ts: "@typescript-eslint/parser",
            js: ...
        }
    }
}

@shameleo
Copy link

shameleo commented Nov 19, 2020

This looks relative to our problem: https://eslint.org/docs/user-guide/configuring#specifying-processor

Plugins may provide processors. Processors can extract JavaScript code from another kind of files, then lets ESLint lint the JavaScript code. Or processors can convert JavaScript code in preprocessing for some purpose.

Processors may make named code blocks such as 0.js and 1.js. ESLint handles such a named code block as a child file of the original file. You can specify additional configurations for named code blocks in the overrides section of the config. For example, the following disables strict rule for the named code blocks which end with .js in markdown files.

{
    "plugins": ["a-plugin"],
    "overrides": [
        {
            "files": ["*.md"],
            "processor": "a-plugin/markdown"
        },
        {
            "files": ["**/*.md/*.js"],
            "rules": {
                "strict": "off"
            }
        }
    ]
}

I assume preprocessor can extract any format, not only js. It's still unclear, should it be implemented by eslint-plugin-vue or vue-eslint-parser or can be some third-party extension. Any suggestions?

UPD: Maybe it is inappropriate, as blocks are not independent, so then need access to some common data

@ota-meshi
Copy link
Member

I think it duplicated with #49. So I close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants