Skip to content

Commit f69b796

Browse files
authored
Migrate postcss-place (#42)
* Migrate postcss-place * Migrate postcss-place
1 parent 78f2c49 commit f69b796

File tree

13 files changed

+77
-205
lines changed

13 files changed

+77
-205
lines changed

plugins/postcss-place/.editorconfig

-15
This file was deleted.

plugins/postcss-place/.gitattributes

-1
This file was deleted.

plugins/postcss-place/.github/workflows/test.yml

-18
This file was deleted.

plugins/postcss-place/.gitignore

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
dist
21
node_modules
2+
dist
33
package-lock.json
44
yarn.lock
55
*.log*
66
*.result.css
7-
.*
7+
*.result.css.map
88
!.editorconfig
9-
!.gitattributes
109
!.gitignore
1110
!.rollup.js
1211
!.tape.js
12+
!.travis.yml
1313
!.github

plugins/postcss-place/.rollup.js

-26
This file was deleted.

plugins/postcss-place/CONTRIBUTING.md

-65
This file was deleted.

plugins/postcss-place/INSTALL.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,6 @@ grunt.initConfig({
157157
[PostCSS]: https://github.com/postcss/postcss
158158
[PostCSS CLI]: https://github.com/postcss/postcss-cli
159159
[PostCSS Loader]: https://github.com/postcss/postcss-loader
160-
[PostCSS Place Properties]: https://github.com/csstools/postcss-place
160+
[PostCSS Place Properties]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-place
161161
[React App Rewire PostCSS]: https://github.com/csstools/react-app-rewire-postcss
162162
[React App Rewired]: https://github.com/timarney/react-app-rewired

plugins/postcss-place/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[<img alt="NPM Version" src="https://img.shields.io/npm/v/postcss-place.svg" height="20">][npm-url]
44
[<img alt="CSS Standard Status" src="https://cssdb.org/badge/double-position-gradients.svg" height="20">][css-url]
5-
[<img alt="Build Status" src="https://github.com/csstools/postcss-place/workflows/test/badge.svg" height="20">][cli-url]
5+
[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url]
66
[<img alt="Support Chat" src="https://img.shields.io/badge/support-chat-blue.svg" height="20">][git-url]
77

88
[PostCSS Place Properties] lets you use `place-*` properties as shorthands for `align-*`
@@ -77,7 +77,7 @@ postcssPlace({ preserve: false })
7777
}
7878
```
7979

80-
[cli-url]: https://github.com/csstools/postcss-place/actions/workflows/test.yml?query=workflow/test
80+
[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
8181
[css-url]: https://cssdb.org/#place-properties
8282
[git-url]: https://gitter.im/postcss/postcss
8383
[npm-url]: https://www.npmjs.com/package/postcss-place
@@ -87,4 +87,4 @@ postcssPlace({ preserve: false })
8787
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
8888
[PostCSS]: https://github.com/postcss/postcss
8989
[PostCSS Loader]: https://github.com/postcss/postcss-loader
90-
[PostCSS Place Properties]: https://github.com/csstools/postcss-place
90+
[PostCSS Place Properties]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-place

plugins/postcss-place/package.json

+26-44
Original file line numberDiff line numberDiff line change
@@ -4,62 +4,39 @@
44
"description": "Use a place-* shorthand for align-* and justify-* in CSS",
55
"author": "Jonathan Neal <jonathantneal@hotmail.com>",
66
"license": "CC0-1.0",
7-
"repository": "csstools/postcss-place",
8-
"homepage": "https://github.com/csstools/postcss-place#readme",
9-
"bugs": "https://github.com/csstools/postcss-place/issues",
10-
"main": "dist/index.js",
7+
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-place#readme",
8+
"bugs": "https://github.com/csstools/postcss-plugins/issues",
9+
"main": "dist/index.cjs",
1110
"module": "dist/index.mjs",
1211
"files": [
12+
"CHANGELOG.md",
13+
"INSTALL.md",
14+
"LICENSE.md",
15+
"README.md",
1316
"dist"
1417
],
18+
"bin": {
19+
"postcss-place": "dist/cli.mjs"
20+
},
1521
"scripts": {
16-
"build": "npx rollup -c .rollup.js",
17-
"build:watch": "npx rollup -c .rollup.js --watch",
18-
"lint": "npx eslint --cache src",
19-
"lint:fix": "npx eslint --cache --fix",
20-
"pretest": "npm install && npm run build",
21-
"test": "npm run lint && npm run tape",
22-
"tape": "npx postcss-tape",
23-
"prepublishOnly": "npm test"
22+
"prepublishOnly": "npm run build && npm run test",
23+
"lint": "eslint src/**/*.js",
24+
"test": "postcss-tape",
25+
"build": "rollup -c ../../rollup/default.js",
26+
"stryker": "stryker run --logLevel error"
2427
},
2528
"engines": {
26-
"node": ">=12"
29+
"node": "^12 || ^14 || >=16"
2730
},
2831
"dependencies": {
2932
"postcss-values-parser": "6.0.1"
3033
},
31-
"peerDependencies": {
32-
"postcss": "^8.3"
33-
},
3434
"devDependencies": {
35-
"@babel/core": "^7.16.0",
36-
"@babel/preset-env": "^7.16.4",
37-
"@rollup/plugin-babel": "^5.3.0",
38-
"eslint": "^8.2.0",
39-
"postcss": "^8.3.11",
40-
"postcss-tape": "^6.0.1",
41-
"pre-commit": "^1.2.2",
42-
"rollup": "^2.60.0"
35+
"postcss": "8.3.6",
36+
"postcss-tape": "6.0.1"
4337
},
44-
"babel": {
45-
"presets": [
46-
[
47-
"@babel/env",
48-
{
49-
"targets": "maintained node versions"
50-
}
51-
]
52-
]
53-
},
54-
"eslintConfig": {
55-
"env": {
56-
"es6": true,
57-
"node": true
58-
},
59-
"extends": "eslint:recommended",
60-
"parserOptions": {
61-
"sourceType": "module"
62-
}
38+
"peerDependencies": {
39+
"postcss": "^8.3"
6340
},
6441
"keywords": [
6542
"postcss",
@@ -72,5 +49,10 @@
7249
"aligns",
7350
"contents",
7451
"selfs"
75-
]
52+
],
53+
"repository": {
54+
"type": "git",
55+
"url": "https://github.com/csstools/postcss-plugins.git",
56+
"directory": "plugins/postcss-place"
57+
}
7658
}

plugins/postcss-place/src/cli.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import plugin from './index';
2+
import { cli, helpTextLogger } from '@csstools/base-cli';
3+
4+
cli(
5+
plugin,
6+
['preserve'],
7+
helpTextLogger(
8+
'postcss-place',
9+
'PostCSS Place',
10+
'Lets you use place-* properties as shorthands for align-* and justify-*, following the CSS Box Alignment specification.',
11+
{
12+
preserve: true,
13+
},
14+
),
15+
);

plugins/postcss-place/src/index.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import options from './options'
2-
import onCSSDeclaration, { placeMatch } from './onCSSDeclaration'
1+
import options from './options';
2+
import onCSSDeclaration, { placeMatch } from './onCSSDeclaration';
33

44
const creator = opts => {
55
// prepare options
6-
if ('preserve' in Object(opts)) options.preserve = Boolean(opts.preserve)
6+
if ('preserve' in Object(opts)) options.preserve = Boolean(opts.preserve);
77

88
return {
99
postcssPlugin: 'postcss-place',
1010
Declaration: (decl, { result }) => {
1111
if (placeMatch.test(decl)) {
12-
onCSSDeclaration(decl, { result })
12+
onCSSDeclaration(decl, { result });
1313
}
1414
},
15-
}
16-
}
15+
};
16+
};
1717

18-
creator.postcss = true
18+
creator.postcss = true;
1919

20-
export default creator
20+
export default creator;
+19-19
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
import { parse } from 'postcss-values-parser'
2-
import options from './options'
1+
import { parse } from 'postcss-values-parser';
2+
import options from './options';
33

44
export default (decl, { result }) => {
55
// alignment
6-
const alignment = decl.prop.match(placeMatch)[1]
6+
const alignment = decl.prop.match(placeMatch)[1];
77

88
// value ast and child nodes
9-
let value
9+
let value;
1010

1111
try {
12-
value = parse(decl.value)
12+
value = parse(decl.value);
1313
} catch (error) {
1414
decl.warn(
1515
result,
16-
`Failed to parse value '${decl.value}'. Leaving the original value intact.`
17-
)
16+
`Failed to parse value '${decl.value}'. Leaving the original value intact.`,
17+
);
1818
}
1919

2020
if (typeof value === 'undefined') {
21-
return
21+
return;
2222
}
2323

24-
let alignmentValues = []
24+
let alignmentValues = [];
2525
value.walkWords(walk => {
2626
alignmentValues.push(
27-
walk.parent.type === 'root' ? walk.toString() : walk.parent.toString()
28-
)
29-
})
27+
walk.parent.type === 'root' ? walk.toString() : walk.parent.toString(),
28+
);
29+
});
3030

3131
decl.cloneBefore({
3232
prop: `align-${alignment}`,
33-
value: alignmentValues[0]
34-
})
33+
value: alignmentValues[0],
34+
});
3535

3636
decl.cloneBefore({
3737
prop: `justify-${alignment}`,
38-
value: alignmentValues[1] || alignmentValues[0]
39-
})
38+
value: alignmentValues[1] || alignmentValues[0],
39+
});
4040

4141
// conditionally remove place-[alignment]
4242
if (!options.preserve) {
43-
decl.remove()
43+
decl.remove();
4444
}
45-
}
45+
};
4646

47-
export const placeMatch = /^place-(content|items|self)/
47+
export const placeMatch = /^place-(content|items|self)/;

plugins/postcss-place/src/options.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export default {
22
/** Whether to preserve the original place value. */
3-
preserve: true
4-
}
3+
preserve: true,
4+
};

0 commit comments

Comments
 (0)