# stylelint-no-restricted-syntax

> Stylelint rule to disallow specified syntax.

Latest version **2.3.0** (published 2026-09-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install stylelint-no-restricted-syntax
pnpm add stylelint-no-restricted-syntax
yarn add stylelint-no-restricted-syntax
bun add stylelint-no-restricted-syntax
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.3.0 |
| Published | 2026-09-15 |
| First published | 2019-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16 |
| Dependencies | 1 |
| Unpacked size | 22.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Author | Ivan Nikolić |
| Maintainers | niksy |
| Keywords | restricted, stylelint, stylelint-plugin, syntax |

## Links

- npm: https://www.npmjs.com/package/stylelint-no-restricted-syntax
- Repository: https://github.com/niksy/stylelint-no-restricted-syntax
- Homepage: https://github.com/niksy/stylelint-no-restricted-syntax#readme
- Issues: https://github.com/niksy/stylelint-no-restricted-syntax/issues
- npm.io page: https://npm.io/package/stylelint-no-restricted-syntax

## Dependencies (1)

- [postcss-query-ast](https://npm.io/package/postcss-query-ast.md) ^2.1.1

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 2.3.0 (latest) — 2026-09-15
- 2.2.1 — 2024-02-26
- 2.2.0 — 2023-09-11
- 2.1.0 — 2023-08-23
- 2.0.0 — 2021-10-25
- 1.0.0 — 2019-01-03

## README

# stylelint-no-restricted-syntax

[![Build Status][ci-img]][ci]

Stylelint rule to disallow specified syntax, similar to ESLint
[`no-restricted-syntax`](https://eslint.org/docs/rules/no-restricted-syntax).

## Install

```sh
npm install stylelint-no-restricted-syntax --save
```

## Usage

Add this config to your `.stylelintrc`:

```json
{
	"plugins": ["stylelint-no-restricted-syntax"],
	"rules": {
		"plugin/no-restricted-syntax": [
			[
				{
					"selector": "rule[selector='a']",
					"message": "Anchors not allowed."
				},
				{
					"selector": "decl[prop='z-index']",
					"message": "z-index not allowed."
				}
			]
		]
	}
}
```

If using a JavaScript config file (e.g., `stylelint.config.cjs`), you may also
use a function that returns a message:

```js
module.exports = {
	'plugins': ['stylelint-no-restricted-syntax'],
	'rules': {
		'plugin/no-restricted-syntax': [
			[
				{
					'selector': "decl[prop='z-index']",
					'message': (node) => `${node.prop} not allowed.`
				}
			]
		]
	}
};
```

## Options

Each restricted syntax rule consists of the following properties:

| Property   | Type               | Description                                                                                                  |
| ---------- | ------------------ | ------------------------------------------------------------------------------------------------------------ |
| `selector` | `string`           | Selector for querying PostCSS AST.                                                                           |
| `message`  | `string\|function` | Error message for queried PostCSS node. If using a function, the provided argument is the full PostCSS node. |

## Details

```css
a {
	z-index: 10;
}
/**          ↑
 * Previous line will be considered as restricted syntax */
b {
	font-weight: bold;
}
```

## License

MIT © [Ivan Nikolić](http://ivannikolic.com)

<!-- prettier-ignore-start -->

[ci]: https://github.com/niksy/stylelint-no-restricted-syntax/actions?query=workflow%3ACI
[ci-img]: https://github.com/niksy/stylelint-no-restricted-syntax/actions/workflows/ci.yml/badge.svg?branch=master

<!-- prettier-ignore-end -->

---
_Source: https://npm.io/package/stylelint-no-restricted-syntax · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
