postcss-fail-on-warn
Advanced tools
Comparing version 0.1.0 to 0.2.0
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 |
{ | ||
"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 |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
4505
62
43
0
+ Addednanoid@3.3.8(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpostcss@8.5.1(transitive)
+ Addedsource-map-js@1.2.1(transitive)
- Removedpostcss@^7.0.6
- Removedpicocolors@0.2.1(transitive)
- Removedpostcss@7.0.39(transitive)
- Removedsource-map@0.6.1(transitive)