Coder Social home page Coder Social logo

Comments (3)

Calvin-LL avatar Calvin-LL commented on July 26, 2024 3

I made a parser that runs vue-parser on vue code before parsing imports. Should hopfully solve everyone's problem. https://www.npmjs.com/package/import-sort-parser-babel-vue

from import-sort.

schnetzi avatar schnetzi commented on July 26, 2024

As mentioned here (#61 (comment)) currently my imports from the style-part are getting moved to the script-part. Which doesn't work of course :/ Can I prevent that somehow?

from import-sort.

juliovedovatto avatar juliovedovatto commented on July 26, 2024

@renke I noticed strange behavior using 'vue/script-indent': ['error', 2, { baseIndent: 1 }] eslint rule

Current config:

{
  ".js, .jsx, .es6, .es": {
    "parser": "babylon",
    "style": "eslint",
    "options": {}
  },
  ".ts, .tsx, .vue": {
    "parser": "typescript",
    "style": "eslint",
    "options": {}
  }
}

Plugin works well with .js(x) and .ts(x), but not for .vue files.

Original:

<template>
[...]
</template>

<script lang="ts">
  import { func } from 'a'
  import * as x from 'b'
  import c from c

[...]
</script>

<style>
[...]
</style>

Expected

<template>
[...]
</template>

<script lang="ts">
  import * as x from 'b'

  import c from c
  import { func } from 'a'
  
[...]
</script>

<style>
[...]
</style>

What is returned:

<template>
[...]
</template>

<script lang="ts">

import * as x from 'b'

import c from c
import { func } from 'a'
  
[...]
</script>

<style>
[...]
</style>

Problems:

  • Sort imports ignores the base indent rule
  • Adds a extra line before first import (as mentioned in #52)

I tried to debug code and run written tests to check the root cause, but 3 days in a row and no luck to reverse engineer and understand what was made.

I was wondering if it would be possible to use CLIEngine eslint lib to check and apply any pending eslint rules before replacing the output.

from import-sort.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.