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

Import Helper does not respect eslint/prettier rules #97

Open
tukusejssirs opened this issue Apr 20, 2021 · 11 comments
Open

Import Helper does not respect eslint/prettier rules #97

tukusejssirs opened this issue Apr 20, 2021 · 11 comments
Assignees
Labels

Comments

@tukusejssirs
Copy link

I prefer no spaces after { and before }, and no semicolon after commands. I have set eslint and prettier accordingly.

However, I could not find a way to make Import Helper respect these settings. Is there a way to configure this?

Thanks for this great plugin! 😉

@unlight
Copy link
Owner

unlight commented Apr 20, 2021

Sorry, no. There is only one setting from_quote
It is not possible to take into account all potential code fixers, stylers and formatters.

I think, you can configure your editor to apply eslint --fix on save.

@tukusejssirs
Copy link
Author

I think, you can configure your editor to apply eslint --fix on save.

Yes, I use that workaround, but I hoped we could insert the import correctly formatted.


I looked at the code, but I don’t code in Python. I’d like to change the hard-coded formatting to my preffered one (in my fork), but I was lost. Could you point me to the rignt file/line? Thanks. 😉

@unlight
Copy link
Owner

unlight commented Apr 20, 2021

Actually there is no formatting in python code.
Python sends code to nodejs process and library import-adjutor actually do inserting.

You need to check insertImport command https://github.com/unlight/import-adjutor/blob/master/src/insert-import.ts

On the other hand import-adjutor is a wrapper around ts-morph

I see that setting related to space before brace is exists there
https://github.com/dsherret/ts-morph/blob/latest/packages/ts-morph/src/options/ManipulationSettingsContainer.ts#L54

But no setting related to no semicolon

So, you need:

  1. patch import-adjutor
  2. update dependency in import-helper to use patched version
  3. build import-helper

@tukusejssirs
Copy link
Author

@unlight, I see that in 4319e8d you added no_semicolon—thanks! That is half of the problem.

If similarly to no_semicolon, we could have a setting no_spaces_in_brackets it would be awesome. It would solve everything I need! 😃

@unlight unlight self-assigned this Sep 13, 2021
unlight pushed a commit that referenced this issue Sep 16, 2021
Allow/disallow insert space after opening and before closing non empty braces
See: #97
@unlight
Copy link
Owner

unlight commented Sep 16, 2021

@tukusejssirs
Copy link
Author

Thanks for being so fast, @unlight!

However, I could not make it work. Package Control automatically upgraded the package to v4.1.0. I have the following in the package-specific settings:

{
  "autocomplete_auto_import": true,
  "insert_space_in_braces": false,
  "no_semicolon": true
}

When I add an import using Import Helper, it still added spaces in brackets and semicolons at the end of the line. I tested this in a third-party project though, where .eslint is configured to to use spaces in brackets and semicolons, however you said that Import Helper does not care about the settings of eslint.

@unlight
Copy link
Owner

unlight commented Sep 18, 2021

Where do you keep these settings? Package/User/import_helper.settings or in sublime-project file?

@tukusejssirs
Copy link
Author

I open the settings file via PreferencesPackage SettingsImport Helper, which opens the package settings on the left and user settings (overrides) on the right. The user settings file is located in ~/.config/sublime-text/Packages/User/import_helper.sublime-settings.

@unlight
Copy link
Owner

unlight commented Sep 18, 2021

Sorry, but I cant reproduce this.
Check settings in sublime project file, it has more priority.

@tukusejssirs
Copy link
Author

I’ve just checked it and now it works. Maybe it required a ST restart, which I didn’t do yesterday.

Anyway, it seems like it does not check the format of previously imported stuff, e.g. import { one } from './app'; is changed into import { one, two} from './app' after importing two.

@tukusejssirs
Copy link
Author

@unlight, I think we can close this issue. Although the original request is not fulfilled, my needs are satisfied. Thanks! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants