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

Different newline behaviour in 1.0 #10

Closed
ai opened this issue Jun 9, 2019 · 5 comments · Fixed by #11
Closed

Different newline behaviour in 1.0 #10

ai opened this issue Jun 9, 2019 · 5 comments · Fixed by #11

Comments

@ai
Copy link
Contributor

ai commented Jun 9, 2019

ESLint config:

    'import-helpers/order-imports': ['error', {
      groups: [
        ['absolute', 'module'],
        ['parent', 'sibling', 'index']
      ],
      newlinesBetween: 'always'
    }],

Expected code after --fix

let { addPrometheus, addScaling } = require('@evilmartians/logux-server-pro')
let { Server } = require('@logux/server')
let path = require('path')
let fs = require('fs')

Actual code after --fix (also ESLint show error on previous code)

let { addPrometheus, addScaling } = require('@evilmartians/logux-server-pro')

let { Server } = require('@logux/server')

let path = require('path')
let fs = require('fs')

How I can ask the plugin to not force me to insert a newline in this example?

@ai
Copy link
Contributor Author

ai commented Jun 9, 2019

@Tibfib seems like plugin have some problem with modules started with @

var CrossTabClient = require('@logux/client/cross-tab-client')

var isFirstOlder = require('@logux/core/is-first-older')

var createStore = require('redux').createStore
var NanoEvents = require('nanoevents')

Here is the same issue. Plugin force me to put newline after @logux/… imports.

@willhoney7
Copy link
Owner

willhoney7 commented Jun 9, 2019

Oh, you’re right!

I see the problem. It’s the regular expression here. It’s not recognizing the @ symbol and classifying it correctly. https://github.com/Tibfib/eslint-plugin-import-helpers/blob/80658479f8c0039a02f99a6c20fc4b5af6e7ffe5/src/util/import-type.ts#L5

I’m on my phone now, I’ll see if I can fix it and have a new release within the next couple of days.

Of course, PRs welcome if you have the chance.

@ai
Copy link
Contributor Author

ai commented Jun 9, 2019

Sure, I will try to send PR in next 40 minutes

@willhoney7
Copy link
Owner

Any other characters you would start an import path with? @ _ \w

I think the regex could either be: /^[_@\w]/ or validate anything not starting with . or / (on my phone and can’t remember the exact regex syntax)

@ai
Copy link
Contributor Author

ai commented Jun 9, 2019

I sent PR

#11

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

Successfully merging a pull request may close this issue.

2 participants