├── .devcontainer ├── Dockerfile └── devcontainer.json ├── .eslintignore ├── .eslintrc.js ├── .github ├── FUNDING.yml └── workflows │ ├── NodeCI.yml │ ├── NpmPublish.yml │ └── stale.yml ├── .gitignore ├── .npmrc ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── astro.js ├── html.js ├── index.js ├── package.json ├── php.js ├── renovate.json ├── svelte.js ├── tests ├── fixtures │ └── integrations │ │ └── stylelint │ │ ├── .npmrc │ │ ├── package.json │ │ ├── src │ │ ├── invalid.astro │ │ ├── invalid.html │ │ ├── invalid.svelte │ │ ├── invalid.vue │ │ ├── valid.astro │ │ ├── valid.html │ │ ├── valid.php │ │ ├── valid.svelte │ │ └── valid.vue │ │ └── stylelint.config.js └── lib │ └── index.js ├── vue.js └── xml.js /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.202.5/containers/javascript-node/.devcontainer/base.Dockerfile 2 | 3 | # [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 16, 14, 12, 16-bullseye, 14-bullseye, 12-bullseye, 16-buster, 14-buster, 12-buster 4 | ARG VARIANT="16-bullseye" 5 | FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT} 6 | 7 | # [Optional] Uncomment this section to install additional OS packages. 8 | # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ 9 | # && apt-get -y install --no-install-recommends 10 | 11 | # [Optional] Uncomment if you want to install an additional version of node using nvm 12 | # ARG EXTRA_NODE_VERSION=10 13 | # RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}" 14 | 15 | # [Optional] Uncomment if you want to install more global node modules 16 | # RUN su node -c "npm install -g " 17 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: 2 | // https://github.com/microsoft/vscode-dev-containers/tree/v0.202.5/containers/javascript-node 3 | { 4 | "name": "Node.js", 5 | "runArgs": ["--init"], 6 | "build": { 7 | "dockerfile": "Dockerfile", 8 | // Update 'VARIANT' to pick a Node version: 16, 14, 12. 9 | // Append -bullseye or -buster to pin to an OS version. 10 | // Use -bullseye variants on local arm64/Apple Silicon. 11 | "args": { "VARIANT": "14" } 12 | }, 13 | 14 | // Set *default* container specific settings.json values on container create. 15 | "settings": {}, 16 | 17 | // Add the IDs of extensions you want installed when the container is created. 18 | "extensions": [ 19 | "dbaeumer.vscode-eslint" 20 | ], 21 | 22 | // Use 'forwardPorts' to make a list of ports inside the container available locally. 23 | // "forwardPorts": [], 24 | 25 | // Use 'postCreateCommand' to run commands after the container is created. 26 | "postCreateCommand": "npm install", 27 | 28 | // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. 29 | "remoteUser": "node" 30 | } 31 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /.nyc_output 2 | /coverage 3 | node_modules 4 | !/.vscode 5 | !/.github 6 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | module.exports = { 4 | parserOptions: { 5 | sourceType: "script", 6 | ecmaVersion: 2020, 7 | }, 8 | extends: [ 9 | "plugin:@ota-meshi/recommended", 10 | "plugin:@ota-meshi/+node", 11 | "plugin:@ota-meshi/+json", 12 | "plugin:@ota-meshi/+yaml", 13 | "plugin:@ota-meshi/+prettier", 14 | ], 15 | }; 16 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: ota-meshi 4 | # patreon: # Replace with a single Patreon username 5 | # open_collective: # Replace with a single Open Collective username 6 | # ko_fi: # Replace with a single Ko-fi username 7 | # tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | # community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | # liberapay: # Replace with a single Liberapay username 10 | # issuehunt: # Replace with a single IssueHunt username 11 | # otechie: # Replace with a single Otechie username 12 | # custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/workflows/NodeCI.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | 9 | jobs: 10 | lint: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v4 14 | - uses: actions/setup-node@v4 15 | with: 16 | node-version: 16 17 | - name: Install Packages 18 | run: npm i --legacy-peer-deps 19 | - name: Lint 20 | run: npm run lint 21 | test: 22 | runs-on: ubuntu-latest 23 | strategy: 24 | matrix: 25 | node-version: [12.x, 14.x, 16.x] 26 | steps: 27 | - uses: actions/checkout@v4 28 | - name: Use Node.js ${{ matrix.node-version }} 29 | uses: actions/setup-node@v4 30 | with: 31 | node-version: ${{ matrix.node-version }} 32 | - name: Install Packages 33 | run: npm i --legacy-peer-deps 34 | - name: Test 35 | run: npm test 36 | -------------------------------------------------------------------------------- /.github/workflows/NpmPublish.yml: -------------------------------------------------------------------------------- 1 | name: publish 2 | on: 3 | push: 4 | tags: 5 | - "*" 6 | jobs: 7 | release: 8 | name: check version, and release 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: checkout 12 | uses: actions/checkout@v4 13 | - name: setup Node 14 | uses: actions/setup-node@v4 15 | with: 16 | registry-url: "https://registry.npmjs.org" 17 | - name: Install Packages 18 | run: npm i --legacy-peer-deps 19 | - name: test 20 | run: npm run test 21 | - name: check can npm-publish 22 | run: npx can-npm-publish 23 | - name: release 24 | run: npm publish 25 | env: 26 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 27 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: Close stale issues and PRs 2 | on: 3 | schedule: 4 | - cron: "30 1 * * *" 5 | 6 | permissions: 7 | issues: write 8 | pull-requests: write 9 | 10 | jobs: 11 | stale: 12 | if: github.repository == 'ota-meshi/stylelint-config-html' 13 | name: Close stale issues with missing information 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/stale@v9 17 | with: 18 | any-of-labels: "needs repro,needs info,needs more info" 19 | days-before-stale: 60 20 | days-before-close: 14 21 | stale-issue-message: This issue is is stale because it missing information and has been open for 60 days with no activity. 22 | stale-pr-message: This PR is is stale because it missing information and has been open for 60 days with no activity. 23 | close-issue-message: > 24 | This issue has been automatically closed because we haven't received a 25 | response from the original author 🙈. This automation helps keep the issue 26 | tracker clean from issues that aren't actionable. Please reach out if you 27 | have more information for us! 🙂 28 | close-pr-message: > 29 | This PR has been automatically closed because we haven't received a 30 | response from the original author 🙈. This automation helps keep the issue 31 | tracker clean from PRs that aren't actionable. Please reach out if you 32 | have more information for us! 🙂 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "eslint.validate": ["javascript", "javascriptreact", "json", "jsonc", "yaml"] 3 | } 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Yosuke Ota 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # stylelint-config-html 2 | 3 | [![NPM license](https://img.shields.io/npm/l/stylelint-config-html.svg)](https://www.npmjs.com/package/stylelint-config-html) 4 | [![NPM version](https://img.shields.io/npm/v/stylelint-config-html.svg)](https://www.npmjs.com/package/stylelint-config-html) 5 | [![NPM downloads](https://img.shields.io/npm/dw/stylelint-config-html.svg)](http://www.npmtrends.com/stylelint-config-html) 6 | [![NPM downloads](https://img.shields.io/npm/dm/stylelint-config-html.svg)](http://www.npmtrends.com/stylelint-config-html) 7 | [![Build Status](https://github.com/ota-meshi/stylelint-config-html/workflows/CI/badge.svg?branch=main)](https://github.com/ota-meshi/stylelint-config-html/actions?query=workflow%3ACI) 8 | 9 | > The shareable HTML (and HTML-like) config for [Stylelint]. 10 | 11 | This config bundles the [`postcss-html` custom syntax](https://github.com/ota-meshi/postcss-html) and configures it. 12 | If you use this config in your Stylelint config, HTML, XML, [Vue], [Svelte], [Astro], and [PHP] files will be parsable. The Stylelint rules you have configured will be able to check these files. 13 | 14 | > **Requirements** 15 | > 16 | > - [Stylelint] v14.0.0 and above 17 | > This config cannot be used with Stylelint v13 and below. Also, if you are using Stylelint v13, you do not need to use this config. 18 | 19 | Stylelint v14 and above has been changed to not bundle non-CSS parsing such as HTML. The goal of this config is to make Stylelint v14 work with HTML (and HTML-like) files, like Stylelint v13. 20 | 21 | To see this config, please read the [config itself](/index.js). 22 | 23 | ## :couple: Related Packages 24 | 25 | ### [stylelint-config-recommended-vue](https://github.com/ota-meshi/stylelint-config-recommended-vue) / [stylelint-config-standard-vue](https://github.com/ota-meshi/stylelint-config-standard-vue) 26 | 27 | The shareable config for [Vue](https://v3.vuejs.org/). 28 | If you want to check [Vue] files, consider using this as well. It is useful because it contains the config for [Vue](https://v3.vuejs.org/). 29 | 30 | ### [postcss-html](https://github.com/ota-meshi/postcss-html) 31 | 32 | [PostCSS] syntax for parsing HTML (and HTML-like). 33 | If you have problems with parses using this config, please open the new issue in that repository. 34 | 35 | ## :cd: Installation 36 | 37 | ```shell 38 | npm install --save-dev postcss-html stylelint-config-html 39 | ``` 40 | 41 | ## :book: Usage 42 | 43 | Set your `stylelint` config to: 44 | 45 | ```json 46 | { 47 | "extends": "stylelint-config-html" 48 | } 49 | ``` 50 | 51 | Note: This config enables HTML (and HTML-like) syntax parsing. 52 | 53 | If you want to enable parsing for only specific language, use each language config as follows: 54 | 55 | ```json 56 | { 57 | "extends": [ 58 | "stylelint-config-html/html", 59 | "stylelint-config-html/xml", 60 | "stylelint-config-html/vue", 61 | "stylelint-config-html/svelte", 62 | "stylelint-config-html/astro", 63 | "stylelint-config-html/php" 64 | ] 65 | } 66 | ``` 67 | 68 | ## :computer: Editor integrations 69 | 70 | ### Visual Studio Code 71 | 72 | Use the [stylelint.vscode-stylelint](https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint) extension that [Stylelint] provides officially. 73 | 74 | You have to configure the `stylelint.validate` option of the extension to check `.html`, `.vue`, `.svelte`, `.astro`, and HTML-like files, because the extension does not check the `*.html` and HTML-like file by default. 75 | 76 | Example **.vscode/settings.json**: 77 | 78 | ```jsonc 79 | { 80 | "stylelint.validate": [ 81 | ..., 82 | // ↓ Add "html" language. 83 | "html", 84 | // ↓ Add "vue" language. 85 | "vue", 86 | // ↓ Add "svelte" language. 87 | "svelte", 88 | // ↓ Add "astro" language. 89 | "astro", 90 | ] 91 | ``` 92 | 93 | ## :lock: License 94 | 95 | See the [LICENSE](LICENSE) file for license rights and limitations (MIT). 96 | 97 | [Stylelint]: https://stylelint.io/ 98 | [Vue]: https://v3.vuejs.org/guide/single-file-component.html 99 | [Svelte]: https://svelte.dev/docs#Component_format 100 | [Astro]: https://docs.astro.build/core-concepts/astro-components/ 101 | [PHP]: https://www.php.net/manual/en/intro-whatis.php 102 | [PostCss]: https://github.com/postcss/postcss 103 | -------------------------------------------------------------------------------- /astro.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const extensions = [ 4 | // https://github.com/withastro/language-tools/blob/main/packages/vscode/package.json 5 | ".astro", 6 | ]; 7 | module.exports = { 8 | overrides: [ 9 | { 10 | files: extensions.flatMap((ext) => [`*${ext}`, `**/*${ext}`]), 11 | customSyntax: "postcss-html", 12 | }, 13 | ], 14 | }; 15 | -------------------------------------------------------------------------------- /html.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const extensions = [ 4 | // https://github.com/Microsoft/vscode/blob/master/extensions/html/package.json 5 | ".html", 6 | ".htm", 7 | ".shtml", 8 | ".xhtml", 9 | ".xht", 10 | ".mdoc", 11 | ".jsp", 12 | ".asp", 13 | ".aspx", 14 | ".jshtm", 15 | ".volt", 16 | ".ejs", 17 | ".rhtml", 18 | ]; 19 | 20 | module.exports = { 21 | overrides: [ 22 | { 23 | files: extensions.flatMap((ext) => [`*${ext}`, `**/*${ext}`]), 24 | customSyntax: "postcss-html", 25 | }, 26 | ], 27 | }; 28 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | module.exports = { 4 | extends: [ 5 | require.resolve("./html.js"), 6 | require.resolve("./vue.js"), 7 | require.resolve("./php.js"), 8 | require.resolve("./svelte.js"), 9 | require.resolve("./astro.js"), 10 | require.resolve("./xml.js"), 11 | ], 12 | }; 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "stylelint-config-html", 3 | "version": "1.1.0", 4 | "description": "The shareable HTML config for Stylelint.", 5 | "keywords": [ 6 | "stylelint", 7 | "stylelint-config", 8 | "html", 9 | "vue", 10 | "svelte", 11 | "php", 12 | "xml" 13 | ], 14 | "main": "index.js", 15 | "files": [ 16 | "index.js", 17 | "html.js", 18 | "vue.js", 19 | "svelte.js", 20 | "astro.js", 21 | "php.js", 22 | "xml.js" 23 | ], 24 | "engines": { 25 | "node": "^12 || >=14" 26 | }, 27 | "scripts": { 28 | "test": "mocha \"tests/lib/**/*.js\" --reporter dot --timeout 60000", 29 | "lint": "eslint .", 30 | "eslint-fix": "eslint . --fix", 31 | "preversion": "npm test && git add ." 32 | }, 33 | "peerDependencies": { 34 | "stylelint": ">=14.0.0", 35 | "postcss-html": "^1.0.0" 36 | }, 37 | "devDependencies": { 38 | "@ota-meshi/eslint-plugin": "^0.15.0", 39 | "eslint": "^8.0.0", 40 | "eslint-config-prettier": "^10.0.0", 41 | "eslint-plugin-eslint-comments": "^3.2.0", 42 | "eslint-plugin-json-schema-validator": "^5.0.0", 43 | "eslint-plugin-jsonc": "^2.0.0", 44 | "eslint-plugin-n": "^17.0.0", 45 | "eslint-plugin-prettier": "^5.0.0", 46 | "eslint-plugin-regexp": "^2.0.0", 47 | "eslint-plugin-vue": "^10.0.0", 48 | "eslint-plugin-yml": "^1.0.0", 49 | "mocha": "^10.0.0", 50 | "prettier": "^3.0.0" 51 | }, 52 | "repository": { 53 | "type": "git", 54 | "url": "git+https://github.com/ota-meshi/stylelint-config-html.git" 55 | }, 56 | "author": "Yosuke Ota (https://github.com/ota-meshi)", 57 | "funding": "https://github.com/sponsors/ota-meshi", 58 | "license": "MIT", 59 | "bugs": { 60 | "url": "https://github.com/ota-meshi/stylelint-config-html/issues" 61 | }, 62 | "homepage": "https://github.com/ota-meshi/stylelint-config-html#readme" 63 | } 64 | -------------------------------------------------------------------------------- /php.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const extensions = [ 4 | // https://github.com/Microsoft/vscode/blob/main/extensions/php/package.json 5 | ".php", 6 | ".php4", 7 | ".php5", 8 | ".phtml", 9 | ".ctp", 10 | ]; 11 | 12 | module.exports = { 13 | overrides: [ 14 | { 15 | files: extensions.flatMap((ext) => [`*${ext}`, `**/*${ext}`]), 16 | customSyntax: "postcss-html", 17 | }, 18 | ], 19 | }; 20 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base", 4 | ":preserveSemverRanges", 5 | ":disableDependencyDashboard" 6 | ], 7 | "packageRules": [ 8 | { 9 | "updateTypes": ["minor", "patch", "pin", "digest"], 10 | "automerge": true 11 | }, 12 | { 13 | "depTypeList": ["devDependencies"], 14 | "automerge": true 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /svelte.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const extensions = [ 4 | // https://github.com/sveltejs/language-tools/blob/master/packages/svelte-vscode/package.json 5 | ".svelte", 6 | ]; 7 | module.exports = { 8 | overrides: [ 9 | { 10 | files: extensions.flatMap((ext) => [`*${ext}`, `**/*${ext}`]), 11 | customSyntax: "postcss-html", 12 | }, 13 | ], 14 | }; 15 | -------------------------------------------------------------------------------- /tests/fixtures/integrations/stylelint/.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /tests/fixtures/integrations/stylelint/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "stylelint-config-html-test-stylelint", 3 | "private": true, 4 | "version": "1.0.0", 5 | "description": "", 6 | "devDependencies": { 7 | "postcss-html": "^1.5.0", 8 | "stylelint": "^14.0.0-0", 9 | "stylelint-config-html": "file:../../../../", 10 | "stylelint-config-recommended": "^6.0.0-0" 11 | }, 12 | "engines": { 13 | "node": "^12 || >=14" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/fixtures/integrations/stylelint/src/invalid.astro: -------------------------------------------------------------------------------- 1 | --- 2 | let value, input, style, bar 3 | const foo = 100 42 4 | --- 5 | 6 | 100 ? 'over-100' : ''}`} style="color: #00;" /> 7 | -------------------------------------------------------------------------------- /tests/fixtures/integrations/stylelint/src/invalid.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 14 |

