Skip to content

Commit

Permalink
Merge branch 'murmur' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed May 17, 2021
2 parents ce7f060 + 631cf49 commit b111207
Show file tree
Hide file tree
Showing 61 changed files with 2,019 additions and 5,637 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/test.yml
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v2
- name: Install Node.js
uses: actions/setup-node@v2-beta
uses: actions/setup-node@v2
with:
node-version: 15
- name: Install dependencies
Expand All @@ -32,11 +32,13 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v2
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2-beta
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
uses: bahmutov/npm-install@v1
with:
install-command: yarn --frozen-lockfile --ignore-engines
- name: Run unit tests
run: npx jest
windows:
Expand All @@ -48,7 +50,7 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v2
- name: Install Node.js LTS
uses: actions/setup-node@v2-beta
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install dependencies
Expand Down
37 changes: 37 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,43 @@
# Change Log
This project adheres to [Semantic Versioning](https://semver.org/).

## 8.2.15
* Fixed `list` type definitions (by @n19htz).

## 8.2.14
* Removed `source-map` from client-side bundle (by Barak Igal).

## 8.2.13
* Fixed ReDoS vulnerabilities in source map parsing (by Yeting Li).

## 8.2.12
* Fixed `package.json` exports.

## 8.2.11
* Fixed `DEP0148` warning in Node.js 16.
* Fixed docs (by @semiromid).

## 8.2.10
* Fixed ReDoS vulnerabilities in source map parsing.
* Fixed webpack 5 support (by Barak Igal).
* Fixed docs (by Roeland Moors).

## 8.2.9
* Exported `NodeErrorOptions` type (by Rouven Weßling).

## 8.2.8
* Fixed browser builds in webpack 4 (by Matt Jones).

## 8.2.7
* Fixed browser builds in webpack 5 (by Matt Jones).

## 8.2.6
* Fixed `Maximum call stack size exceeded` in `Node#toJSON`.
* Fixed docs (by inokawa).

## 8.2.5
* Fixed escaped characters handling in `list.split` (by Natalie Weizenbaum).

## 8.2.4
* Added plugin name to `postcss.plugin()` warning (by Tom Williams).
* Fixed docs (by Bill Columbia).
Expand Down
7 changes: 5 additions & 2 deletions README.md
Expand Up @@ -47,7 +47,10 @@ PostCSS needs your support. We are accepting donations

<a href="https://tailwindcss.com/">
<img src="https://refactoringui.nyc3.cdn.digitaloceanspaces.com/tailwind-logo.svg"
alt="Sponsored by Tailwind CSS" width="273" height="64">
alt="Sponsored by Tailwind CSS" width="213" height="50">
</a>      <a href="https://themeisle.com/">
<img src="https://mllj2j8xvfl0.i.optimole.com/d0cOXWA.3970~373ad/w:auto/h:auto/q:90/https://s30246.pcdn.co/wp-content/uploads/2019/03/logo.png"
alt="Sponsored by ThemeIsle" width="171" height="56">
</a>


Expand Down Expand Up @@ -377,7 +380,7 @@ PostCSS also supports [Deno]:

```js
import postcss from 'https://deno.land/x/postcss/mod.js'
import autoprefixer from 'https://dev.jspm.io/autoprefixer'
import autoprefixer from 'https://jspm.dev/autoprefixer'

const result = await postcss([autoprefixer]).process(css)
```
Expand Down
44 changes: 36 additions & 8 deletions docs/guidelines/plugin.md
Expand Up @@ -206,9 +206,37 @@ is described in [API docs].
[API docs]: https://postcss.org/api/


## 3. Errors
## 3. Dependencies

### 3.1. Use `node.error` on CSS relevant errors
### 3.1. Use messages to specify dependencies

If a plugin depends on another file, it should be specified by attaching
a `dependency` message to the `result`:

```js
result.messages.push({
type: 'dependency',
plugin: 'postcss-import',
file: '/imported/file.css',
parent: result.opts.from
})
```

Specify recursive directory dependencies using the `dir-dependency` message type:

```js
result.messages.push({
type: 'dir-dependency',
plugin: 'postcss-import',
dir: '/imported',
parent: result.opts.from
})
```


## 4. Errors

### 4.1. Use `node.error` on CSS relevant errors

If you have an error because of input CSS (like an unknown name
in a mixin plugin) you should use `node.error` to create an error
Expand All @@ -221,7 +249,7 @@ if (typeof mixins[name] === 'undefined') {
```


### 3.2. Use `result.warn` for warnings
### 4.2. Use `result.warn` for warnings

Do not print warnings with `console.log` or `console.warn`,
because some PostCSS runner may not allow console output.
Expand All @@ -237,9 +265,9 @@ Declaration (decl, { result }) {
If CSS input is a source of the warning, the plugin must set the `node` option.


## 4. Documentation
## 5. Documentation

### 4.1. Document your plugin in English
### 5.1. Document your plugin in English

PostCSS plugins must have their `README.md` wrote in English. Do not be afraid
of your English skills, as the open source community will fix your errors.
Expand All @@ -248,7 +276,7 @@ Of course, you are welcome to write documentation in other languages;
just name them appropriately (e.g. `README.ja.md`).


### 4.2. Include input and output examples
### 5.2. Include input and output examples

The plugin's `README.md` must contain example input and output CSS.
A clear example is the best way to describe how your plugin works.
Expand All @@ -260,7 +288,7 @@ Of course, this guideline does not apply if your plugin does not
transform the CSS.


### 4.3. Maintain a changelog
### 5.3. Maintain a changelog

PostCSS plugins must describe the changes of all their releases
in a separate file, such as `CHANGELOG.md`, `History.md`, or [GitHub Releases].
Expand All @@ -273,7 +301,7 @@ Of course, you should be using [SemVer].
[SemVer]: https://semver.org/


### 4.4. Include `postcss-plugin` keyword in `package.json`
### 5.4. Include `postcss-plugin` keyword in `package.json`

PostCSS plugins written for npm must have the `postcss-plugin` keyword
in their `package.json`. This special keyword will be useful for feedback about
Expand Down
37 changes: 28 additions & 9 deletions docs/guidelines/runner.md
Expand Up @@ -71,9 +71,28 @@ is described in [API docs].
[API docs]: https://postcss.org/api/


## 3. Output
## 3. Dependencies

### 3.1. Don’t show JS stack for `CssSyntaxError`
### 3.1. Rebuild when dependencies change

PostCSS plugins may declare file or directory dependencies by attaching
messages to the `result`. Runners should watch these and ensure that the
CSS is rebuilt when they change. Directories should be watched recursively.

```js
for (let message of result.messages) {
if (message.type === 'dependency') {
watcher.addFile(message.file)
} else if (message.type === 'dir-dependency') {
watcher.addDir(message.dir)
}
}
```


## 4. Output

### 4.1. Don’t show JS stack for `CssSyntaxError`

PostCSS runners must not show a stack trace for CSS syntax errors,
as the runner can be used by developers who are not familiar with JavaScript.
Expand All @@ -90,7 +109,7 @@ processor.process(opts).catch(error => {
```


### 3.2. Display `result.warnings()`
### 4.2. Display `result.warnings()`

PostCSS runners must output warnings from `result.warnings()`:

Expand All @@ -106,7 +125,7 @@ See also [postcss-log-warnings] and [postcss-messages] plugins.
[postcss-messages]: https://github.com/postcss/postcss-messages


### 3.3. Allow the user to write source maps to different files
### 4.3. Allow the user to write source maps to different files

PostCSS by default will inline source maps in the generated file; however,
PostCSS runners must provide an option to save the source map in a different
Expand All @@ -119,9 +138,9 @@ if (result.map) {
```


## 4. Documentation
## 5. Documentation

### 4.1. Document your runner in English
### 5.1. Document your runner in English

PostCSS runners must have their `README.md` wrote in English. Do not be afraid
of your English skills, as the open source community will fix your errors.
Expand All @@ -130,7 +149,7 @@ Of course, you are welcome to write documentation in other languages;
just name them appropriately (e.g. `README.ja.md`).


### 4.2. Maintain a changelog
### 5.2. Maintain a changelog

PostCSS runners must describe changes of all releases in a separate file,
such as `ChangeLog.md`, `History.md`, or with [GitHub Releases].
Expand All @@ -143,7 +162,7 @@ Of course, you should use [SemVer].
[SemVer]: https://semver.org/


### 4.3. `postcss-runner` keyword in `package.json`
### 5.3. `postcss-runner` keyword in `package.json`

PostCSS runners written for npm must have the `postcss-runner` keyword
in their `package.json`. This special keyword will be useful for feedback about
Expand All @@ -153,7 +172,7 @@ For packages not published to npm, this is not mandatory, but recommended
if the package format is allowed to contain keywords.


### 4.4. Keep `postcss` to `peerDependencies`
### 5.4. Keep `postcss` to `peerDependencies`

AST can be broken because of different `postcss` version in different plugins.
Different plugins could use a different node creators (like `postcss.decl()`).
Expand Down
20 changes: 17 additions & 3 deletions docs/plugins.md
Expand Up @@ -68,6 +68,7 @@ Or enable plugins directly in CSS using [`postcss-use`]:

* [`postcss-apply`] supports custom properties sets references.
* [`postcss-attribute-case-insensitive`] supports case insensitive attributes.
* [`postcss-bidirection`] generate left-to-right and right-to-left styles with single syntax.
* [`postcss-color-function`] supports functions to transform colors.
* [`postcss-color-gray`] supports the `gray()` function.
* [`postcss-color-hex-alpha`] supports `#rrggbbaa` and `#rgba` notation.
Expand Down Expand Up @@ -99,17 +100,18 @@ Or enable plugins directly in CSS using [`postcss-use`]:
to clean inherit styles.
* [`postcss-logical-properties`] transforms `start` and `end` properties
to `left` and `right` depending on the writing direction of the document.
* [`postcss-bidirection`] generate left-to-right and right-to-left styles with single syntax.
* [`postcss-media-minmax`] adds `<=` and `=>` statements to media queries.
* [`postcss-multi-value-display`] transforms `inline flex` and `block flow`
to `inline-flex` and `block`
* [`postcss-pseudo-class-any-link`] adds `:any-link` pseudo-class.
* [`postcss-pseudo-is`] transforms `:is()` to more compatible CSS.
* [`postcss-selector-not`] transforms CSS4 `:not()` to CSS3 `:not()`.
* [`postcss-selector-matches`] transforms CSS4 `:matches()`
to more compatible CSS.
* [`postcss-start-to-end`] lets you control your layout (LTR or RTL)
through logical rather than direction / physical rules.
* [`postcss-subgrid`] provides a basic shim for the CSS `display: subgrid` spec.
* [`mq4-hover-shim`] supports the `@media (hover)` feature.
* [`postcss-pseudo-is`] transforms `:is()` to more compatible CSS.

See also [`postcss-preset-env`] plugins pack to add future CSS syntax
by one line of code.
Expand Down Expand Up @@ -219,6 +221,7 @@ for targeting all button elements.
* [`csstyle`] adds components workflow to your styles.
* [`postcss-percentage`] support Sass-like `percentage()` function.
* [`postcss-custom-css-units`] Define custom css units and convert them to CSS variables.
* [`postcss-easy-z`] lets you organize z-indices by declaring relations between them.

See also [`precss`] plugins pack to add them by one line of code.

Expand Down Expand Up @@ -271,6 +274,7 @@ See also [`precss`] plugins pack to add them by one line of code.
* [`postcss-data-packer`] moves embedded Base64 data to a separate file.
* [`postcss-easysprites`] combine images to sprites, based on their
image.png`#hash` and aspect ratio (`@2x`).
* [`postcss-icon-blender`] create custom SVG icon sets from over 80,000 free and open-source icons
* [`postcss-image-set`] adds `background-image` with first image
for `image-set()`.
* [`postcss-image-inliner`] inlines local and remote images.
Expand Down Expand Up @@ -406,15 +410,19 @@ See also plugins in modular minifier [`cssnano`].

## Others

* [`postcss-add-root-selector`] intelligently wraps all rules in a custom selector.
* [`postcss-alter-property-value`] alters your CSS declarations from a rule based configuration.
* [`postcss-attribute-selector-prefix`] adds a prefix to attribute selectors
* [`postcss-auto-rem`] compiles pixel units to `rem` without configuration.
* [`postcss-autoreset`] automatically adds reset styles.
* [`postcss-bem-to-js`] creates a JavaScript definition file for BEM-style CSS.
* [`postcss-bom`] adds a UTF-8 BOM to files.
* [`postcss-blurry-gradient-workaround`] fixes blurry CSS gradients with too many explicit end-stops.
* [`postcss-camelcaser`] transforms selectors to CamelCase.
* [`postcss-class-prefix`] adds a prefix/namespace to class selectors.
* [`postcss-classes-to-mixins`] converts classes to Sass, Less and Stylus mixins
* [`postcss-currency`] replaces name of currency with symbols.
* [`postcss-d-ts`] generates `.d.ts` declaration for TypeScript `import` from used CSS classes and ids
* [`postcss-eol`] replaces EOL of files.
* [`postcss-extract-value`] extracts values from css properties and puts them into variables.
* [`postcss-fakeid`] transforms `#foo` IDs to attribute selectors `[id="foo"]`.
Expand Down Expand Up @@ -472,7 +480,6 @@ See also plugins in modular minifier [`cssnano`].
* [`postcss-px-to-viewport`] generates viewport units (`vw`, `vh`, `vmin`, `vmax`) from `px` units.
* [`postcss-viewport-height-correction`] solves the popular problem when `100vh`
doesn’t fit the mobile browser screen.
* [`postcss-auto-rem`] compiles pixel units to `rem` without configuration.


[flexbox bugs]: https://github.com/philipwalton/flexbugs
Expand Down Expand Up @@ -523,6 +530,7 @@ See also plugins in modular minifier [`cssnano`].
* [`postcss-spanish-stylesheets`] Spanish Style Sheets.
* [`postcss-nope`] lets you write `nope` instead of `none`.
* [`postcss-glitch`] add glitch effect to your text.
* [`postcss-khaleesi`] translate CSS values and properties to `khaleesi meme` language.

[`postcss-background-image-auto-size`]: https://github.com/JustClear/postcss-background-image-auto-size
[`postcss-letter-tracking`]: https://github.com/letsjaam/postcss-letter-tracking
Expand Down Expand Up @@ -855,3 +863,9 @@ See also plugins in modular minifier [`cssnano`].
[`webp-in-css`]: https://github.com/ai/webp-in-css
[`avif-in-css`]: https://github.com/nucliweb/avif-in-css
[`postcss-custom-css-units`]: https://github.com/joe223/postcss-custom-css-units
[`postcss-khaleesi`]: https://github.com/Hugoer/postcss-khaleesi
[`postcss-blurry-gradient-workaround`]: https://github.com/strarsis/postcss-blurry-gradient-workaround
[`postcss-d-ts`]: https://github.com/askirmas/postcss-d-ts
[`postcss-multi-value-display`]: https://github.com/jake-low/postcss-multi-value-display
[`postcss-easy-z`]: https://github.com/CSSSR/postcss-easy-z
[`postcss-icon-blender`]: https://github.com/icon-blender/postcss-icon-blender
18 changes: 15 additions & 3 deletions docs/writing-a-plugin.md
Expand Up @@ -317,9 +317,9 @@ Second argument also have `result` object to add warnings:
}
```

If your plugin load another file, you can use `result` to add message, that
webpack/Gulp should add this file to a watching list
(and rebuild CSS on file changes):
If your plugin depends on another file, you can attach a message to `result`
to signify to runners (webpack, Gulp etc.) that they should rebuild the CSS
when this file changes:

```js
AtRule: {
Expand All @@ -335,6 +335,18 @@ webpack/Gulp should add this file to a watching list
}
```

If the dependency is a directory you should use the `dir-dependency`
message type instead:

```js
result.messages.push({
type: 'dir-dependency',
plugin: 'postcss-import',
dir: importedDir,
parent: result.opts.from
})
```

If you find an syntax error (for instance, undefined custom property),
you can throw a special error:

Expand Down

0 comments on commit b111207

Please sign in to comment.