Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-fail-on-warn

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-fail-on-warn - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

index.test.js

40

index.js

@@ -1,9 +0,37 @@

var postcss = require('postcss')
module.exports = () => {
return {
postcssPlugin: 'postcss-fail-on-warn',
OnceExit(css, { result, CssSyntaxError }) {
let [first, ...rest] = result.warnings()
if (!first) return
module.exports = postcss.plugin('postcss-fail-on-warn', function () {
return function (root, result) {
if (result.warnings().length > 0) {
throw new Error(result.warnings()[0])
function format(warning) {
if (warning.line) {
let input = (warning.node && warning.node.input) || {}
let formatter = new CssSyntaxError(
warning.text,
warning.line,
warning.column,
input.css,
input.file,
warning.plugin
)
return formatter.toString().replace(/^CssSyntaxError: /, '')
} else if (warning.plugin) {
return warning.plugin + ': ' + warning.text
} else {
return warning.text
}
}
if (rest) {
for (let warning of rest) {
console.warn(format(warning))
}
}
throw new Error(format(first))
}
}
})
}
module.exports.postcss = true

13

package.json
{
"name": "postcss-fail-on-warn",
"version": "0.1.0",
"version": "0.2.0",
"description": "PostCSS plugin throws a error on any warning from previous PostCSS plugins",

@@ -13,10 +13,9 @@ "keywords": [

"license": "MIT",
"repository": "ai/postcss-fail-on-warn",
"bugs": {
"url": "https://github.com/ai/postcss-fail-on-warn/issues"
"repository": "postcss/postcss-fail-on-warn",
"engines": {
"node": ">=12.0"
},
"homepage": "https://github.com/ai/postcss-fail-on-warn",
"dependencies": {
"postcss": "^7.0.6"
"peerDependencies": {
"postcss": "^8.2.14"
}
}
# PostCSS Fail On Warn
<img align="right" width="135" height="95"
title="Philosopher’s stone, logo of PostCSS"
src="https://postcss.org/logo-leftp.svg">
[PostCSS] plugin throws a error on any warning from previous PostCSS plugins.

@@ -7,12 +11,33 @@

<a href="https://evilmartians.com/?utm_source=postcss-focus">
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
alt="Sponsored by Evil Martians" width="236" height="54">
</a>
## Usage
```js
postcss([
require('autoprefixer'),
// other plugins
require('postcss-fail-on-warn')
])
**Step 1:** Install plugin:
```sh
npm install --save-dev postcss postcss-focus
```
See [PostCSS] docs for examples for your environment.
**Step 2:** Check you project for existed PostCSS config: `postcss.config.js`
in the project root, `"postcss"` section in `package.json`
or `postcss` in bundle config.
If you do not use PostCSS, add it according to [official docs]
and set this plugin in settings.
**Step 3:** Add the plugin to plugins list:
```diff
module.exports = {
plugins: [
require('autoprefixer'),
+ require('postcss-fail-on-warn')
]
}
```
[official docs]: https://github.com/postcss/postcss#usage
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc