Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
See original GitHub issueThis seems like a really cool eslint config! I gave it a try on a typescript project with eslint config
{
"extends": ["hardcore", "hardcore/fp", "hardcore/node"],
"overrides": [
{
"files": ["*.js"],
"extends": ["hardcore/ts-for-js"],
"parserOptions": { "project": "./tsconfig.json" }
}
]
}
and get the error
/home/pong/utils/src/cookies/cookies.ts
3:1 error Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
I tried with a ts config of {}
as suggested in readme.
I am using E6 syntax and want to use the import/export
syntax. Do you know what has gone wrong here?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
'import' and 'export' may appear only with 'sourceType: module ...
I get this error since the most recent update. is it possible there this is missing somewhere in the package?
Read more >ignore eslint error: 'import' and 'export' may only appear at the ...
my solution incase other dont work "parserOptions": { "ecmaVersion": 6, "sourceType" ...
Read more >'import' and 'export' may appear only with 'sourceType: module ...
Parsing error on .vue files during typescript analysis with javascript sensor - 'import' and 'export' may appear only with 'sourceType: ...
Read more >ESLint - HackingNote
Ignore Warning: Parsing error: 'import' and 'export' may only appear at the top level. Use babel-eslint as parser and allow import/export ...
Read more >Solved: Bundle Error: 'import' and 'export' may appear onl...
Bundle Error: 'import' and 'export' may appear only with 'sourceType: ... But I meet an error after I install an es6 modules( @antv/x6...
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
Here are some useful typescript-eslint rules that work with JavaScript (they all are included in
hardcore/ts-for-js
):lines-between-class-members
require-await
return-await
await-thenable
no-floating-promises
no-misused-promises
promise-function-async
no-throw-literal
unbound-method
prefer-optional-chain
naming-convention
- I really like this one, I was able to enforce boolean naming with it (boolean names have to begin with a prefix, like is/has/should)Looks like you are facing a known issue with eslint-plugin-import and its
import/no-unused-modules
rule, see https://github.com/benmosher/eslint-plugin-import/issues/1645. I guess you should just disable this rule.Let me know if that helps.
BTW, I can see that Node.js 14 was promoted to LTS two days ago, which means now we should be able to use ES6 modules both on client side and on server side. I guess I should set
"sourceType": "module"
as default in eslint-config-hardcore then. And also discourage the use of commonjs. Created https://github.com/EvgenyOrekhov/eslint-config-hardcore/issues/164.