├── .editorconfig ├── .gitignore ├── .rollup.js ├── .tape.js ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── INSTALL.md ├── LICENSE.md ├── README.md ├── index.js ├── package.json └── test ├── basic.css ├── basic.expect.css ├── basic.w-prefix.expect.css ├── prefix.css ├── prefix.expect.css ├── prefix.w-prefix.expect.css ├── skipped.css └── skipped.expect.css /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_style = tab 7 | insert_final_newline = true 8 | trim_trailing_whitespace = true 9 | 10 | [*.md] 11 | trim_trailing_whitespace = false 12 | 13 | [*.{json,md,yml}] 14 | indent_size = 2 15 | indent_style = space 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | index.*.* 3 | package-lock.json 4 | *.log* 5 | *.result.css 6 | .* 7 | !.editorconfig 8 | !.gitignore 9 | !.rollup.js 10 | !.tape.js 11 | !.travis.yml 12 | -------------------------------------------------------------------------------- /.rollup.js: -------------------------------------------------------------------------------- 1 | import babel from 'rollup-plugin-babel'; 2 | 3 | export default { 4 | input: 'index.js', 5 | output: [ 6 | { file: 'index.cjs.js', format: 'cjs', sourcemap: true }, 7 | { file: 'index.es.mjs', format: 'es', sourcemap: true } 8 | ], 9 | plugins: [ 10 | babel({ 11 | presets: [ 12 | ['@babel/env', { modules: false, targets: { node: 6 } }] 13 | ] 14 | }) 15 | ] 16 | }; 17 | -------------------------------------------------------------------------------- /.tape.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'postcss-short-size': { 3 | 'basic': { 4 | message: 'supports basic usage' 5 | }, 6 | 'basic:w-prefix': { 7 | message: 'ignores basic usage when { prefix: "x" }', 8 | options: { 9 | prefix: 'x' 10 | } 11 | }, 12 | 'prefix': { 13 | message: 'ignores prefix usage' 14 | }, 15 | 'prefix:w-prefix': { 16 | message: 'supports prefix usage when { prefix: "x" }', 17 | options: { 18 | prefix: 'x' 19 | } 20 | }, 21 | 'skipped': { 22 | message: 'supports skip tokens' 23 | } 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # https://docs.travis-ci.com/user/travis-lint 2 | 3 | language: node_js 4 | 5 | node_js: 6 | - 6 7 | 8 | install: 9 | - npm install --ignore-scripts 10 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changes to PostCSS Short Size 2 | 3 | ### 4.0.0 (October 9, 2018) 4 | 5 | - Added: Support for Node 6 6 | - Added: Support for PostCSS 7 7 | 8 | ### 3.0.0 (May 25, 2017) 9 | 10 | - Added: Support for PostCSS 6, Node 4 11 | - Removed: echint and jscs devDependencies 12 | - Updated: 2 spaces in Markdown 13 | - Updated: dependencies 14 | 15 | ### 2.0.1 (December 8, 2016) 16 | 17 | - Updated: Use destructing assignment on plugin options 18 | - Updated: Use template literals 19 | 20 | ### 2.0.0 (December 6, 2016) 21 | 22 | - Added: Define `skip` token 23 | - Updated: boilerplate conventions (Node v6.9.1 LTS) 24 | 25 | ### 1.1.0 (March 5, 2015) 26 | 27 | - Added: Support for aspect-ratio as partial value 28 | - Updated: Tests 29 | 30 | ### 1.0.0 (September 21, 2015) 31 | 32 | - Added: Initial version 33 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to PostCSS Short Size 2 | 3 | You want to help? You rock! Now, take a moment to be sure your contributions 4 | make sense to everyone else. 5 | 6 | ## Reporting Issues 7 | 8 | Found a problem? Want a new feature? 9 | 10 | - See if your issue or idea has [already been reported]. 11 | - Provide a [reduced test case] or a [live example]. 12 | 13 | Remember, a bug is a _demonstrable problem_ caused by _our_ code. 14 | 15 | ## Submitting Pull Requests 16 | 17 | Pull requests are the greatest contributions, so be sure they are focused in 18 | scope and avoid unrelated commits. 19 | 20 | 1. To begin; [fork this project], clone your fork, and add our upstream. 21 | ```bash 22 | # Clone your fork of the repo into the current directory 23 | git clone git@github.com:YOUR_USER/postcss-short-size.git 24 | 25 | # Navigate to the newly cloned directory 26 | cd postcss-short-size 27 | 28 | # Assign the original repo to a remote called "upstream" 29 | git remote add upstream git@github.com:jonathantneal/postcss-short-size.git 30 | 31 | # Install the tools necessary for testing 32 | npm install 33 | ``` 34 | 35 | 2. Create a branch for your feature or fix: 36 | ```bash 37 | # Move into a new branch for your feature 38 | git checkout -b feature/thing 39 | ``` 40 | ```bash 41 | # Move into a new branch for your fix 42 | git checkout -b fix/something 43 | ``` 44 | 45 | 3. If your code follows our practices, then push your feature branch: 46 | ```bash 47 | # Test current code 48 | npm test 49 | ``` 50 | ```bash 51 | # Push the branch for your new feature 52 | git push origin feature/thing 53 | ``` 54 | ```bash 55 | # Or, push the branch for your update 56 | git push origin update/something 57 | ``` 58 | 59 | That’s it! Now [open a pull request] with a clear title and description. 60 | 61 | [already been reported]: issues 62 | [fork this project]: fork 63 | [live example]: https://codepen.io/pen 64 | [open a pull request]: https://help.github.com/articles/using-pull-requests/ 65 | [reduced test case]: https://css-tricks.com/reduced-test-cases/ 66 | -------------------------------------------------------------------------------- /INSTALL.md: -------------------------------------------------------------------------------- 1 | # Installing PostCSS Short Size 2 | 3 | [PostCSS Short Size] runs in all Node environments, with special instructions for: 4 | 5 | | [Node](#node) | [PostCSS CLI](#postcss-cli) | [Webpack](#webpack) | [Create React App](#create-react-app) | [Gulp](#gulp) | [Grunt](#grunt) | 6 | | --- | --- | --- | --- | --- | --- | 7 | 8 | ## Node 9 | 10 | Add [PostCSS Short Size] to your project: 11 | 12 | ```bash 13 | npm install postcss-short-size --save-dev 14 | ``` 15 | 16 | Use [PostCSS Short Size] to process your CSS: 17 | 18 | ```js 19 | const postcssShortSize = require('postcss-short-size'); 20 | 21 | postcssShortSize.process(YOUR_CSS /*, processOptions, pluginOptions */); 22 | ``` 23 | 24 | Or use it as a [PostCSS] plugin: 25 | 26 | ```js 27 | const postcss = require('postcss'); 28 | const postcssShortSize = require('postcss-short-size'); 29 | 30 | postcss([ 31 | postcssShortSize(/* pluginOptions */) 32 | ]).process(YOUR_CSS /*, processOptions */); 33 | ``` 34 | 35 | ## PostCSS CLI 36 | 37 | Add [PostCSS CLI] to your project: 38 | 39 | ```bash 40 | npm install postcss-cli --save-dev 41 | ``` 42 | 43 | Use [PostCSS Short Size] in your `postcss.config.js` configuration file: 44 | 45 | ```js 46 | const postcssShortSize = require('postcss-short-size'); 47 | 48 | module.exports = { 49 | plugins: [ 50 | postcssShortSize(/* pluginOptions */) 51 | ] 52 | } 53 | ``` 54 | 55 | ## Webpack 56 | 57 | Add [PostCSS Loader] to your project: 58 | 59 | ```bash 60 | npm install postcss-loader --save-dev 61 | ``` 62 | 63 | Use [PostCSS Short Size] in your Webpack configuration: 64 | 65 | ```js 66 | const postcssShortSize = require('postcss-short-size'); 67 | 68 | module.exports = { 69 | module: { 70 | rules: [ 71 | { 72 | test: /\.css$/, 73 | use: [ 74 | 'style-loader', 75 | { loader: 'css-loader', options: { importLoaders: 1 } }, 76 | { loader: 'postcss-loader', options: { 77 | ident: 'postcss', 78 | plugins: () => [ 79 | postcssShortSize(/* pluginOptions */) 80 | ] 81 | } } 82 | ] 83 | } 84 | ] 85 | } 86 | } 87 | ``` 88 | 89 | ## Create React App 90 | 91 | Add [React App Rewired] and [React App Rewire PostCSS] to your project: 92 | 93 | ```bash 94 | npm install react-app-rewired react-app-rewire-postcss --save-dev 95 | ``` 96 | 97 | Use [React App Rewire PostCSS] and [PostCSS Short Size] in your 98 | `config-overrides.js` file: 99 | 100 | ```js 101 | const reactAppRewirePostcss = require('react-app-rewire-postcss'); 102 | const postcssShortSize = require('postcss-short-size'); 103 | 104 | module.exports = config => reactAppRewirePostcss(config, { 105 | plugins: () => [ 106 | postcssShortSize(/* pluginOptions */) 107 | ] 108 | }); 109 | ``` 110 | 111 | ## Gulp 112 | 113 | Add [Gulp PostCSS] to your project: 114 | 115 | ```bash 116 | npm install gulp-postcss --save-dev 117 | ``` 118 | 119 | Use [PostCSS Short Size] in your Gulpfile: 120 | 121 | ```js 122 | const postcss = require('gulp-postcss'); 123 | const postcssShortSize = require('postcss-short-size'); 124 | 125 | gulp.task('css', () => gulp.src('./src/*.css').pipe( 126 | postcss([ 127 | postcssShortSize(/* pluginOptions */) 128 | ]) 129 | ).pipe( 130 | gulp.dest('.') 131 | )); 132 | ``` 133 | 134 | ## Grunt 135 | 136 | Add [Grunt PostCSS] to your project: 137 | 138 | ```bash 139 | npm install grunt-postcss --save-dev 140 | ``` 141 | 142 | Use [PostCSS Short Size] in your Gruntfile: 143 | 144 | ```js 145 | const postcssShortSize = require('postcss-short-size'); 146 | 147 | grunt.loadNpmTasks('grunt-postcss'); 148 | 149 | grunt.initConfig({ 150 | postcss: { 151 | options: { 152 | use: [ 153 | postcssShortSize(/* pluginOptions */) 154 | ] 155 | }, 156 | dist: { 157 | src: '*.css' 158 | } 159 | } 160 | }); 161 | ``` 162 | 163 | [Gulp PostCSS]: https://github.com/postcss/gulp-postcss 164 | [Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss 165 | [PostCSS]: https://github.com/postcss/postcss 166 | [PostCSS CLI]: https://github.com/postcss/postcss-cli 167 | [PostCSS Loader]: https://github.com/postcss/postcss-loader 168 | [PostCSS Short Size]: https://github.com/jonathantneal/postcss-short-size 169 | [React App Rewire PostCSS]: https://github.com/csstools/react-app-rewire-postcss 170 | [React App Rewired]: https://github.com/timarney/react-app-rewired 171 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # CC0 1.0 Universal 2 | 3 | ## Statement of Purpose 4 | 5 | The laws of most jurisdictions throughout the world automatically confer 6 | exclusive Copyright and Related Rights (defined below) upon the creator and 7 | subsequent owner(s) (each and all, an “owner”) of an original work of 8 | authorship and/or a database (each, a “Work”). 9 | 10 | Certain owners wish to permanently relinquish those rights to a Work for the 11 | purpose of contributing to a commons of creative, cultural and scientific works 12 | (“Commons”) that the public can reliably and without fear of later claims of 13 | infringement build upon, modify, incorporate in other works, reuse and 14 | redistribute as freely as possible in any form whatsoever and for any purposes, 15 | including without limitation commercial purposes. These owners may contribute 16 | to the Commons to promote the ideal of a free culture and the further 17 | production of creative, cultural and scientific works, or to gain reputation or 18 | greater distribution for their Work in part through the use and efforts of 19 | others. 20 | 21 | For these and/or other purposes and motivations, and without any expectation of 22 | additional consideration or compensation, the person associating CC0 with a 23 | Work (the “Affirmer”), to the extent that he or she is an owner of Copyright 24 | and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and 25 | publicly distribute the Work under its terms, with knowledge of his or her 26 | Copyright and Related Rights in the Work and the meaning and intended legal 27 | effect of CC0 on those rights. 28 | 29 | 1. Copyright and Related Rights. A Work made available under CC0 may be 30 | protected by copyright and related or neighboring rights (“Copyright and 31 | Related Rights”). Copyright and Related Rights include, but are not limited 32 | to, the following: 33 | 1. the right to reproduce, adapt, distribute, perform, display, communicate, 34 | and translate a Work; 35 | 2. moral rights retained by the original author(s) and/or performer(s); 36 | 3. publicity and privacy rights pertaining to a person’s image or likeness 37 | depicted in a Work; 38 | 4. rights protecting against unfair competition in regards to a Work, 39 | subject to the limitations in paragraph 4(i), below; 40 | 5. rights protecting the extraction, dissemination, use and reuse of data in 41 | a Work; 42 | 6. database rights (such as those arising under Directive 96/9/EC of the 43 | European Parliament and of the Council of 11 March 1996 on the legal 44 | protection of databases, and under any national implementation thereof, 45 | including any amended or successor version of such directive); and 46 | 7. other similar, equivalent or corresponding rights throughout the world 47 | based on applicable law or treaty, and any national implementations 48 | thereof. 49 | 50 | 2. Waiver. To the greatest extent permitted by, but not in contravention of, 51 | applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and 52 | unconditionally waives, abandons, and surrenders all of Affirmer’s Copyright 53 | and Related Rights and associated claims and causes of action, whether now 54 | known or unknown (including existing as well as future claims and causes of 55 | action), in the Work (i) in all territories worldwide, (ii) for the maximum 56 | duration provided by applicable law or treaty (including future time 57 | extensions), (iii) in any current or future medium and for any number of 58 | copies, and (iv) for any purpose whatsoever, including without limitation 59 | commercial, advertising or promotional purposes (the “Waiver”). Affirmer 60 | makes the Waiver for the benefit of each member of the public at large and 61 | to the detriment of Affirmer’s heirs and successors, fully intending that 62 | such Waiver shall not be subject to revocation, rescission, cancellation, 63 | termination, or any other legal or equitable action to disrupt the quiet 64 | enjoyment of the Work by the public as contemplated by Affirmer’s express 65 | Statement of Purpose. 66 | 67 | 3. Public License Fallback. Should any part of the Waiver for any reason be 68 | judged legally invalid or ineffective under applicable law, then the Waiver 69 | shall be preserved to the maximum extent permitted taking into account 70 | Affirmer’s express Statement of Purpose. In addition, to the extent the 71 | Waiver is so judged Affirmer hereby grants to each affected person a 72 | royalty-free, non transferable, non sublicensable, non exclusive, 73 | irrevocable and unconditional license to exercise Affirmer’s Copyright and 74 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 75 | maximum duration provided by applicable law or treaty (including future time 76 | extensions), (iii) in any current or future medium and for any number of 77 | copies, and (iv) for any purpose whatsoever, including without limitation 78 | commercial, advertising or promotional purposes (the “License”). The License 79 | shall be deemed effective as of the date CC0 was applied by Affirmer to the 80 | Work. Should any part of the License for any reason be judged legally 81 | invalid or ineffective under applicable law, such partial invalidity or 82 | ineffectiveness shall not invalidate the remainder of the License, and in 83 | such case Affirmer hereby affirms that he or she will not (i) exercise any 84 | of his or her remaining Copyright and Related Rights in the Work or (ii) 85 | assert any associated claims and causes of action with respect to the Work, 86 | in either case contrary to Affirmer’s express Statement of Purpose. 87 | 88 | 4. Limitations and Disclaimers. 89 | 1. No trademark or patent rights held by Affirmer are waived, abandoned, 90 | surrendered, licensed or otherwise affected by this document. 91 | 2. Affirmer offers the Work as-is and makes no representations or warranties 92 | of any kind concerning the Work, express, implied, statutory or 93 | otherwise, including without limitation warranties of title, 94 | merchantability, fitness for a particular purpose, non infringement, or 95 | the absence of latent or other defects, accuracy, or the present or 96 | absence of errors, whether or not discoverable, all to the greatest 97 | extent permissible under applicable law. 98 | 3. Affirmer disclaims responsibility for clearing rights of other persons 99 | that may apply to the Work or any use thereof, including without 100 | limitation any person’s Copyright and Related Rights in the Work. 101 | Further, Affirmer disclaims responsibility for obtaining any necessary 102 | consents, permissions or other rights required for any use of the Work. 103 | 4. Affirmer understands and acknowledges that Creative Commons is not a 104 | party to this document and has no duty or obligation with respect to this 105 | CC0 or use of the Work. 106 | 107 | For more information, please see 108 | http://creativecommons.org/publicdomain/zero/1.0/. 109 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PostCSS Short Size [PostCSS][postcss] 2 | 3 | [![NPM Version][npm-img]][npm-url] 4 | [![Build Status][cli-img]][cli-url] 5 | [![Support Chat][git-img]][git-url] 6 | 7 | [PostCSS Short Size] lets you use `size` properties to represent `width` and 8 | `height` in CSS, following the [1-to-2 syntax]. 9 | 10 | ```pcss 11 | .image { 12 | size: 100px; 13 | } 14 | 15 | .video { 16 | max-size: 400px 300px; 17 | } 18 | 19 | /* becomes */ 20 | 21 | .image { 22 | width: 100px; 23 | height: 100px; 24 | } 25 | 26 | .video { 27 | max-width: 400px; 28 | max-height: 300px; 29 | } 30 | ``` 31 | 32 | The supported properties are `size`, `min-size`, and `max-size`. 33 | 34 | ## Usage 35 | 36 | Add [PostCSS Short Size] to your project: 37 | 38 | ```bash 39 | npm install postcss-short-size --save-dev 40 | ``` 41 | 42 | Use [PostCSS Short Size] to process your CSS: 43 | 44 | ```js 45 | const postcssShortSize = require('postcss-short-size'); 46 | 47 | postcssShortSize.process(YOUR_CSS /*, processOptions, pluginOptions */); 48 | ``` 49 | 50 | Or use it as a [PostCSS] plugin: 51 | 52 | ```js 53 | const postcss = require('postcss'); 54 | const postcssShortSize = require('postcss-short-size'); 55 | 56 | postcss([ 57 | postcssShortSize(/* pluginOptions */) 58 | ]).process(YOUR_CSS /*, processOptions */); 59 | ``` 60 | 61 | [PostCSS Short Size] runs in all Node environments, with special instructions for: 62 | 63 | | [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) | 64 | | --- | --- | --- | --- | --- | --- | 65 | 66 | ## Options 67 | 68 | #### prefix 69 | 70 | The `prefix` option defines a prefix required by properties being transformed. 71 | Wrapping dashes are automatically applied, so that `x` would transform 72 | `-x-margin`. 73 | 74 | ```js 75 | postcssShortSize({ prefix: 'x' }); 76 | ``` 77 | 78 | ```pcss 79 | .image { 80 | x-size: 100px; 81 | } 82 | 83 | /* becomes */ 84 | 85 | .image { 86 | width: 100px; 87 | height: 100px; 88 | } 89 | ``` 90 | 91 | #### skip 92 | 93 | The `skip` option defines the skip token used to ignore portions of the 94 | shorthand. 95 | 96 | ```js 97 | postcssShortSize({ skip: '-' }); 98 | ``` 99 | 100 | ```pcss 101 | .image { 102 | size: - 100px; 103 | } 104 | 105 | /* becomes */ 106 | 107 | .image { 108 | height: 100px; 109 | } 110 | ``` 111 | 112 | [cli-img]: https://img.shields.io/travis/jonathantneal/postcss-short-size.svg 113 | [cli-url]: https://travis-ci.org/jonathantneal/postcss-short-size 114 | [git-img]: https://img.shields.io/badge/support-chat-blue.svg 115 | [git-url]: https://gitter.im/postcss/postcss 116 | [npm-img]: https://img.shields.io/npm/v/postcss-short-size.svg 117 | [npm-url]: https://www.npmjs.com/package/postcss-short-size 118 | 119 | [1-to-2 syntax]: https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties#Tricky_edge_cases 120 | [PostCSS]: https://github.com/postcss/postcss 121 | [PostCSS Short Size]: https://github.com/jonathantneal/postcss-short-size 122 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import postcss from 'postcss'; 2 | 3 | export default postcss.plugin('postcss-short-size', opts => { 4 | const prefix = 'prefix' in Object(opts) ? `-${opts.prefix}-` : ''; 5 | const skip = 'skip' in Object(opts) ? String(opts.skip) : '*'; 6 | 7 | // property pattern 8 | const sizePropertyRegExp = new RegExp(`^${prefix}((?:max|min)-)?size$`, 'i'); 9 | 10 | return root => { 11 | // for each size declaration 12 | root.walkDecls(sizePropertyRegExp, decl => { 13 | // min-max property 14 | const minmax = decl.prop.match(sizePropertyRegExp)[1] || ''; 15 | 16 | // space-separated values (width, height) 17 | const values = postcss.list.space(decl.value); 18 | 19 | // width is the first value 20 | let width = values[0]; 21 | 22 | // whether the width matches a length or aspect ratio 23 | const widthLength = width.match(lengthRegExp); 24 | const widthAspectRatio = width.match(aspectRatioRegExp); 25 | 26 | // height is the second value 27 | let height = values[1] || values[0]; 28 | 29 | // whether the height matches a length or aspect ratio 30 | const heightLength = height.match(lengthRegExp); 31 | const heightAspectRatio = height.match(aspectRatioRegExp); 32 | 33 | // conditionally update the width when it is an aspect ratio and the height is a length 34 | if (widthAspectRatio && heightLength) { 35 | width = heightLength[1] / widthAspectRatio[2] * widthAspectRatio[1] + heightLength[2]; 36 | } 37 | 38 | // conditionally update the height when it is an aspect ratio and the width is a length 39 | if (heightAspectRatio && widthLength) { 40 | height = widthLength[1] / heightAspectRatio[1] * heightAspectRatio[2] + widthLength[2]; 41 | } 42 | 43 | // conditionally create a new width declaration if the width is not a skip token 44 | if (width !== skip) { 45 | decl.cloneBefore({ 46 | prop: `${minmax}width`, 47 | value: width 48 | }); 49 | } 50 | 51 | // conditionally create a new height declaration if the height is not a skip token 52 | if (height !== skip) { 53 | decl.cloneBefore({ 54 | prop: `${minmax}height`, 55 | value: height 56 | }); 57 | } 58 | 59 | // remove the original size declaration 60 | decl.remove(); 61 | }); 62 | }; 63 | }); 64 | 65 | const lengthRegExp = /^([-+]?0|[-+]?[0-9]*\.?[0-9]+)(%|\w+)$/; 66 | const aspectRatioRegExp = /^([-+]?[0-9]*\.?[0-9]+)\/([-+]?[0-9]*\.?[0-9]+)$/; 67 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "postcss-short-size", 3 | "version": "4.0.0", 4 | "description": "Use this in CSS", 5 | "author": "Jonathan Neal ", 6 | "license": "CC0-1.0", 7 | "repository": "jonathantneal/postcss-short-size", 8 | "homepage": "https://github.com/jonathantneal/postcss-short-size#readme", 9 | "bugs": "https://github.com/jonathantneal/postcss-short-size/issues", 10 | "main": "index.cjs.js", 11 | "module": "index.es.mjs", 12 | "files": [ 13 | "index.cjs.js", 14 | "index.cjs.js.map", 15 | "index.es.mjs", 16 | "index.es.mjs.map" 17 | ], 18 | "scripts": { 19 | "prepublishOnly": "npm test", 20 | "pretest": "rollup -c .rollup.js --silent", 21 | "test": "echo 'Running tests...'; npm run test:js && npm run test:tape", 22 | "test:js": "eslint *.js --cache --ignore-path .gitignore --quiet", 23 | "test:tape": "postcss-tape" 24 | }, 25 | "engines": { 26 | "node": ">=6.0.0" 27 | }, 28 | "dependencies": { 29 | "postcss": "^7.0.5" 30 | }, 31 | "devDependencies": { 32 | "@babel/core": "^7.1.2", 33 | "@babel/plugin-syntax-dynamic-import": "^7.0.0", 34 | "@babel/preset-env": "^7.1.0", 35 | "babel-eslint": "^10.0.1", 36 | "eslint": "^5.6.1", 37 | "eslint-config-dev": "^2.0.0", 38 | "postcss-tape": "^2.2.0", 39 | "pre-commit": "^1.2.2", 40 | "rollup": "^0.66.5", 41 | "rollup-plugin-babel": "^4.0.3" 42 | }, 43 | "eslintConfig": { 44 | "extends": "dev", 45 | "parser": "babel-eslint" 46 | }, 47 | "keywords": [ 48 | "postcss", 49 | "css", 50 | "postcss-plugin", 51 | "size", 52 | "short", 53 | "shorthand", 54 | "width", 55 | "height" 56 | ] 57 | } 58 | -------------------------------------------------------------------------------- /test/basic.css: -------------------------------------------------------------------------------- 1 | a { 2 | size: 20px 10px; 3 | } 4 | 5 | b { 6 | size: calc(4 * 2px) 2px; 7 | } 8 | 9 | c { 10 | size: fit-content auto; 11 | } 12 | 13 | d { 14 | size: 32px; 15 | } 16 | 17 | e { 18 | size: 4in 4/3; 19 | } 20 | 21 | f { 22 | size: 4/3 3in; 23 | } 24 | 25 | g { 26 | size: 16/9 1080px; 27 | } 28 | -------------------------------------------------------------------------------- /test/basic.expect.css: -------------------------------------------------------------------------------- 1 | a { 2 | width: 20px; 3 | height: 10px; 4 | } 5 | 6 | b { 7 | width: calc(4 * 2px); 8 | height: 2px; 9 | } 10 | 11 | c { 12 | width: fit-content; 13 | height: auto; 14 | } 15 | 16 | d { 17 | width: 32px; 18 | height: 32px; 19 | } 20 | 21 | e { 22 | width: 4in; 23 | height: 3in; 24 | } 25 | 26 | f { 27 | width: 4in; 28 | height: 3in; 29 | } 30 | 31 | g { 32 | width: 1920px; 33 | height: 1080px; 34 | } 35 | -------------------------------------------------------------------------------- /test/basic.w-prefix.expect.css: -------------------------------------------------------------------------------- 1 | a { 2 | size: 20px 10px; 3 | } 4 | 5 | b { 6 | size: calc(4 * 2px) 2px; 7 | } 8 | 9 | c { 10 | size: fit-content auto; 11 | } 12 | 13 | d { 14 | size: 32px; 15 | } 16 | 17 | e { 18 | size: 4in 4/3; 19 | } 20 | 21 | f { 22 | size: 4/3 3in; 23 | } 24 | 25 | g { 26 | size: 16/9 1080px; 27 | } 28 | -------------------------------------------------------------------------------- /test/prefix.css: -------------------------------------------------------------------------------- 1 | a { 2 | -x-size: 20px 10px; 3 | } 4 | 5 | b { 6 | -x-size: calc(4 * 2px) 2px; 7 | } 8 | 9 | c { 10 | -x-size: fit-content auto; 11 | } 12 | -------------------------------------------------------------------------------- /test/prefix.expect.css: -------------------------------------------------------------------------------- 1 | a { 2 | -x-size: 20px 10px; 3 | } 4 | 5 | b { 6 | -x-size: calc(4 * 2px) 2px; 7 | } 8 | 9 | c { 10 | -x-size: fit-content auto; 11 | } 12 | -------------------------------------------------------------------------------- /test/prefix.w-prefix.expect.css: -------------------------------------------------------------------------------- 1 | a { 2 | width: 20px; 3 | height: 10px; 4 | } 5 | 6 | b { 7 | width: calc(4 * 2px); 8 | height: 2px; 9 | } 10 | 11 | c { 12 | width: fit-content; 13 | height: auto; 14 | } 15 | -------------------------------------------------------------------------------- /test/skipped.css: -------------------------------------------------------------------------------- 1 | a { 2 | size: *; 3 | } 4 | 5 | b { 6 | size: * 100px; 7 | } 8 | 9 | c { 10 | size: 100px *; 11 | } 12 | -------------------------------------------------------------------------------- /test/skipped.expect.css: -------------------------------------------------------------------------------- 1 | a { 2 | } 3 | 4 | b { 5 | height: 100px; 6 | } 7 | 8 | c { 9 | width: 100px; 10 | } 11 | --------------------------------------------------------------------------------