Skip to content

Commit

Permalink
Merge remote-tracking branch 'source/main' into temp
Browse files Browse the repository at this point in the history
  • Loading branch information
pix666 committed Dec 16, 2024
2 parents 3aa595b + 4f6bf89 commit 265340b
Show file tree
Hide file tree
Showing 9 changed files with 2,255 additions and 1,578 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Release
on:
push:
tags:
- '*'
permissions:
contents: write
jobs:
release:
name: Release On Tag
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Extract the changelog
id: changelog
run: |
TAG_NAME=${GITHUB_REF/refs\/tags\//}
READ_SECTION=false
CHANGELOG=""
while IFS= read -r line; do
if [[ "$line" =~ ^#+\ +(.*) ]]; then
if [[ "${BASH_REMATCH[1]}" == "$TAG_NAME" ]]; then
READ_SECTION=true
elif [[ "$READ_SECTION" == true ]]; then
break
fi
elif [[ "$READ_SECTION" == true ]]; then
CHANGELOG+="$line"$'\n'
fi
done < "CHANGELOG.md"
CHANGELOG=$(echo "$CHANGELOG" | awk '/./ {$1=$1;print}')
echo "changelog_content<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create the release
if: steps.changelog.outputs.changelog_content != ''
uses: softprops/action-gh-release@v2
with:
name: ${{ github.ref_name }}
body: '${{ steps.changelog.outputs.changelog_content }}'
draft: false
prerelease: false
46 changes: 11 additions & 35 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,64 +14,40 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 8
version: 9
- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 23
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
run: pnpm install --ignore-scripts
- name: Run tests
run: pnpm test
short:
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 22
- 20
- 18
- 16
name: Node.js ${{ matrix.node-version }} Quick
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 8
version: 9
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Run unit tests
run: pnpm unit
old:
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 14
- 12
name: Node.js ${{ matrix.node-version }} Quick
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 6
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: pnpm install --no-frozen-lockfile --ignore-scripts
run: pnpm install --ignore-scripts
- name: Run unit tests
run: pnpm unit
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).

## 6.0.1
## 7.0.2
* Fixed nested selector regression (by @Ulyanov-programmer).

## 7.0.1
* Fixed RegExp issue with nested comments (by @Ulyanov-programmer).

## 7.0.0
* More complex logic of when to move comments (by @Ulyanov-programmer).
* Removed Node.js 16, 14, and 12 support.

## 6.2.0
* Added `@starting-style` to bubbling at-rules.

## 6.1.0
* Added `@container` to bubbling at-rules.

## 6.0
Expand Down
91 changes: 47 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@

```css
.phone {
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
body.is_dark & {
color: white;
}
&_title {
width: 500px;
@media (max-width: 500px) {
width: auto;
}
img {
display: block;
body.is_dark & {
color: white;
}
}
img {
display: block;
}
}

.title {
font-size: var(--font);

@at-root html {
--font: 16px
--font: 16px;
}
}
```
Expand All @@ -35,39 +35,39 @@ will be processed to:

```css
.phone_title {
width: 500px;
width: 500px;
}
@media (max-width: 500px) {
.phone_title {
width: auto;
}
.phone_title {
width: auto;
}
}
body.is_dark .phone_title {
color: white;
color: white;
}
.phone img {
display: block;
display: block;
}

.title {
font-size: var(--font);
}
html {
--font: 16px
--font: 16px;
}
```

Related plugins:

* Use [`postcss-current-selector`] **after** this plugin if you want
- Use [`postcss-current-selector`] **after** this plugin if you want
to use current selector in properties or variables values.
* Use [`postcss-nested-ancestors`] **before** this plugin if you want
- Use [`postcss-nested-ancestors`] **before** this plugin if you want
to reference any ancestor element directly in your selectors with `^&`.

Alternatives:

* See also [`postcss-nesting`], which implements [CSSWG draft].
* [`postcss-nested-props`] for nested properties like `font-size`.
- See also [`postcss-nesting`], which implements [CSSWG draft].
- [`postcss-nested-props`] for nested properties like `font-size`.

<a href="https://evilmartians.com/?utm_source=postcss-nested">
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
Expand All @@ -76,11 +76,10 @@ Alternatives:

[`postcss-current-selector`]: https://github.com/komlev/postcss-current-selector
[`postcss-nested-ancestors`]: https://github.com/toomuchdesign/postcss-nested-ancestors
[`postcss-nested-props`]: https://github.com/jedmao/postcss-nested-props
[`postcss-nesting`]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting
[CSSWG draft]: https://drafts.csswg.org/css-nesting-1/
[PostCSS]: https://github.com/postcss/postcss

[`postcss-nested-props`]: https://github.com/jedmao/postcss-nested-props
[`postcss-nesting`]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting
[CSSWG draft]: https://drafts.csswg.org/css-nesting-1/
[PostCSS]: https://github.com/postcss/postcss

## Usage

Expand Down Expand Up @@ -110,16 +109,16 @@ module.exports = {

[official docs]: https://github.com/postcss/postcss#usage


## Options

### `bubble`

By default, plugin will bubble only `@media`, `@supports` and `@layer`
at-rules. Use this option to add your custom at-rules to this list.
By default, plugin will bubble only `@media`, `@supports`, `@layer`,
`@container`, and `@starting-style` at-rules. Use this option
to add your custom at-rules to this list.

```js
postcss([ require('postcss-nested')({ bubble: ['phone'] }) ])
postcss([require('postcss-nested')({ bubble: ['phone'] })])
```

```css
Expand All @@ -141,14 +140,13 @@ a {
}
```


### `unwrap`

By default, plugin will unwrap only `@font-face`, `@keyframes` and `@document`
at-rules. You can add your custom at-rules to this list by `unwrap` option:

```js
postcss([ require('postcss-nested')({ unwrap: ['phone'] }) ])
postcss([require('postcss-nested')({ unwrap: ['phone'] })])
```

```css
Expand All @@ -168,51 +166,56 @@ a {
}
```


### `preserveEmpty`

By default, plugin will strip out any empty selector generated by intermediate
nesting levels. You can set `preserveEmpty` to `true` to preserve them.

```css
.a {
.b {
color: black;
}
.b {
color: black;
}
}
```

Will be compiled to:

```css
.a { }
.a {
}
.a .b {
color: black;
color: black;
}
```

This is especially useful if you want to export the empty classes with `postcss-modules`.


### `rootRuleName`

The plugin supports the SCSS custom at-rule `@at-root` which breaks rule
blocks out of their nested position. If you want, you can choose a new
custom name for this rule in your code.

```js
postcss([ require('postcss-nested')({ rootRuleName: '_escape-nesting' }) ])
postcss([require('postcss-nested')({ rootRuleName: '_escape-nesting' })])
```

```css
/* input */
.a {
color: white;
@_escape-nesting {
.b { color: black; }
.b {
color: black;
}
}
}
/* output */
.a { color: white; }
.b { color: black; }
.a {
color: white;
}
.b {
color: black;
}
```
3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import loguxConfig from '@logux/eslint-config'

export default [...loguxConfig]
Loading

0 comments on commit 265340b

Please sign in to comment.