Skip to content

Commit 8a40fec

Browse files
mfranzkeCopilot
andauthored
feat: added stylelint-config-if-function package (#53)
* feat: added stylelint-config-if-function package * Update README.md * Update README.md * Create big-timers-jump.md * Update packages/stylelint-config-if-function/package.json Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update package.json Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * refactor: regenerated pnpm lock file * refactor: regenerated pnpm lock file --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 0b7e437 commit 8a40fec

File tree

11 files changed

+443
-3
lines changed

11 files changed

+443
-3
lines changed

.changeset/big-timers-jump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"stylelint-config-if-function": patch
3+
---
4+
5+
feat: added stylelint-config-if-function package

.config/.stylelintrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": [
3+
"stylelint-config-standard",
4+
"../packages/stylelint-config-if-function/dist/index.cjs"
5+
]
6+
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# CSS if() Function Polyfill and PostCSS plugin
1+
# CSS if() Function Polyfill, PostCSS plugin and Stylelint plugin
22

33
[![MIT license](https://img.shields.io/npm/l/css-if-polyfill.svg "license badge")](https://opensource.org/licenses/mit-license.php)
44
[![Default CI/CD Pipeline](https://github.com/mfranzke/css-if-polyfill/actions/workflows/default.yml/badge.svg)](https://github.com/mfranzke/css-if-polyfill/actions/workflows/default.yml)
@@ -9,7 +9,7 @@
99
[![Open Source Love](https://badges.frapsoft.com/os/v3/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/)
1010
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](CODE-OF-CONDUCT.md)
1111

12-
A modern JavaScript [polyfill](https://github.com/mfranzke/css-if-polyfill/tree/main/packages/css-if-polyfill) and [PostCSS plugin](https://github.com/mfranzke/css-if-polyfill/tree/main/packages/postcss-if-function) for the [CSS `if()` function](https://developer.mozilla.org/en-US/docs/Web/CSS/if) with **hybrid build-time and runtime processing**. Transforms CSS `if()` functions to native `@media` and `@supports` rules where possible, with runtime fallback for dynamic conditions.
12+
A modern JavaScript [polyfill](https://github.com/mfranzke/css-if-polyfill/tree/main/packages/css-if-polyfill), [PostCSS plugin](https://github.com/mfranzke/css-if-polyfill/tree/main/packages/postcss-if-function) and a [Stylelint plugin](stylelint-config-if-function) (to extend to prevent lint errors) for the [CSS `if()` function](https://developer.mozilla.org/en-US/docs/Web/CSS/if) with **hybrid build-time and runtime processing**. Transforms CSS `if()` functions to native `@media` and `@supports` rules where possible, with runtime fallback for dynamic conditions.
1313

1414
## Contributing
1515

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
"dev": "pnpm --recursive run dev",
3333
"lint": "pnpm --parallel run '/^lint:[^:]*$/'",
3434
"lint:markdownlint": "markdownlint --config .config/.markdown-lint.yml **/*.md",
35-
"lint:packages": "publint packages/css-if-polyfill && publint packages/postcss-if-function",
35+
"lint:packages": "publint packages/css-if-polyfill && publint packages/postcss-if-function && publint packages/stylelint-config-if-function",
36+
"lint:stylelint": "stylelint test/fixtures/basic-media.input.css --config .config/.stylelintrc.json",
37+
"lint:stylelint:14": "npx stylelint@14 test/fixtures/*.input.css --config .config/.stylelintrc.json",
38+
"lint:stylelint:15": "npx stylelint@15 test/fixtures/*.input.css --config .config/.stylelintrc.json",
3639
"lint:xo": "xo",
3740
"prelint:packages": "pnpm run build",
3841
"prepare": "husky",
@@ -58,6 +61,8 @@
5861
"prettier-plugin-organize-imports": "4.2.0",
5962
"prettier-plugin-pkg": "0.21.2",
6063
"publint": "0.3.12",
64+
"stylelint": "^16.23.0",
65+
"stylelint-config-standard": "^39.0.0",
6166
"vite": "7.0.6",
6267
"vitest": "3.2.4",
6368
"xo": "1.1.1"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/*
2+
/*/
3+
!/dist/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# stylelint-config-if-function
2+
3+
_tbd_
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Maximilian Franzke
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.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# stylelint-config-if-function
2+
3+
A shareable Stylelint config to support the experimental CSS `if()` function syntax.
4+
5+
## Installation
6+
7+
```bash
8+
npm install --save-dev stylelint stylelint-config-if-function
9+
```
10+
11+
## Configuration
12+
13+
```json
14+
{
15+
"extends": ["stylelint-config-standard", "stylelint-config-if-function"]
16+
}
17+
```
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "stylelint-config-if-function",
3+
"version": "0.0.0",
4+
"type": "module",
5+
"description": "Shareable stylelint config for CSS if() function support",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/mfranzke/css-if-polyfill.git"
9+
},
10+
"bugs": {
11+
"url": "https://github.com/mfranzke/css-if-polyfill/issues"
12+
},
13+
"author": "Maximilian Franzke",
14+
"license": "MIT",
15+
"main": "dist/index.cjs",
16+
"exports": {
17+
"require": "./dist/index.cjs",
18+
"import": "./dist/index.modern.js"
19+
},
20+
"files": [
21+
"dist/",
22+
"README.md",
23+
"LICENSE"
24+
],
25+
"keywords": [
26+
"stylelint",
27+
"config",
28+
"if",
29+
"css",
30+
"function"
31+
],
32+
"scripts": {
33+
"build": "microbundle",
34+
"prepublishOnly": "pnpm run build"
35+
},
36+
"peerDependencies": {
37+
"stylelint": "^14.5.1 || ^15.0.0 || ^16.0.0"
38+
},
39+
"devDependencies": {
40+
"microbundle": "0.15.1"
41+
},
42+
"source": "src/index.js"
43+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const config = {
2+
rules: {
3+
'declaration-property-value-no-unknown': [
4+
true,
5+
{
6+
ignoreProperties: {
7+
'/.+/': ['/^if(.*)/']
8+
}
9+
}
10+
],
11+
'function-no-unknown': [
12+
true,
13+
{
14+
ignoreFunctions: ['if', 'media', 'supports', 'style']
15+
}
16+
]
17+
}
18+
};
19+
20+
export default config;

0 commit comments

Comments
 (0)