diff --git a/.gitignore b/.gitignore index 1ca9571..c6873c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ npm-debug.log +package-lock.json diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 140f99b..0000000 --- a/.npmignore +++ /dev/null @@ -1,7 +0,0 @@ -.gitignore - -node_modules/ -npm-debug.log - -test.js -.travis.yml diff --git a/.travis.yml b/.travis.yml index 6446018..0517f82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: node_js node_js: - - "5" - - "4" - - "0.12" + - 6 + - 7 + - 8 + - 9 + - 10 diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29..e8bd1ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +## 3.0 +* Use PostCSS 7.x +* Bump various dependencies + +## 2.0 +* Use PostCSS 6.x +* Use Node 4.x syntax + +## 1.0 +* Initial release diff --git a/README.md b/README.md index aa309c4..9c8f5f3 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ -# PostCSS Replace Overflow Wrap [![Build Status][ci-img]][ci] +# PostCSS Replace Overflow Wrap [![CSS Standard Status][css-img]][css] [![Build Status][ci-img]][ci] [PostCSS] plugin to replace overflow-wrap with word-wrap. May optionally retain both declarations. [PostCSS]: https://github.com/postcss/postcss +[css-img]: https://jonathantneal.github.io/css-db/badge/css-text-overflow-wrap-property.svg +[css]: https://jonathantneal.github.io/css-db/#css-text-overflow-wrap-property [ci-img]: https://travis-ci.org/MattDiMu/postcss-replace-overflow-wrap.svg [ci]: https://travis-ci.org/MattDiMu/postcss-replace-overflow-wrap @@ -32,6 +34,13 @@ } ``` +### Installation +`npm install --save-dev postcss postcss-replace-overflow-wrap` + +For Postcss 7 or earlier use Version 3 or earlier: + +`npm install --save-dev postcss-replace-overflow-wrap@3` + ## Usage diff --git a/index.js b/index.js index 58fe6a5..a661048 100644 --- a/index.js +++ b/index.js @@ -1,19 +1,19 @@ -var postcss = require('postcss'); +// @ts-check -module.exports = postcss.plugin('postcss-replace-overflow-wrap', function (opts) { - opts = opts || {}; - var method = opts.method || 'replace'; - - return function (css, result) { // eslint-disable-line no-unused-vars - css.walkRules(function (rule) { - rule.walkDecls(function (decl, i) { // eslint-disable-line no-unused-vars - if (decl.prop === 'overflow-wrap') { - decl.cloneBefore({ prop: 'word-wrap' }); - if (method === 'replace') { - decl.remove(); - } +module.exports = function (opts) { + opts = opts || {} + var method = opts.method || 'replace' + return { + postcssPlugin: 'postcss-replace-overflow-wrap', + Declaration: { + 'overflow-wrap': decl => { + decl.cloneBefore({ prop: 'word-wrap' }) + if (method === 'replace') { + decl.remove() } - }); - }); - }; -}); + } + } + } +} + +module.exports.postcss = true diff --git a/package.json b/package.json index 09ae6dd..edeb595 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-replace-overflow-wrap", - "version": "1.0.0", + "version": "4.0.0", "description": "PostCSS plugin to replace overflow-wrap with word-wrap or optionally retain both declarations.", "keywords": [ "postcss", @@ -16,13 +16,27 @@ "url": "https://github.com/MattDiMu/postcss-replace-overflow-wrap/issues" }, "homepage": "https://github.com/MattDiMu/postcss-replace-overflow-wrap", - "dependencies": { - "postcss": "^5.0.16" - }, + "files": [ + "index.js" + ], + "dependencies": {}, "devDependencies": { - "ava": "^0.14.0", - "eslint": "^2.1.0", - "eslint-config-postcss": "^2.0.0" + "ava": "^0.25.0", + "eslint": "^5.3.0", + "eslint-config-logux": "^24.0.0", + "eslint-config-postcss": "^3.0.3", + "eslint-config-standard": "^11.0.0", + "eslint-plugin-es5": "^1.3.1", + "eslint-plugin-import": "^2.13.0", + "eslint-plugin-jest": "^21.20.1", + "eslint-plugin-node": "^7.0.1", + "eslint-plugin-promise": "^3.8.0", + "eslint-plugin-security": "^1.4.0", + "eslint-plugin-standard": "^3.1.0", + "postcss": "^8.0.3" + }, + "peerDependencies": { + "postcss": "^8.0.3" }, "scripts": { "test": "ava && eslint *.js" @@ -30,7 +44,13 @@ "eslintConfig": { "extends": "eslint-config-postcss/es5", "rules": { - "max-len": 0 + "max-len": 0, + "es5/no-modules": false, + "indent": [ + "warn", + 4 + ], + "es5/no-arrow-functions": 0 } } } diff --git a/test.js b/test.js index eba474a..0bd69f2 100644 --- a/test.js +++ b/test.js @@ -1,34 +1,33 @@ -import postcss from 'postcss'; -import test from 'ava'; +import postcss from 'postcss' +import test from 'ava' -import plugin from './'; +import plugin from './' -function run(t, input, output, opts = { }) { - return postcss([ plugin(opts) ]).process(input) - .then( result => { - t.deepEqual(result.css, output); - t.deepEqual(result.warnings().length, 0); - }); +function run(t, input, output, opts = {}) { //eslint-disable-line + return postcss([plugin(opts)]).process(input) + .then(function (result) { + t.deepEqual(result.css, output) + t.deepEqual(result.warnings().length, 0) + }) } - -test('replace overflow-wrap with word-wrap, no options', t => { +test('replace overflow-wrap with word-wrap, no options', function (t) { return run(t, '.someClass{ overflow-wrap: break-word; }', '.someClass{ word-wrap: break-word; }' - , {}); -}); + , {}) +}) -test('add word-wrap right before overflow-wrap due to passed arg', t => { +test('add word-wrap right before overflow-wrap due to passed arg', function (t) { return run(t, '.anotherClass{font-size:1rem;overflow-wrap:break-word;}', '.anotherClass{font-size:1rem;word-wrap:break-word;overflow-wrap:break-word;}' - , { method: 'copy' }); -}); + , { method: 'copy' }) +}) -test('replace overflow-wrap with word-wrap, replace method', t => { +test('replace overflow-wrap with word-wrap, replace method', function (t) { return run(t, 'main { overflow-wrap: normal; }', 'main { word-wrap: normal; }' - , { method: 'replace' }); -}); + , { method: 'replace' }) +})