ESLint plugin to lint script tags in HTML.
npm install @nice-move/eslint-plugin-html --save-dev
// eslintrc.js
module.exports = {
extends: ['plugin:@nice-move/html/recommended']
};
// or
module.exports = {
extends: ['plugin:@nice-move/html/base']
};
// or
module.exports = {
overrides: [
{
files: ['*.{htm,html}'],
plugins: ['@nice-move/eslint-plugin-html']
},
{
files: ['**/*.{htm,html}/**/html-script-legacy.js'],
parserOptions: {
sourceType: 'script'
}
},
{
files: ['**/*.{htm,html}/**/html-script-module.js'],
parserOptions: {
sourceType: 'module'
}
}
]
};
- SVG support
Different from eslint-plugin-html
@nice-move/eslint-plugin-html
using processor to treat <script>
and <script type="module">
differently.
See: BenoitZugmeyer/eslint-plugin-html#139
And @nice-move/eslint-plugin-html
is bundle-able.
Visual Studio Code support
When using Eslint for VS Code, you may need to add following code to settings:
// example: settings.json or .vscode/settings.json
// I don't know why `eslint-plugin-html` don't need this.
{
"eslint.validate": ["html"]
}
Not compatible with import/first rule.
See: import-js/eslint-plugin-import#2407
<script>
console.log('this example trigger error');
import 'http://something';
</script>
See: Reason why