diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 60c68541c..6eec078d6 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -4,16 +4,6 @@ If you want to contribute to PostCSS, there are a few things that you should be familiar with. -## In Case You Have Questions About Using PostCSS - -* **Ask for help in [the chat]** - - If you're stuck, chances are - someone had a similar problem before. - -[the chat]: https://gitter.im/postcss/postcss - - ## Adding Your Plugin to the List If you created or found a plugin and want to add it to the PostCSS plugins list diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 04f82bab2..91de44399 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,3 @@ open_collective: postcss tidelift: npm/postcss +github: ai diff --git a/.github/workflows/deno.yml b/.github/workflows/deno.yml deleted file mode 100644 index cc2a41613..000000000 --- a/.github/workflows/deno.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Deno - -on: - push: - tags: - - "8.*" - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Setup Deno environment - uses: denolib/setup-deno@v2.3.0 - with: - deno-version: v1.x - - - name: Checkout postcss-deno - uses: actions/checkout@v2 - with: - repository: postcss/postcss-deno - token: ${{ secrets.PAT }} - - - name: Checkout sources - uses: actions/checkout@v2 - with: - ref: main - path: postcss - - - name: Convert the code - run: | - rm -rf deno - deno run --unstable --allow-write --allow-read to_deno.js - deno fmt deno - deno test --unstable --allow-read --allow-env deno/test/* - - - name: Get the tag name - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - - - name: Commit the changes and create the tag - run: | - git config user.name deno-conversion - git config user.email github-actions@github.com - git add deno - git commit -m "update code" - git push - git tag ${{ steps.get_version.outputs.VERSION }} - git push --tags diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d698d3b55..b379d876d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,100 +1,99 @@ name: Test on: push: + branches: + - main pull_request: +permissions: + contents: read jobs: full: - name: Node.js 17 Full + name: Node.js Latest Full runs-on: ubuntu-latest steps: - name: Checkout the repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install pnpm uses: pnpm/action-setup@v2 with: - version: 6.23.6 + version: 8 - name: Install Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: - node-version: 17 + node-version: 20 cache: pnpm - name: Install dependencies run: pnpm install --frozen-lockfile --ignore-scripts - name: Run tests run: pnpm test - env: - FORCE_COLOR: 2 short: runs-on: ubuntu-latest strategy: matrix: node-version: + - 18 - 16 - - 14 - - 12 name: Node.js ${{ matrix.node-version }} Quick steps: - name: Checkout the repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install pnpm uses: pnpm/action-setup@v2 with: - version: 6.23.6 + version: 8 - name: Install Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 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 - env: - FORCE_COLOR: 2 + run: pnpm run unit old: runs-on: ubuntu-latest strategy: matrix: node-version: + - 14 + - 12 - 10 name: Node.js ${{ matrix.node-version }} Quick steps: - name: Checkout the repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install pnpm uses: pnpm/action-setup@v1 with: - version: 3.8.1 + version: 3 env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true - name: Install Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - name: Install dependencies - run: pnpm install --frozen-lockfile --ignore-scripts + run: pnpm install --ignore-scripts + - name: Downgrade TypeScript + run: pnpm install typescript@4 - name: Run unit tests - run: pnpm unit - env: - FORCE_COLOR: 2 + run: pnpm run old windows: runs-on: windows-latest name: Windows Quick steps: - name: Checkout the repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install pnpm uses: pnpm/action-setup@v2 with: - version: 6.23.6 + version: latest - name: Install Node.js LTS - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 20 cache: pnpm - name: Install dependencies run: pnpm install --frozen-lockfile --ignore-scripts - name: Run unit tests - run: pnpm unit - env: - FORCE_COLOR: 2 + run: pnpm run unit diff --git a/.npmignore b/.npmignore index 357696a44..de9010b49 100644 --- a/.npmignore +++ b/.npmignore @@ -1,11 +1,5 @@ -node_modules/ -pnpm-lock.yaml - -.editorconfig coverage/ test/ -.travis.yml docs/ -.github/ tsconfig.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 85118b5d4..05c9da70e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,92 @@ # Change Log This project adheres to [Semantic Versioning](https://semver.org/). +## 8.4.31 +* Fixed `\r` parsing to fix CVE-2023-44270. + +## 8.4.30 +* Improved source map performance (by Romain Menke). + +## 8.4.29 +* Fixed `Node#source.offset` (by Ido Rosenthal). +* Fixed docs (by Christian Oliff). + +## 8.4.28 +* Fixed `Root.source.end` for better source map (by Romain Menke). +* Fixed `Result.root` types when `process()` has no parser. + +## 8.4.27 +* Fixed `Container` clone methods types. + +## 8.4.26 +* Fixed clone methods types. + +## 8.4.25 +* Improve stringify performance (by Romain Menke). +* Fixed docs (by @vikaskaliramna07). + +## 8.4.24 +* Fixed `Plugin` types. + +## 8.4.23 +* Fixed warnings in TypeDoc. + +## 8.4.22 +* Fixed TypeScript support with `node16` (by Remco Haszing). + +## 8.4.21 +* Fixed `Input#error` types (by Aleks Hudochenkov). + +## 8.4.20 +* Fixed source map generation for childless at-rules like `@layer`. + +## 8.4.19 +* Fixed whitespace preserving after AST transformations (by Romain Menke). + +## 8.4.18 +* Fixed an error on `absolute: true` with empty `sourceContent` (by Rene Haas). + +## 8.4.17 +* Fixed `Node.before()` unexpected behavior (by Romain Menke). +* Added TOC to docs (by Mikhail Dedov). + +## 8.4.16 +* Fixed `Root` AST migration. + +## 8.4.15 +* Fixed AST normalization after using custom parser with old PostCSS AST. + +## 8.4.14 +* Print “old plugin API” warning only if plugin was used (by @zardoy). + +## 8.4.13 +* Fixed `append()` error after using `.parent` (by Jordan Pittman). + +## 8.4.12 +* Fixed `package.funding` to have same value between all PostCSS packages. + +## 8.4.11 +* Fixed `Declaration#raws.value` type. + +## 8.4.10 +* Fixed `package.funding` URL format. + +## 8.4.9 +* Fixed `package.funding` (by Álvaro Mondéjar). + +## 8.4.8 +* Fixed end position in empty Custom Properties. + +## 8.4.7 +* Fixed `Node#warn()` type (by Masafumi Koba). +* Fixed comment removal in values after `,`. + +## 8.4.6 +* Prevented comment removing when it change meaning of CSS. +* Fixed parsing space in last semicolon-less CSS Custom Properties. +* Fixed comment cleaning in CSS Custom Properties with space. +* Fixed throwing an error on `.root` access for plugin-less case. + ## 8.4.5 * Fixed `raws` types to make object extendable (by James Garbutt). * Moved from Yarn 1 to pnpm. diff --git a/README.md b/README.md index c8c333c42..c6a041523 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,28 @@ -# PostCSS [![Gitter][chat-img]][chat] +# PostCSS Philosopher’s stone, logo of PostCSS -[chat-img]: https://img.shields.io/badge/Gitter-Join_the_PostCSS_chat-brightgreen.svg -[chat]: https://gitter.im/postcss/postcss - PostCSS is a tool for transforming styles with JS plugins. These plugins can lint your CSS, support variables and mixins, transpile future CSS syntax, inline images, and more. PostCSS is used by industry leaders including Wikipedia, Twitter, Alibaba, -and JetBrains. The [Autoprefixer] PostCSS plugin is one of the most popular -CSS processors. +and JetBrains. The [Autoprefixer] and [Stylelint] PostCSS plugins is one of the most popular CSS tools. -PostCSS takes a CSS file and provides an API to analyze and modify its rules -(by transforming them into an [Abstract Syntax Tree]). -This API can then be used by [plugins] to do a lot of useful things, -e.g., to find errors automatically, or to insert vendor prefixes. +--- -**Support / Discussion:** [Gitter](https://gitter.im/postcss/postcss)
-**Twitter account:** [@postcss](https://twitter.com/postcss)
-**VK.com page:** [postcss](https://vk.com/postcss)
-**中文翻译**: [`docs/README-cn.md`](./docs/README-cn.md) +  Made in Evil Martians, product consulting for developer tools. -For PostCSS commercial support (consulting, improving the front-end culture -of your company, PostCSS plugins), contact [Evil Martians] -at . +--- [Abstract Syntax Tree]: https://en.wikipedia.org/wiki/Abstract_syntax_tree [Evil Martians]: https://evilmartians.com/?utm_source=postcss [Autoprefixer]: https://github.com/postcss/autoprefixer +[Stylelint]: https://stylelint.io/ [plugins]: https://github.com/postcss/postcss#plugins - - Sponsored by Evil Martians - - ## Sponsorship @@ -56,6 +40,11 @@ PostCSS needs your support. We are accepting donations ## Plugins +PostCSS takes a CSS file and provides an API to analyze and modify its rules +(by transforming them into an [Abstract Syntax Tree]). +This API can then be used by [plugins] to do a lot of useful things, +e.g., to find errors automatically, or to insert vendor prefixes. + Currently, PostCSS has more than 200 plugins. You can find all of the plugins in the [plugins list] or in the [searchable catalog]. Below is a list of our favorite plugins — the best demonstrations of what can be built @@ -97,7 +86,7 @@ If you have any new ideas, [PostCSS plugin development] is really easy. ### Images and Fonts -* [`postcss-assets`] inserts image dimensions and inlines files. +* [`postcss-url`] postcss plugin to rebase url(), inline or copy asset. * [`postcss-sprites`] generates image sprites. * [`font-magician`] generates all the `@font-face` rules needed in CSS. * [`postcss-inline-svg`] allows you to inline SVG and customize its styles. @@ -116,27 +105,25 @@ If you have any new ideas, [PostCSS plugin development] is really easy. ### Other -* [`postcss-rtl`] combines both-directional (left-to-right and right-to-left) styles in one CSS file. * [`cssnano`] is a modular CSS minifier. * [`lost`] is a feature-rich `calc()` grid system. * [`rtlcss`] mirrors styles for right-to-left locales. [PostCSS plugin development]: https://github.com/postcss/postcss/blob/main/docs/writing-a-plugin.md [`postcss-inline-svg`]: https://github.com/TrySound/postcss-inline-svg -[`postcss-preset-env`]: https://github.com/jonathantneal/postcss-preset-env +[`postcss-preset-env`]: https://github.com/csstools/postcss-plugins/tree/main/plugin-packs/postcss-preset-env [`react-css-modules`]: https://github.com/gajus/react-css-modules [`postcss-autoreset`]: https://github.com/maximkoretskiy/postcss-autoreset -[`postcss-write-svg`]: https://github.com/jonathantneal/postcss-write-svg +[`postcss-write-svg`]: https://github.com/csstools/postcss-write-svg [`postcss-utilities`]: https://github.com/ismamz/postcss-utilities [`postcss-initial`]: https://github.com/maximkoretskiy/postcss-initial [`postcss-sprites`]: https://github.com/2createStudio/postcss-sprites [`postcss-modules`]: https://github.com/outpunk/postcss-modules [`postcss-sorting`]: https://github.com/hudochenkov/postcss-sorting -[`postcss-assets`]: https://github.com/assetsjs/postcss-assets -[`font-magician`]: https://github.com/jonathantneal/postcss-font-magician +[`font-magician`]: https://github.com/csstools/postcss-font-magician [`autoprefixer`]: https://github.com/postcss/autoprefixer [`cq-prolyfill`]: https://github.com/ausi/cq-prolyfill -[`postcss-rtl`]: https://github.com/vkalinichev/postcss-rtl +[`postcss-url`]: https://github.com/postcss/postcss-url [`postcss-use`]: https://github.com/postcss/postcss-use [`css-modules`]: https://github.com/css-modules/css-modules [`webp-in-css`]: https://github.com/ai/webp-in-css @@ -148,7 +135,7 @@ If you have any new ideas, [PostCSS plugin development] is really easy. [`postcss-nested`]: https://github.com/postcss/postcss-nested [`doiuse`]: https://github.com/anandthakker/doiuse [`rtlcss`]: https://github.com/MohammadYounes/rtlcss -[`short`]: https://github.com/jonathantneal/postcss-short +[`short`]: https://github.com/csstools/postcss-short [`lost`]: https://github.com/peterramsing/lost ## Syntaxes @@ -161,6 +148,8 @@ you can write a parser and/or stringifier to extend PostCSS. * [`postcss-syntax`] switch syntax automatically by file extensions. * [`postcss-html`] parsing styles in `\n\n' - }, - nodes: [new Rule({ selector: 'b' })] + codeAfter: '\n', + codeBefore: '\n