Skip to content

Commit d3d7786

Browse files
committed
postcss-base-plugin
1 parent 2cbb93d commit d3d7786

40 files changed

+516
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
package-lock.json
3+
yarn.lock
4+
*.result.css
5+
*.result.css.map
6+
dist/*

plugins/postcss-base-plugin/.tape.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
basic: {
3+
message: "supports basic usage",
4+
},
5+
'basic:color': {
6+
message: "supports { color: '<a color>' }",
7+
options: {
8+
color: 'purple'
9+
}
10+
},
11+
example: {
12+
message: "minimal example",
13+
},
14+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Changes to PostCSS Base Plugin
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Contributing to PostCSS Base Plugin
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-dir-pseudo-class.git
24+
25+
# Navigate to the newly cloned directory
26+
cd postcss-dir-pseudo-class
27+
28+
# Assign the original repo to a remote called "upstream"
29+
git remote add upstream git@github.com:jonathantneal/postcss-dir-pseudo-class.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/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Installing PostCSS Base Plugin
2+
3+
<!-- TODO -->
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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/.

plugins/postcss-base-plugin/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# PostCSS Base Plugin [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss]
2+
3+
<!-- TODO -->
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "@csstools/postcss-base-plugin",
3+
"private": "true",
4+
"version": "0.0.0",
5+
"description": "A base plugin",
6+
"author": "Jonathan Neal <jonathantneal@hotmail.com>",
7+
"license": "CC0-1.0",
8+
"engines": {
9+
"node": "^12 || ^14 || >=16"
10+
},
11+
"main": "dist/index.cjs",
12+
"module": "dist/index.mjs",
13+
"types": "dist/index.d.ts",
14+
"files": [
15+
"CHANGELOG.md",
16+
"INSTALL.md",
17+
"LICENSE.md",
18+
"README.md",
19+
"dist"
20+
],
21+
"bin": {
22+
"postcss-base-plugin": "dist/cli.mjs"
23+
},
24+
"scripts": {
25+
"prepublishOnly": "npm run build --if-present && npm run test --if-present",
26+
"lint": "eslint src/**/*.ts",
27+
"test": "postcss-tape && bash ./test/cli/test.sh",
28+
"build": "rollup -c ../../rollup/default.ts.js",
29+
"stryker": "stryker run --logLevel error"
30+
},
31+
"devDependencies": {
32+
"@csstools/base-cli": "^0.1.0",
33+
"postcss": "^8.3.6",
34+
"postcss-tape": "^6.0.1"
35+
},
36+
"peerDependencies": {
37+
"postcss": "^8.3"
38+
},
39+
"repository": {
40+
"type": "git",
41+
"url": "https://github.com/csstools/postcss-plugins.git",
42+
"directory": "plugins/postcss-base-plugin"
43+
}
44+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import plugin from '@csstools/postcss-base-plugin';
2+
import { cli, helpTextLogger } from '@csstools/base-cli';
3+
4+
cli(
5+
plugin,
6+
['color', 'another_option'],
7+
helpTextLogger(
8+
'postcss-base-plugin-cli',
9+
'Base Plugin',
10+
'An example plugin CLI',
11+
{
12+
color: 'A CSS color',
13+
another_option: true,
14+
},
15+
),
16+
);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { PluginCreator } from 'postcss';
2+
3+
const creator: PluginCreator<{ color: string }> = (opts?: { color: string }) => {
4+
return {
5+
postcssPlugin: 'postcss-base-plugin',
6+
Declaration(decl) {
7+
if (decl.value === 'red') {
8+
if (opts?.color) {
9+
decl.value = opts.color;
10+
} else {
11+
decl.value = 'blue';
12+
}
13+
}
14+
},
15+
};
16+
};
17+
18+
creator.postcss = true;
19+
20+
export default creator;
21+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "../../node_modules/@stryker-mutator/core/schema/stryker-schema.json",
3+
"mutate": [
4+
"src/**/*.ts"
5+
],
6+
"buildCommand": "npm run build",
7+
"testRunner": "command",
8+
"coverageAnalysis": "perTest",
9+
"tempDirName": "../../.stryker-tmp",
10+
"commandRunner": {
11+
"command": "npm run test:tape"
12+
},
13+
"thresholds": {
14+
"high": 100,
15+
"low": 100,
16+
"break": 100
17+
},
18+
"inPlace": true
19+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.foo {
2+
color: purple;
3+
}
4+
5+
.baz {
6+
color: green;
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.foo {
2+
color: red;
3+
}
4+
5+
.baz {
6+
color: green;
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.foo {
2+
color: blue;
3+
}
4+
5+
.baz {
6+
color: green;
7+
}

plugins/postcss-base-plugin/test/cli/basic.color.expect.css

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.foo {
2+
color: red;
3+
}

plugins/postcss-base-plugin/test/cli/basic.expect.css

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/postcss-base-plugin/test/cli/basic.external-map.expect.css

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/postcss-base-plugin/test/cli/basic.external-map.expect.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/postcss-base-plugin/test/cli/basic.failure.expect.css

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.foo {
2+
color: blue;
3+
}

plugins/postcss-base-plugin/test/cli/basic.replace.css

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/postcss-base-plugin/test/cli/basic.replace.expect.css

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/postcss-base-plugin/test/cli/basic.stdin.expect.css

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/postcss-base-plugin/test/cli/out/a.css

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/postcss-base-plugin/test/cli/out/a.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/postcss-base-plugin/test/cli/out/a.expect.css

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)