diff --git a/plugins/postcss-place/.editorconfig b/plugins/postcss-place/.editorconfig deleted file mode 100644 index e06d7982b..000000000 --- a/plugins/postcss-place/.editorconfig +++ /dev/null @@ -1,15 +0,0 @@ -root = true - -[*] -charset = utf-8 -end_of_line = lf -indent_style = tab -insert_final_newline = true -trim_trailing_whitespace = true - -[*.md] -trim_trailing_whitespace = false - -[*.{json,md,yml}] -indent_size = 2 -indent_style = space diff --git a/plugins/postcss-place/.gitattributes b/plugins/postcss-place/.gitattributes deleted file mode 100644 index 6313b56c5..000000000 --- a/plugins/postcss-place/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto eol=lf diff --git a/plugins/postcss-place/.github/workflows/test.yml b/plugins/postcss-place/.github/workflows/test.yml deleted file mode 100644 index 4067cf59b..000000000 --- a/plugins/postcss-place/.github/workflows/test.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: test -on: - push: - -jobs: - test: - runs-on: ubuntu-latest - strategy: - matrix: - node: [12, 14, 16] - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node }} - - - run: npm install --ignore-scripts - - run: npm run test diff --git a/plugins/postcss-place/.gitignore b/plugins/postcss-place/.gitignore index 72a6a3d37..b5d13c8c0 100644 --- a/plugins/postcss-place/.gitignore +++ b/plugins/postcss-place/.gitignore @@ -1,13 +1,13 @@ -dist node_modules +dist package-lock.json yarn.lock *.log* *.result.css -.* +*.result.css.map !.editorconfig -!.gitattributes !.gitignore !.rollup.js !.tape.js +!.travis.yml !.github diff --git a/plugins/postcss-place/.rollup.js b/plugins/postcss-place/.rollup.js deleted file mode 100644 index 4e8adac9e..000000000 --- a/plugins/postcss-place/.rollup.js +++ /dev/null @@ -1,26 +0,0 @@ -import babel from '@rollup/plugin-babel'; - -export default { - input: 'src/index.js', - output: [ - { file: 'dist/index.js', format: 'cjs', sourcemap: true, exports: 'default' }, - { file: 'dist/index.mjs', format: 'esm', sourcemap: true, exports: 'default' } - ], - plugins: [ - babel({ - babelHelpers: 'bundled', - presets: [ - ['@babel/preset-env', { - corejs: 3, - loose: true, - modules: false, - targets: { node: 10 }, - useBuiltIns: 'entry' - }] - ] - }), - ], - onwarn(warning, warn) { - if (warning.code !== 'UNRESOLVED_IMPORT') warn(warning) - } -} diff --git a/plugins/postcss-place/CONTRIBUTING.md b/plugins/postcss-place/CONTRIBUTING.md deleted file mode 100644 index 7f4dd7306..000000000 --- a/plugins/postcss-place/CONTRIBUTING.md +++ /dev/null @@ -1,65 +0,0 @@ -# Contributing to PostCSS Place Properties - -You want to help? You rock! Now, take a moment to be sure your contributions -make sense to everyone else. - -## Reporting Issues - -Found a problem? Want a new feature? - -- See if your issue or idea has [already been reported]. -- Provide a [reduced test case] or a [live example]. - -Remember, a bug is a _demonstrable problem_ caused by _our_ code. - -## Submitting Pull Requests - -Pull requests are the greatest contributions, so be sure they are focused in -scope and avoid unrelated commits. - -1. To begin; [fork this project], clone your fork, and add our upstream. - ```bash - # Clone your fork of the repo into the current directory - git clone git@github.com:YOUR_USER/postcss-place.git - - # Navigate to the newly cloned directory - cd postcss-place - - # Assign the original repo to a remote called "upstream" - git remote add upstream git@github.com:csstools/postcss-place.git - - # Install the tools necessary for testing - npm install - ``` - -2. Create a branch for your feature or fix: - ```bash - # Move into a new branch for your feature - git checkout -b feature/thing - ``` - ```bash - # Move into a new branch for your fix - git checkout -b fix/something - ``` - -3. If your code follows our practices, then push your feature branch: - ```bash - # Test current code - npm test - ``` - ```bash - # Push the branch for your new feature - git push origin feature/thing - ``` - ```bash - # Or, push the branch for your update - git push origin update/something - ``` - -That’s it! Now [open a pull request] with a clear title and description. - -[already been reported]: issues -[fork this project]: fork -[live example]: https://codepen.io/pen -[open a pull request]: https://help.github.com/articles/using-pull-requests/ -[reduced test case]: https://css-tricks.com/reduced-test-cases/ diff --git a/plugins/postcss-place/INSTALL.md b/plugins/postcss-place/INSTALL.md index 287cd5333..2a356b822 100644 --- a/plugins/postcss-place/INSTALL.md +++ b/plugins/postcss-place/INSTALL.md @@ -157,6 +157,6 @@ grunt.initConfig({ [PostCSS]: https://github.com/postcss/postcss [PostCSS CLI]: https://github.com/postcss/postcss-cli [PostCSS Loader]: https://github.com/postcss/postcss-loader -[PostCSS Place Properties]: https://github.com/csstools/postcss-place +[PostCSS Place Properties]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-place [React App Rewire PostCSS]: https://github.com/csstools/react-app-rewire-postcss [React App Rewired]: https://github.com/timarney/react-app-rewired diff --git a/plugins/postcss-place/README.md b/plugins/postcss-place/README.md index 20295ae2e..b060e1fb5 100644 --- a/plugins/postcss-place/README.md +++ b/plugins/postcss-place/README.md @@ -2,7 +2,7 @@ [NPM Version][npm-url] [CSS Standard Status][css-url] -[Build Status][cli-url] +[Build Status][cli-url] [Support Chat][git-url] [PostCSS Place Properties] lets you use `place-*` properties as shorthands for `align-*` @@ -77,7 +77,7 @@ postcssPlace({ preserve: false }) } ``` -[cli-url]: https://github.com/csstools/postcss-place/actions/workflows/test.yml?query=workflow/test +[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test [css-url]: https://cssdb.org/#place-properties [git-url]: https://gitter.im/postcss/postcss [npm-url]: https://www.npmjs.com/package/postcss-place @@ -87,4 +87,4 @@ postcssPlace({ preserve: false }) [Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss [PostCSS]: https://github.com/postcss/postcss [PostCSS Loader]: https://github.com/postcss/postcss-loader -[PostCSS Place Properties]: https://github.com/csstools/postcss-place +[PostCSS Place Properties]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-place diff --git a/plugins/postcss-place/package.json b/plugins/postcss-place/package.json index 8d3ccdf44..eede19f40 100755 --- a/plugins/postcss-place/package.json +++ b/plugins/postcss-place/package.json @@ -4,62 +4,39 @@ "description": "Use a place-* shorthand for align-* and justify-* in CSS", "author": "Jonathan Neal ", "license": "CC0-1.0", - "repository": "csstools/postcss-place", - "homepage": "https://github.com/csstools/postcss-place#readme", - "bugs": "https://github.com/csstools/postcss-place/issues", - "main": "dist/index.js", + "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-place#readme", + "bugs": "https://github.com/csstools/postcss-plugins/issues", + "main": "dist/index.cjs", "module": "dist/index.mjs", "files": [ + "CHANGELOG.md", + "INSTALL.md", + "LICENSE.md", + "README.md", "dist" ], + "bin": { + "postcss-place": "dist/cli.mjs" + }, "scripts": { - "build": "npx rollup -c .rollup.js", - "build:watch": "npx rollup -c .rollup.js --watch", - "lint": "npx eslint --cache src", - "lint:fix": "npx eslint --cache --fix", - "pretest": "npm install && npm run build", - "test": "npm run lint && npm run tape", - "tape": "npx postcss-tape", - "prepublishOnly": "npm test" + "prepublishOnly": "npm run build && npm run test", + "lint": "eslint src/**/*.js", + "test": "postcss-tape", + "build": "rollup -c ../../rollup/default.js", + "stryker": "stryker run --logLevel error" }, "engines": { - "node": ">=12" + "node": "^12 || ^14 || >=16" }, "dependencies": { "postcss-values-parser": "6.0.1" }, - "peerDependencies": { - "postcss": "^8.3" - }, "devDependencies": { - "@babel/core": "^7.16.0", - "@babel/preset-env": "^7.16.4", - "@rollup/plugin-babel": "^5.3.0", - "eslint": "^8.2.0", - "postcss": "^8.3.11", - "postcss-tape": "^6.0.1", - "pre-commit": "^1.2.2", - "rollup": "^2.60.0" + "postcss": "8.3.6", + "postcss-tape": "6.0.1" }, - "babel": { - "presets": [ - [ - "@babel/env", - { - "targets": "maintained node versions" - } - ] - ] - }, - "eslintConfig": { - "env": { - "es6": true, - "node": true - }, - "extends": "eslint:recommended", - "parserOptions": { - "sourceType": "module" - } + "peerDependencies": { + "postcss": "^8.3" }, "keywords": [ "postcss", @@ -72,5 +49,10 @@ "aligns", "contents", "selfs" - ] + ], + "repository": { + "type": "git", + "url": "https://github.com/csstools/postcss-plugins.git", + "directory": "plugins/postcss-place" + } } diff --git a/plugins/postcss-place/src/cli.js b/plugins/postcss-place/src/cli.js new file mode 100644 index 000000000..5a5d96ac7 --- /dev/null +++ b/plugins/postcss-place/src/cli.js @@ -0,0 +1,15 @@ +import plugin from './index'; +import { cli, helpTextLogger } from '@csstools/base-cli'; + +cli( + plugin, + ['preserve'], + helpTextLogger( + 'postcss-place', + 'PostCSS Place', + 'Lets you use place-* properties as shorthands for align-* and justify-*, following the CSS Box Alignment specification.', + { + preserve: true, + }, + ), +); diff --git a/plugins/postcss-place/src/index.js b/plugins/postcss-place/src/index.js index c95266181..541884057 100755 --- a/plugins/postcss-place/src/index.js +++ b/plugins/postcss-place/src/index.js @@ -1,20 +1,20 @@ -import options from './options' -import onCSSDeclaration, { placeMatch } from './onCSSDeclaration' +import options from './options'; +import onCSSDeclaration, { placeMatch } from './onCSSDeclaration'; const creator = opts => { // prepare options - if ('preserve' in Object(opts)) options.preserve = Boolean(opts.preserve) + if ('preserve' in Object(opts)) options.preserve = Boolean(opts.preserve); return { postcssPlugin: 'postcss-place', Declaration: (decl, { result }) => { if (placeMatch.test(decl)) { - onCSSDeclaration(decl, { result }) + onCSSDeclaration(decl, { result }); } }, - } -} + }; +}; -creator.postcss = true +creator.postcss = true; -export default creator +export default creator; diff --git a/plugins/postcss-place/src/onCSSDeclaration.js b/plugins/postcss-place/src/onCSSDeclaration.js index 4a7c33205..b941e919b 100644 --- a/plugins/postcss-place/src/onCSSDeclaration.js +++ b/plugins/postcss-place/src/onCSSDeclaration.js @@ -1,47 +1,47 @@ -import { parse } from 'postcss-values-parser' -import options from './options' +import { parse } from 'postcss-values-parser'; +import options from './options'; export default (decl, { result }) => { // alignment - const alignment = decl.prop.match(placeMatch)[1] + const alignment = decl.prop.match(placeMatch)[1]; // value ast and child nodes - let value + let value; try { - value = parse(decl.value) + value = parse(decl.value); } catch (error) { decl.warn( result, - `Failed to parse value '${decl.value}'. Leaving the original value intact.` - ) + `Failed to parse value '${decl.value}'. Leaving the original value intact.`, + ); } if (typeof value === 'undefined') { - return + return; } - let alignmentValues = [] + let alignmentValues = []; value.walkWords(walk => { alignmentValues.push( - walk.parent.type === 'root' ? walk.toString() : walk.parent.toString() - ) - }) + walk.parent.type === 'root' ? walk.toString() : walk.parent.toString(), + ); + }); decl.cloneBefore({ prop: `align-${alignment}`, - value: alignmentValues[0] - }) + value: alignmentValues[0], + }); decl.cloneBefore({ prop: `justify-${alignment}`, - value: alignmentValues[1] || alignmentValues[0] - }) + value: alignmentValues[1] || alignmentValues[0], + }); // conditionally remove place-[alignment] if (!options.preserve) { - decl.remove() + decl.remove(); } -} +}; -export const placeMatch = /^place-(content|items|self)/ +export const placeMatch = /^place-(content|items|self)/; diff --git a/plugins/postcss-place/src/options.js b/plugins/postcss-place/src/options.js index 62ef20da9..484ccd4a4 100644 --- a/plugins/postcss-place/src/options.js +++ b/plugins/postcss-place/src/options.js @@ -1,4 +1,4 @@ export default { /** Whether to preserve the original place value. */ - preserve: true -} + preserve: true, +};