Test

15 | 16 | 17 | -------------------------------------------------------------------------------- /tests/fixtures/integrations/stylelint/src/invalid.svelte: -------------------------------------------------------------------------------- 1 | 4 | 100) ) } bind:value={value} style="color: #ff"> 5 | -------------------------------------------------------------------------------- /tests/fixtures/integrations/stylelint/src/invalid.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/integrations/stylelint/src/valid.astro: -------------------------------------------------------------------------------- 1 | --- 2 | let value, input, style, bar 3 | const foo = 100 42 4 | --- 5 | 6 | 100 ? 'over-100' : ''}`} style="color: #000;" /> 7 | -------------------------------------------------------------------------------- /tests/fixtures/integrations/stylelint/src/valid.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 14 |

Test

15 | 16 | 17 | -------------------------------------------------------------------------------- /tests/fixtures/integrations/stylelint/src/valid.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/integrations/stylelint/src/valid.svelte: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/integrations/stylelint/src/valid.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/integrations/stylelint/stylelint.config.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | module.exports = { 4 | extends: ["stylelint-config-recommended", "stylelint-config-html"], 5 | }; 6 | -------------------------------------------------------------------------------- /tests/lib/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const { fail } = require("assert"); 4 | const cp = require("child_process"); 5 | const path = require("path"); 6 | 7 | const STYLELINT = `.${path.sep}node_modules${path.sep}.bin${path.sep}stylelint`; 8 | 9 | describe("Integration with stylelint", () => { 10 | let originalCwd; 11 | 12 | before(() => { 13 | originalCwd = process.cwd(); 14 | process.chdir(path.join(__dirname, "../fixtures/integrations/stylelint")); 15 | cp.execSync("npm i --no-package-lock --legacy-peer-deps", { 16 | stdio: "inherit", 17 | }); 18 | }); 19 | after(() => { 20 | process.chdir(originalCwd); 21 | }); 22 | 23 | it("should lint without errors with html", () => { 24 | cp.execSync(`${STYLELINT} src/valid.html`, { stdio: "inherit" }); 25 | }); 26 | it("should lint without errors with vue", () => { 27 | cp.execSync(`${STYLELINT} src/valid.vue`, { stdio: "inherit" }); 28 | }); 29 | it("should lint without errors with svelte", () => { 30 | cp.execSync(`${STYLELINT} src/valid.svelte`, { stdio: "inherit" }); 31 | }); 32 | it("should lint without errors with astro", () => { 33 | cp.execSync(`${STYLELINT} src/valid.astro`, { stdio: "inherit" }); 34 | }); 35 | it("should lint without errors with php", () => { 36 | cp.execSync(`${STYLELINT} src/valid.php`, { stdio: "inherit" }); 37 | }); 38 | it("should lint with errors with html", () => { 39 | try { 40 | cp.execSync(`${STYLELINT} src/invalid.html`, { stdio: "inherit" }); 41 | fail("Expect an error, but without errors"); 42 | } catch { 43 | // Expected! 44 | } 45 | }); 46 | it("should lint with errors with vue", () => { 47 | try { 48 | cp.execSync(`${STYLELINT} src/invalid.vue`, { stdio: "inherit" }); 49 | fail("Expect an error, but without errors"); 50 | } catch { 51 | // Expected! 52 | } 53 | }); 54 | it("should lint with errors with svelte", () => { 55 | try { 56 | cp.execSync(`${STYLELINT} src/invalid.svelte`, { stdio: "inherit" }); 57 | fail("Expect an error, but without errors"); 58 | } catch { 59 | // Expected! 60 | } 61 | }); 62 | it("should lint with errors with astro", () => { 63 | try { 64 | cp.execSync(`${STYLELINT} src/invalid.astro`, { stdio: "inherit" }); 65 | fail("Expect an error, but without errors"); 66 | } catch { 67 | // Expected! 68 | } 69 | }); 70 | }); 71 | -------------------------------------------------------------------------------- /vue.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const extensions = [ 4 | // https://v3.vuejs.org/api/sfc-spec.html 5 | ".vue", 6 | ]; 7 | module.exports = { 8 | overrides: [ 9 | { 10 | files: extensions.flatMap((ext) => [`*${ext}`, `**/*${ext}`]), 11 | customSyntax: "postcss-html", 12 | }, 13 | ], 14 | }; 15 | -------------------------------------------------------------------------------- /xml.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const extensions = [ 4 | // https://github.com/Microsoft/vscode/blob/master/extensions/xml/package.json 5 | ".xml", 6 | ".xsd", 7 | ".ascx", 8 | ".atom", 9 | ".axml", 10 | ".axaml", 11 | ".bpmn", 12 | ".cpt", 13 | ".csl", 14 | ".csproj", 15 | ".csproj.user", 16 | ".dita", 17 | ".ditamap", 18 | ".dtd", 19 | ".ent", 20 | ".mod", 21 | ".dtml", 22 | ".fsproj", 23 | ".fxml", 24 | ".iml", 25 | ".isml", 26 | ".jmx", 27 | ".launch", 28 | ".menu", 29 | ".mxml", 30 | ".nuspec", 31 | ".opml", 32 | ".owl", 33 | ".proj", 34 | ".props", 35 | ".pt", 36 | ".publishsettings", 37 | ".pubxml", 38 | ".pubxml.user", 39 | ".rbxlx", 40 | ".rbxmx", 41 | ".rdf", 42 | ".rng", 43 | ".rss", 44 | ".shproj", 45 | ".storyboard", 46 | ".svg", 47 | ".targets", 48 | ".tld", 49 | ".tmx", 50 | ".vbproj", 51 | ".vbproj.user", 52 | ".vcxproj", 53 | ".vcxproj.filters", 54 | ".wsdl", 55 | ".wxi", 56 | ".wxl", 57 | ".wxs", 58 | ".xaml", 59 | ".xbl", 60 | ".xib", 61 | ".xlf", 62 | ".xliff", 63 | ".xpdl", 64 | ".xul", 65 | ".xoml", 66 | 67 | // xsl 68 | ".xsl", 69 | ".xslt", 70 | ]; 71 | module.exports = { 72 | overrides: [ 73 | { 74 | files: extensions.flatMap((ext) => [`*${ext}`, `**/*${ext}`]), 75 | customSyntax: "postcss-html", 76 | }, 77 | ], 78 | }; 79 | --------------------------------------------------------------------------------