diff --git a/.eslintrc.yaml b/.eslintrc.yaml index ae169c8..0473b0f 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -1,10 +1,5 @@ env: node: true extends: problems -plugins: - - prettier rules: - prettier/prettier: - - error - - { semi: false, singleQuote: true } no-console: off diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..3018b3a --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +.tmp/ diff --git a/CHANGELOG.md b/CHANGELOG.md index a59b572..dd27f8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,245 +1,215 @@ -4.1.1 / 2017-08-17 -================== +# 4.1.1 / 2017-08-17 -- Fixed bug with `--config` -- Upgraded dependencies +* Fixed bug with `--config` +* Upgraded dependencies -4.1.0 / 2017-06-10 -================== +# 4.1.0 / 2017-06-10 -- Can now pass a number to `--poll` to set poll interval -- Updated `postcss-reporter` dependency to v4.0.0 +* Can now pass a number to `--poll` to set poll interval +* Updated `postcss-reporter` dependency to v4.0.0 -4.0.0 / 2017-05-09 -================== +# 4.0.0 / 2017-05-09 -- **BREAKING:** Upgrade postcss to v6.x +* **BREAKING:** Upgrade postcss to v6.x -3.2.0 / 2017-04-21 -================== +# 3.2.0 / 2017-04-21 -- Added `--base` CLI option for keeping directory structure +* Added `--base` CLI option for keeping directory structure -3.1.1 / 2017-04-04 -================== +# 3.1.1 / 2017-04-04 -- Fixed `files` property in `package.json`; `lib/` folder wasn't included in v3.1.0 +* Fixed `files` property in `package.json`; `lib/` folder wasn't included in v3.1.0 -3.1.0 / 2017-04-04 -================== +# 3.1.0 / 2017-04-04 -- Improved incremental rebuilds for better performance in watch mode. -- Switched to `read-cache` for file reading for better performance. -- Set a dummy filename when reading from stdin to help plugins like autoprefixer find config files. -- Updated `fs-promise` dependency. +* Improved incremental rebuilds for better performance in watch mode. +* Switched to `read-cache` for file reading for better performance. +* Set a dummy filename when reading from stdin to help plugins like autoprefixer find config files. +* Updated `fs-promise` dependency. -3.0.0 / 2017-03-15 -========== +# 3.0.0 / 2017-03-15 ## Changes since 3.0.0-beta ### Breaking Changes -- Don't exit on `CssSyntaxError` in watch mode. v2 behaved this way, but v3.0.0-beta didn't. -- Error out if `from` or `to` options are set in the config file. Use command line arguments instead. +* Don't exit on `CssSyntaxError` in watch mode. v2 behaved this way, but v3.0.0-beta didn't. +* Error out if `from` or `to` options are set in the config file. Use command line arguments instead. ### New Features -- Add `--poll` option. v2 had this, however, this new implementation removes the capability to set the interval, which was supported in v2. +* Add `--poll` option. v2 had this, however, this new implementation removes the capability to set the interval, which was supported in v2. ### Bugfixes -- Set `from` option for correct sourcemaps -- Fix `--watch`'s glob handling -- Fix error handling - +* Set `from` option for correct sourcemaps +* Fix `--watch`'s glob handling +* Fix error handling ## Changes since v2.6.0 ### Breaking Changes -- Uses https://github.com/michael-ciniawsky/postcss-load-config for config files. Dropped support for the v2 config file format. -- Can't set input files in config file; pass input files on the command line instead. -- `--use` accepts a list of plugins. This may cause issues if you have your list of css files at the end of your command. -- Can't pass options to plugins via `--plugin.key=value` anymore, use a config file. -- Changed usage of the `--map` option; use `--map` for external sourcemaps, `--no-map` to disable all maps. Inline sourcemaps are default. -- Removed `--log` flag; this behavior is now default. -- Removed the `--local-plugins` flag; same result can be achieved with `postcss.config.js`. -- Removed the global `watchCSS` handler, plugins that import/rely on other files should use a `dependency` message instead. -- Changed behavior of the `--poll` option; no longer accepts an integer `interval`. + +* Uses https://github.com/michael-ciniawsky/postcss-load-config for config files. Dropped support for the v2 config file format. +* Can't set input files in config file; pass input files on the command line instead. +* `--use` accepts a list of plugins. This may cause issues if you have your list of css files at the end of your command. +* Can't pass options to plugins via `--plugin.key=value` anymore, use a config file. +* Changed usage of the `--map` option; use `--map` for external sourcemaps, `--no-map` to disable all maps. Inline sourcemaps are default. +* Removed `--log` flag; this behavior is now default. +* Removed the `--local-plugins` flag; same result can be achieved with `postcss.config.js`. +* Removed the global `watchCSS` handler, plugins that import/rely on other files should use a `dependency` message instead. +* Changed behavior of the `--poll` option; no longer accepts an integer `interval`. ### New Features -- `--ext` (`-x`) option allows you to set the file extensions for your output files when using `--dir`. -- `--env` allows you to set `NODE_ENV` in a cross-platform manner. + +* `--ext` (`-x`) option allows you to set the file extensions for your output files when using `--dir`. +* `--env` allows you to set `NODE_ENV` in a cross-platform manner. Migration guide for upgrading from v2: https://github.com/postcss/postcss-cli/wiki/Migrating-from-v2-to-v3 -3.0.0-beta / 2017-03-17 -========== +# 3.0.0-beta / 2017-03-17 ## Breaking Changes -- Uses https://github.com/michael-ciniawsky/postcss-load-config for config files. Dropped support for the v2 config file format. -- Can't set input files in config file; pass input files on the command line instead. -- `--use` accepts a list of plugins. This may cause issues if you have your list of css files at the end of your command. -- Can't pass options to plugins via `--plugin.key=value` anymore, use a config file. -- Changed usage of the `--map` option; use `--map` for external sourcemaps, `--no-map` to disable all maps. Inline sourcemaps are default. -- Removed `--log` flag; this behavior is now default. -- Removed the `--local-plugins` flag; same result can be achieved with `postcss.config.js`. -- Removed the global `watchCSS` handler, plugins that import/rely on other files should use a `dependency` message instead. + +* Uses https://github.com/michael-ciniawsky/postcss-load-config for config files. Dropped support for the v2 config file format. +* Can't set input files in config file; pass input files on the command line instead. +* `--use` accepts a list of plugins. This may cause issues if you have your list of css files at the end of your command. +* Can't pass options to plugins via `--plugin.key=value` anymore, use a config file. +* Changed usage of the `--map` option; use `--map` for external sourcemaps, `--no-map` to disable all maps. Inline sourcemaps are default. +* Removed `--log` flag; this behavior is now default. +* Removed the `--local-plugins` flag; same result can be achieved with `postcss.config.js`. +* Removed the global `watchCSS` handler, plugins that import/rely on other files should use a `dependency` message instead. ## New Features -- `--ext` (`-x`) option allows you to set the file extensions for your output files when using `--dir`. -- `--env` allows you to set `NODE_ENV` in a cross-platform manner. + +* `--ext` (`-x`) option allows you to set the file extensions for your output files when using `--dir`. +* `--env` allows you to set `NODE_ENV` in a cross-platform manner. Migration guide: https://github.com/postcss/postcss-cli/wiki/Migrating-from-v2-to-v3 -2.6.0 / 2016-08-30 -================== +# 2.6.0 / 2016-08-30 - * Add log option - * Update postcss-import to v8.1.2 from v7.1.0 - * Update globby to v4.1.0 from v3.0.1 - * Update postcss-url to v5.1.2 from v4.0.0 - * Update jshint to v2.9.2 from v2.6.3 - * Update chokidar to v1.5.1 from v1.0.3 - * Update yargs to v4.7.1 from v3.32.0 - * Support es6 export - * Allow running without plugins - * Add test for --poll - * Add --poll flag +* Add log option +* Update postcss-import to v8.1.2 from v7.1.0 +* Update globby to v4.1.0 from v3.0.1 +* Update postcss-url to v5.1.2 from v4.0.0 +* Update jshint to v2.9.2 from v2.6.3 +* Update chokidar to v1.5.1 from v1.0.3 +* Update yargs to v4.7.1 from v3.32.0 +* Support es6 export +* Allow running without plugins +* Add test for --poll +* Add --poll flag -2.5.2 / 2016-04-18 -================== +# 2.5.2 / 2016-04-18 - * Fix typo in help message: -use => [--use|-u] - * npm install --save mkdirp - * Support mkdirp to create dest path if it doesn't exists - * Fix booleans in config file +* Fix typo in help message: -use => [--use|-u] +* npm install --save mkdirp +* Support mkdirp to create dest path if it doesn't exists +* Fix booleans in config file -2.5.1 / 2016-02-11 -================== +# 2.5.1 / 2016-02-11 - * fix `input` argument +* fix `input` argument -2.5.0 / 2016-01-30 -================== +# 2.5.0 / 2016-01-30 - * move to postcss/postcss-cli repository - * Update Readme.md +* move to postcss/postcss-cli repository +* Update Readme.md -2.4.1 / 2016-01-27 -================== +# 2.4.1 / 2016-01-27 - * improve warning disply format +* improve warning disply format -2.4.0 / 2016-01-15 -================== +# 2.4.0 / 2016-01-15 - * add support for source maps +* add support for source maps -2.3.3 / 2015-12-28 -================== +# 2.3.3 / 2015-12-28 - * add usage example for `local-plugins` option in config file +* add usage example for `local-plugins` option in config file -2.3.2 / 2015-10-27 -================== +# 2.3.2 / 2015-10-27 - * auto-configure postcss-import support - * add support for watching multiple entry points +* auto-configure postcss-import support +* add support for watching multiple entry points -2.3.1 / 2015-10-25 -================== +# 2.3.1 / 2015-10-25 - * update Travis config - * upgrade postcss-import dependency - fix deprecation warnings during make test-watch +* update Travis config +* upgrade postcss-import dependency - fix deprecation warnings during make test-watch -2.3.0 / 2015-10-24 -================== +# 2.3.0 / 2015-10-24 - * add --local-plugins option that lets postcss-cli to look for plugins in current directory +* add --local-plugins option that lets postcss-cli to look for plugins in current directory -2.2.0 / 2015-10-09 -================== +# 2.2.0 / 2015-10-09 - * add support for --replace|-r - if used input files are replaced with generated output - * refactor support for custom syntax options +* add support for --replace|-r - if used input files are replaced with generated output +* refactor support for custom syntax options -2.1.1 / 2015-10-08 -================== +# 2.1.1 / 2015-10-08 - * add globby to support wildcards in Windows - * remove obsolete note on postcss-import compatibility +* add globby to support wildcards in Windows +* remove obsolete note on postcss-import compatibility -2.1.0 / 2015-09-01 -================== +# 2.1.0 / 2015-09-01 - * add support for PostCSS 5.0 custom syntax options +* add support for PostCSS 5.0 custom syntax options -2.0.0 / 2015-08-24 -================== +# 2.0.0 / 2015-08-24 - * remove support for --safe option - * switch to using postcss 5.x +* remove support for --safe option +* switch to using postcss 5.x -1.5.0 / 2015-07-20 -================== +# 1.5.0 / 2015-07-20 - * add watch mode (-w|--watch) in which postcss-cli observes and recompiles inputs whenever they change - * update neo-async dependency to released version - * update postcss-url dependency (used in tests only) +* add watch mode (-w|--watch) in which postcss-cli observes and recompiles inputs whenever they change +* update neo-async dependency to released version +* update postcss-url dependency (used in tests only) -1.4.0 / 2015-07-12 -================== +# 1.4.0 / 2015-07-12 - * allow specifying input file via config file - * allow specifying -u|--use via config file +* allow specifying input file via config file +* allow specifying -u|--use via config file -1.3.1 / 2015-05-03 -================== +# 1.3.1 / 2015-05-03 - * update npm keyword: postcssrunner -> postcss-runner +* update npm keyword: postcssrunner -> postcss-runner -1.3.0 / 2015-04-28 -================== +# 1.3.0 / 2015-04-28 - * add support for stdin/stdout if no input/output file specified +* add support for stdin/stdout if no input/output file specified -1.2.1 / 2015-04-20 -================== +# 1.2.1 / 2015-04-20 - * fix typo in readme +* fix typo in readme -1.2.0 / 2015-04-02 -================== +# 1.2.0 / 2015-04-02 - * display warnings and errors - * stop testing on node 0.10 +* display warnings and errors +* stop testing on node 0.10 -1.1.0 / 2015-03-28 -================== +# 1.1.0 / 2015-03-28 - * prefer postcss async API if available +* prefer postcss async API if available -1.0.0 / 2015-03-22 -================== +# 1.0.0 / 2015-03-22 - * use official yargs version - * add support for multiple input files +* use official yargs version +* add support for multiple input files -0.3.0 / 2015-03-19 -================== +# 0.3.0 / 2015-03-19 - * support JS format as plugins config +* support JS format as plugins config -0.2.0 / 2015-03-13 -================== +# 0.2.0 / 2015-03-13 - * use autoprefixer instead of autoprefixer-core - * change short options for --use from `p` to `u` - * add -v|--version support - * add --safe option to enable postcss safe mode +* use autoprefixer instead of autoprefixer-core +* change short options for --use from `p` to `u` +* add -v|--version support +* add --safe option to enable postcss safe mode -0.1.0 / 2015-03-11 -================== +# 0.1.0 / 2015-03-11 - * initial implementaion +* initial implementaion diff --git a/README.md b/README.md index 49b8bf8..8351fdc 100644 --- a/README.md +++ b/README.md @@ -70,18 +70,19 @@ Input files may contain globs. If you pass an input directory, it will process all files in the directory and any subdirectories. ``` -> ℹ️ More details on custom parsers, stringifiers and syntaxes, can be found [here](https://github.com/postcss/postcss#syntaxes). +> ℹ️ More details on custom parsers, stringifiers and syntaxes, can be found [here](https://github.com/postcss/postcss#syntaxes). ### [Config](https://github.com/michael-ciniawsky/postcss-load-config) If you need to pass options to your plugins, or have a long plugin chain, you'll want to use a configuration file. **postcss.config.js** + ```js module.exports = { parser: 'sugarss', plugins: [ - require('postcss-import')({...options}), + require('postcss-import')({ ...options }), require('postcss-url')({ url: 'copy', useHash: true }) ] } @@ -93,58 +94,53 @@ Note that you **can not** set the `from` or `to` options for postcss in the conf For more advanced usage it's recommend to to use a function in `postcss.config.js`, this gives you access to the CLI context to dynamically apply options and plugins **per file** -|Name|Type|Default|Description| -|:--:|:--:|:-----:|:----------| -|`env`|`{String}`|`'development'`|process.env.NODE_ENV| -|`file`|`{Object}`|`dirname, basename, extname`|File| -|`options`|`{Object}`|`map, parser, syntax, stringifier`|PostCSS Options| +| Name | Type | Default | Description | +| :-------: | :--------: | :--------------------------------: | :------------------- | +| `env` | `{String}` | `'development'` | process.env.NODE_ENV | +| `file` | `{Object}` | `dirname, basename, extname` | File | +| `options` | `{Object}` | `map, parser, syntax, stringifier` | PostCSS Options | **postcss.config.js** + ```js -module.exports = (ctx) => ({ +module.exports = ctx => ({ map: ctx.options.map, parser: ctx.file.extname === '.sss' ? 'sugarss' : false, plugins: { 'postcss-import': { root: ctx.file.dirname }, - 'cssnano': ctx.env === 'production' ? {} : false + cssnano: ctx.env === 'production' ? {} : false } }) ``` -> ⚠️ If you want to set options via CLI, it's mandatory to reference `ctx.options` in `postcss.config.js` - +> ⚠️ If you want to set options via CLI, it's mandatory to reference `ctx.options` in `postcss.config.js` ```bash postcss input.sss -p sugarss -o output.css -m ``` **postcss.config.js** + ```js -module.exports = (ctx) => ({ +module.exports = ctx => ({ map: ctx.options.map, parser: ctx.options.parser, plugins: { 'postcss-import': { root: ctx.file.dirname }, - 'cssnano': ctx.env === 'production' ? {} : false + cssnano: ctx.env === 'production' ? {} : false } }) ``` - [npm]: https://img.shields.io/npm/v/postcss-cli.svg [npm-url]: https://npmjs.com/package/postcss-cli - [node]: https://img.shields.io/node/v/postcss-cli.svg [node-url]: https://nodejs.org/ - [deps]: https://img.shields.io/gemnasium/postcss/postcss-cli.svg [deps-url]: https://gemnasium.com/postcss/postcss-cli - [tests]: http://img.shields.io/travis/postcss/postcss-cli/master.svg [tests-url]: https://travis-ci.org/postcss/postcss-cli - [cover]: https://img.shields.io/coveralls/postcss/postcss-cli/master.svg [cover-url]: https://coveralls.io/github/postcss/postcss-cli - [chat]: https://img.shields.io/gitter/room/postcss/postcss.svg [chat-url]: https://gitter.im/postcss/postcss diff --git a/package.json b/package.json index 6541366..15713dd 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,10 @@ "postcss": "./bin/postcss" }, "scripts": { - "ci": "eslint . && nyc ava -v", + "ci": "eslint . && nyc ava -v && npm run prettier -- --list-different", "clean": "node test/helpers/clean.js", - "format": "eslint . --fix", + "prettier": "prettier --single-quote --no-semi **/*.{js,md}", + "format": "npm run prettier -- --write && eslint . --fix", "pretest": "npm run clean && npm run format", "test": "nyc ava -v" }, @@ -35,11 +36,10 @@ "coveralls": "^3.0.0", "eslint": "^4.2.0", "eslint-config-problems": "0.0.2", - "eslint-plugin-prettier": "^2.1.2", "nyc": "^11.0.2", "per-env": "^1.0.2", "postcss-import": "^11.0.0", - "prettier": "1.9.2", + "prettier": "1.10.2", "standard": "^10.0.2", "sugarss": "^1.0.0", "uuid": "^3.0.1"