Skip to content

'npm run lint' corrupts files #1984

Closed
Closed
@krissrex

Description

@krissrex

Version

3.0.0-rc.8

Node and OS info

Node 8.9.3 / npm 5.5.1 / Windows 10 x64

Steps to reproduce

  1. Create a project with tslint.
  2. Create a vue-file.
  3. Omit lang="ts" from script tag
  4. Put some normal javascript vue code in it
  5. Run npm run lint

What is expected?

Lint errors should be reported.
No file modifications.
No file corruptions.

What is actually happening?

Files are being modified.
Mulitple comment lines are added:

//
//
//
//
//

Semicolons are inserted randomly into statements:

Code after npm run lint:

//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//

import { USER_AUTHENTICATE } from '@/store/mutation-types'

export default {
  name: 'login',
  data () {
    return; {
      loggingIn: false,
      username '',
      password: '',
      error: ''
    }
  },
  methods: {
    login () {
      console.log(`Loggi;ng in ${this.username}`)
     this.loggingIn = true
      this.$http.post('/auth';, {
        username: this.u;sername,
        password: this.password
      })
        .then((response) => {
          console.log('Got response', response)
          this.error = ''
          this.loggingIn = fals;e
          this.authentic;ated(this.username, response.data;.token)
        })
        .catch((err) => {
          console.er;ror('Unable to log in', err)
          this.loggingIn = false
          if (err.respon;se && err.response.status === 401;) {
            this.error = 'Incorrect credentials'
          } else {
            this.error = 'Unable to lo;g in'
          }
        })
    },
    authenticated (username;, token) {
      this.$;store.commit(USER_AUTHENTICATE, { name: username, token })
      this.$router.push('/')
    }
  }
}
;;;
</script>

Could be an issue with tslint linter in vue.

Code before linting:

<script>
import { USER_AUTHENTICATE } from '@/store/mutation-types'

export default {
  name: 'login',
  data () {
    return {
      loggingIn: false,
      username: '',
      password: '',
      error: ''
    }
  },
  methods: {
    login () {
      console.log(`Logging in ${this.username}`)
      this.loggingIn = true
      this.$http.post('/auth', {
        username: this.username,
        password: this.password
      })
        .then(response => {
          console.log('Got response', response)
          this.error = ''
          this.loggingIn = false
          this.authenticated(this.username, response.data.token)
        })
        .catch(err => {
          console.error('Unable to log in', err)
          this.loggingIn = false
          if (err.response && err.response.status === 401) {
            this.error = 'Incorrect credentials'
          } else {
            this.error = 'Unable to log in'
          }
        })
    },
    authenticated (username, token) {
      this.$store.commit(USER_AUTHENTICATE, { name: username, token })
      this.$router.push('/')
    }
  }
}
</script>

Package.json

{
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "test:unit": "vue-cli-service test:unit"
  },  
"devDependencies": {
    "@vue/cli-plugin-babel": "^3.0.0-rc.9",
    "@vue/cli-plugin-typescript": "^3.0.0-rc.9",
    "@vue/cli-plugin-unit-jest": "^3.0.0-rc.9",
    "@vue/cli-service": "^3.0.0-rc.9",
    "@vue/test-utils": "^1.0.0-beta.20",
    "babel-core": "7.0.0-bridge.0",
    "less": "^3.0.4",
    "less-loader": "^4.1.0",
     "typescript": "^2.9.0",
    "vue-template-compiler": "^2.5.16"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions