8000 TS rules should only apply to .ts and .vue files with <script lang="ts"> in mixed codebase · Issue #1835 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content
< 8000 div id="js-flash-container" class="flash-container" data-turbo-replace>

TS rules should only apply to .ts and .vue files with <script lang="ts"> in mixed codebase #1835

8000
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

Closed
dsteinbach opened this issue Apr 2, 2020 · 3 comments
Labels
package: parser Issues related to @typescript-eslint/parser working as intended Issues that are closed as they are working as intended

Comments

@dsteinbach
Copy link

Repro

module.exports = {
    root: true,
    env: {
        node: true,
    },
    extends: ['eslint:recommended', 'plugin:vue/recommended', '@vue/typescript'],
    rules: {
        '@typescript-eslint/explicit-function-return-type': 'off',
    },
    parserOptions: {
        parser: '@typescript-eslint/parser'
    },
    overrides: [
        {
            files: ['*.ts'],
            rules: {
                '@typescript-eslint/explicit-function-return-type': ['error'],
            },
        },
    ],
};
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
    ...
    methods: {
        // undefined return type
        someFunc() {
             return 'abc';
        }
    },
    watch: {
        clientCode(val: string): here-is-an-undefined-return-type {
              this.someStateVar = val;     
        },
    },
});
</script>

Additional Info
If I get rid of overrides object and enable explicit-function-return-type under the default rules object that rule will run on all .vue files regardless if it's <script lang="ts"> or <script lang="js">. Everything works as it should if the file extension is .ts.

Expected Result
Should show error for .vue files that have <script lang="ts"> and no return type explicitly defined.

Actual Result
Does not show error for .vue files that have <script lang="ts"> with no return type explicitly defined.

Versions

package version
@typescript-eslint/parser ^2.19.0
TypeScript ^3.7.3
ESLint ^6.7.2
node 8.16.2
npm 6.4.1
@dsteinbach dsteinbach added package: parser Issues related to @typescript-eslint/parser triage Waiting for team members to take a look labels Apr 2, 2020
@bradzacher
Copy link
Member
bradzacher commented Apr 2, 2020

A .vue file isn't going to match a .ts extension glob because the extensions don't match.
There's nothing that can be done here. If you want it to match vue files, add vue to your glob.

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party working as intended Issues that are closed as they are working as intended and removed triage Waiting for team members to take a look awaiting response Issues waiting for a reply from the OP or another party labels Apr 2, 2020
@dsteinbach
Copy link
Author

If i add vue to my glob then it will run TS rules on .vue files that contain both <script lang="ts"> and <script> (js).

@bradzacher
Copy link
Member

you should file a request in the vue parser. our parser has no concept of what a vue file even is. the vue parser is what converts your vue code to something consumable by our parser.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: parser Issues related to @typescript-eslint/parser working as intended Issues that are closed as they are working as intended
Projects
None yet
Development

No branches or pull requests

2 participants
0