diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d45c89a..5b08a8b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,22 +50,22 @@ jobs: strategy: matrix: os: [ubuntu-latest] - node: [18, 20] + node: [18, 20, 22, 24] eslint: [latest] include: # ESLint 4.7 support: lowest version supported - os: ubuntu-latest - node: 20 + node: 24 eslint: "4.7" # ESLint 5 support: lowest version we can use to test external html plugins support - os: ubuntu-latest - node: 20 + node: 24 eslint: "5.0" # Upcoming ESLint major version support - os: ubuntu-latest - node: 20 + node: 24 eslint: next # Node 16 support: use ESLint v8 becacuse they dropped node 16 support in v9. Will be @@ -76,7 +76,7 @@ jobs: # Windows support - os: windows-latest - node: 20 + node: 24 eslint: latest steps: - uses: actions/checkout@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index d85b51a..9acc675 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +2025-05-19 v8.1.3 + +- Fix compatibility with ESLint 9.27.0 #300 +- Update dependencies + +2024-09-21 v8.1.2 + +- Fix sourceType config for ESLint 9 +- Don't require espree directly #271 + 2024-04-22 v8.1.1 - Fix compatibility with @eslint/config-inspector #267 diff --git a/README.md b/README.md index 6a96b00..547d921 100644 --- a/README.md +++ b/README.md @@ -35,16 +35,33 @@ Simply install via `npm install --save-dev eslint-plugin-html` and add the plugi configuration. See [ESLint documentation](http://eslint.org/docs/user-guide/configuring#configuring-plugins). -Example: +
+ Example with ESLint 9 and above (flat config) ```javascript +import html from "eslint-plugin-html" + +export default [ + { + files: ["**/*.html"], + plugins: { html }, + }, +] +``` + +
+ +
+ Example with ESLint 8 and below + +```json { - "plugins": [ - "html" - ] + "plugins": ["html"] } ``` +
+ ## Disabling ESLint To temporarily disable ESLint, use the `` HTML comment. Re-enable it with @@ -91,7 +108,26 @@ option](https://eslint.org/docs/user-guide/configuring#specifying-parser-options if the script are modules. `eslint-plugin-html` will use this option as well to know if the scopes should be shared (the default) or not. To change this, just set it in your ESLint configuration: +
+ESLint 9 and above (flat config) + +```javascript +export default [ + { + // ... + languageOptions: { + sourceType: "module", + }, + }, +] ``` + +
+ +
+ESLint 8 and below + +```json { "parserOptions": { "sourceType": "module" @@ -99,6 +135,8 @@ should be shared (the default) or not. To change this, just set it in your ESLin } ``` +
+ To illustrate this behavior, consider this HTML extract: ```html @@ -142,29 +180,79 @@ By default, this plugin will only consider files ending with those extensions as `.handlebars`, `.hbs`, `.htm`, `.html`, `.mustache`, `.nunjucks`, `.php`, `.tag`, `.twig`, `.we`. You can set your own list of HTML extensions by using this setting. Example: +
+ ESLint 9 and above (flat config) + ```javascript +export default [ + { + files: ["**/*.html", "**/*.we"], + plugins: { html }, + settings: { + "html/html-extensions": [".html", ".we"], // consider .html and .we files as HTML + }, + }, +] +``` + +Note: you need to specify extensions twice, which is not ideal. This should be imporved in the +future. + +
+ +
+ ESLint 8 and below + +```json { - "plugins": [ "html" ], - "settings": { - "html/html-extensions": [".html", ".we"], // consider .html and .we files as HTML - } + "plugins": ["html"], + "settings": { + "html/html-extensions": [".html", ".we"] // consider .html and .we files as HTML + } } ``` +
+ ### `html/xml-extensions` By default, this plugin will only consider files ending with those extensions as XML: `.xhtml`, `.xml`. You can set your own list of XML extensions by using this setting. Example: +
+ ESLint 9 and above (flat config) + ```javascript +export default [ + { + files: ["**/*.html"], + plugins: { html }, + settings: { + "html/xml-extensions": [".html"], // consider .html files as XML + }, + }, +] +``` + +Note: you need to specify extensions twice, which is not ideal. This should be imporved in the +future. + +
+ +
+ ESLint 8 and below + +```json { - "plugins": [ "html" ], - "settings": { - "html/xml-extensions": [".html"], // consider .html files as XML - } + "plugins": ["html"], + "settings": { + "html/xml-extensions": [".html"] // consider .html files as XML + } } ``` +
+ ### `html/indent` By default, the code between `