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

[strict] False positive for modules that don't export #58

Closed
mockdeep opened this issue Dec 19, 2018 · 5 comments · Fixed by #68
Closed

[strict] False positive for modules that don't export #58

mockdeep opened this issue Dec 19, 2018 · 5 comments · Fixed by #68
Labels
bug Something isn't working package: parser Issues related to @typescript-eslint/parser

Comments

@mockdeep
Copy link

Repro

If I have a file that has no exports and I have sourceType: module, it still reports a failure on the strict rule. I import the file for its global side effects.

root: true
env:
  browser: true
  es6: true
  commonjs: true

extends:
  - eslint:all
  - plugin:react/all
  - plugin:eslint-plugin-jsx-a11y/recommended
  - plugin:fp/recommended
  - plugin:import/errors

parserOptions:
  ecmaVersion: 2018
  ecmaFeatures:
    jsx: true
  sourceType: module

plugins:
  - better
  - fp
  - eslint-plugin-jsx-a11y
  - import
  - react

overrides:
  - files: ['**/*.ts', '**/*.tsx']
    parser: typescript-eslint-parser
    plugins: [typescript]
    rules:
      no-undef: off
      typescript/no-unused-vars: error

settings:
  import/resolver:
    node:
      moduleDirectory:
        - app/javascript
        - spec/javascript
        - vendor/assets/javascripts
        - node_modules
      extensions: [.js, .jsx, .ts, .tsx]
    babel-module:
      - root:
        - './app'
  import/extensions: [js, jsx]
window.whatevs = {
  myFunc() {
    console.log('yep');
  }
};

Expected Result

No linter error should be reported.

Actual Result

2:9  error  Use the function form of 'use strict'                      strict

Additional Info

This works as expected if I change the file to be js, so seems to be something related to changing it to ts.

Versions

package version
eslint-plugin-typescript 0.13.0
typescript-eslint-parser 17.0.1
typescript 2.9.3
@armano2
Copy link
Member

armano2 commented Dec 23, 2018

@bradzacher i will take a look ono this, but i think issue is in typescript-eslint-parser or even in typescript-estree

@armano2
Copy link
Member

armano2 commented Dec 23, 2018

ok i did some testing and sourceType is not properly set in https://github.com/eslint/typescript-eslint-parser/blob/master/parser.js#L74

@armano2
Copy link
Member

armano2 commented Dec 23, 2018

@mockdeep i make a PR for this eslint/typescript-eslint-parser#583

@mockdeep
Copy link
Author

@armano2 excellent, thanks!

@JamesHenry JamesHenry transferred this issue from bradzacher/eslint-plugin-typescript Jan 18, 2019
@bradzacher bradzacher added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin migration-test labels Jan 18, 2019
@bradzacher
Copy link
Member

Should have a test case added to the plugin if this is fixed.

@bradzacher bradzacher added package: parser Issues related to @typescript-eslint/parser and removed package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin labels Jan 18, 2019
sodatea added a commit to vuejs/eslint-config-typescript that referenced this issue Nov 13, 2019
@typescript-eslint typescript-eslint locked as resolved and limited conversation to collaborators Feb 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: parser Issues related to @typescript-eslint/parser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants