BenoitZugmeyer / eslint-plugin-html

An ESLint plugin to extract and lint scripts from HTML files.
ISC License
430 stars 51 forks source link

Honor @type of <script> to decide on the `sourceType` used #91

Closed mnoorenberghe closed 6 years ago

mnoorenberghe commented 6 years ago

Right now it seems like sourceType for the file will be applied to all <script> in the HTML files. This means that out-of-the-box the following…

…<script type="module">import "foo";</script>…

will give a linting error:

Parsing error: 'import' and 'export' may appear only with 'sourceType: module' (eslint)

even though the import is inside a module scope. <script type="module"> should force the block to be treated as a module source.

BenoitZugmeyer commented 6 years ago

I thought about it initially, but this duplicates the ESLint configuration. Also some other script type may be considered as modules (ex: text/babel), so it should be configurable.

For the sake of simplicity, let's follow the ESLint way here.