Imports without semicolons not treated as imports
See original GitHub issueOriginally reported here: https://github.com/Galooshi/atom-import-js/issues/8
I’m moving the issue to the main project as it affects all clients.
Given this content
import AppView from './AppView'
const Test = AppView;
If you import AppView, you end up with duplicate import lines. One with semicolon (added by import-js) and one without (the original).
import AppView from './AppView';
import AppView from './AppView'
const Abc = AppView;
The original bug report is for the atom plugin, but I have confirmed this bug to exist in the vim plugin as well.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:9
Top Results From Across the Web
ecmascript 6 - Does import statement need semicolon actually?
Javascript only requires semicolons to separate statements in the same line. Strictly, speaking, this is not true. It also requires semi-colons ...
Read more >Allow importing of modules that don't use semicolons #1004
The problem is not only with rollup not adding semi colons at the end of functions. The same runtime TpyeError also occurs when...
Read more >semi - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Import or link to data in an Excel workbook - Microsoft Support
You can import Excel data into Access desktop databases or link to an Excel file, which results in a linked table.
Read more >Style guide - The Apache Groovy programming language
1. No semicolons · 2. Return keyword optional · 3. Def and type · 4. Public by default · 5. Omitting parentheses ·...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is the main regex used to match imports: https://github.com/Galooshi/import-js/blob/ae73c764682d1ff9925575d0fb3969886cc6de9f/lib/ImportStatement.js#L23. Though there’s a pre-processing step that assumes semicolons higher up in the hierarchy: https://github.com/Galooshi/import-js/blob/ae73c764682d1ff9925575d0fb3969886cc6de9f/lib/findCurrentImports.js#L51
However, I’m about to kill both of those regexes in favor of a real parser. That work is ongoing in https://github.com/Galooshi/import-js/tree/better-parsing. I can’t promise anything, but I’m hoping to release that in a 2.0 in the coming month.
Of course, sorry for leaving you in the dark here.
With 2.0, import statements without semicolons at the end are already recognized. The issue that you can solve with
importStatementFormatter
is that import-js will automatically add the semicolon when it constructs new import statements. You should be able to use something like