Skip to content

Commit 1ca24e6

Browse files
jonathantnealromainmenke
authored andcommitted
0.1.0
1 parent 955c698 commit 1ca24e6

19 files changed

+1201
-0
lines changed

plugins/css-has-pseudo/.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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

plugins/css-has-pseudo/.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
node_modules
2+
/browser.js*
3+
/cli.js*
4+
/index.js*
5+
/index.mjs*
6+
/postcss.js*
7+
/postcss.mjs*
8+
package-lock.json
9+
*.log*
10+
*.result.css
11+
.*
12+
!.appveyor.yml
13+
!.editorconfig
14+
!.gitignore
15+
!.rollup.js
16+
!.tape.js
17+
!.travis.yml

plugins/css-has-pseudo/.rollup.js

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import babel from 'rollup-plugin-babel';
2+
import { terser } from 'rollup-plugin-terser';
3+
4+
const isCLI = String(process.env.NODE_ENV).includes('cli');
5+
const isPostCSS = String(process.env.NODE_ENV).includes('postcss');
6+
const isBrowser = String(process.env.NODE_ENV).includes('browser');
7+
8+
const input = `src/${isCLI ? 'cli' : isPostCSS ? 'postcss' : 'browser'}.js`;
9+
10+
const output = isCLI
11+
? { file: 'cli.js', format: 'cjs' }
12+
: isPostCSS
13+
? [
14+
{ file: 'postcss.js', format: 'cjs', sourcemap: true },
15+
{ file: 'postcss.mjs', format: 'esm', sourcemap: true }
16+
] : isBrowser
17+
? { file: 'browser.js', format: 'cjs' }
18+
: [
19+
{ file: 'index.js', format: 'cjs', sourcemap: true },
20+
{ file: 'index.mjs', format: 'esm', sourcemap: true }
21+
];
22+
23+
const targets = isCLI || isPostCSS || !isBrowser ? { node: 6 } : 'last 2 versions, not dead';
24+
const plugins = [
25+
babel({
26+
presets: [
27+
['@babel/env', { targets }]
28+
]
29+
})
30+
].concat(isBrowser
31+
? [
32+
trimContentForBrowser(),
33+
terser()
34+
]
35+
: isCLI
36+
? [
37+
trimContentForBrowser(),
38+
addHashBang()
39+
]
40+
: []);
41+
42+
export default { input, output, plugins };
43+
44+
function addHashBang() {
45+
return {
46+
name: 'add-hash-bang',
47+
renderChunk(code) {
48+
const updatedCode = `#!/usr/bin/env node\n\n${code}`;
49+
50+
return updatedCode;
51+
}
52+
};
53+
}
54+
55+
function trimContentForBrowser() {
56+
return {
57+
name: 'trim-content-for-browser',
58+
renderChunk(code) {
59+
const updatedCode = code
60+
.replace(/'use strict';\n*/, '')
61+
.replace(/\n*module\.exports = cssHas;/, '');
62+
63+
return updatedCode;
64+
}
65+
};
66+
}

plugins/css-has-pseudo/.tape.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
'css-has-pseudo': {
3+
'basic': {
4+
message: 'supports basic usage'
5+
},
6+
'basic:preserve': {
7+
message: 'supports { preserve: false } usage',
8+
options: {
9+
preserve: false
10+
}
11+
}
12+
}
13+
};

plugins/css-has-pseudo/.travis.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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

plugins/css-has-pseudo/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changes to CSS Has Pseudo
2+
3+
### 0.1.0 (November 20, 2018)
4+
5+
- Initial version
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Contributing to CSS Has Pseudo
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/css-has-pseudo.git
24+
25+
# Navigate to the newly cloned directory
26+
cd css-has-pseudo
27+
28+
# Assign the original repo to a remote called "upstream"
29+
git remote add upstream git@github.com:csstools/css-has-pseudo.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/
+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# Installing PostCSS
2+
3+
[CSS Has Pseudo] 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 [CSS Has Pseudo] to your project:
11+
12+
```bash
13+
npm install css-has-pseudo --save-dev
14+
```
15+
16+
Use [CSS Has Pseudo] to process your CSS:
17+
18+
```js
19+
const postcssHasPseudo = require('css-has-pseudo/postcss');
20+
21+
postcssHasPseudo.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 postcssHasPseudo = require('css-has-pseudo/postcss');
29+
30+
postcss([
31+
postcssHasPseudo(/* 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 [CSS Has Pseudo] in your `postcss.config.js` configuration file:
44+
45+
```js
46+
const postcssHasPseudo = require('css-has-pseudo/postcss');
47+
48+
module.exports = {
49+
plugins: [
50+
postcssHasPseudo(/* 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 [CSS Has Pseudo] in your Webpack configuration:
64+
65+
```js
66+
const postcssHasPseudo = require('css-has-pseudo/postcss');
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+
postcssHasPseudo(/* 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 [CSS Has Pseudo] in your
98+
`config-overrides.js`
99+
file:
100+
101+
```js
102+
const reactAppRewirePostcss = require('react-app-rewire-postcss');
103+
const postcssHasPseudo = require('css-has-pseudo/postcss');
104+
105+
module.exports = config => reactAppRewirePostcss(config, {
106+
plugins: () => [
107+
postcssHasPseudo(/* pluginOptions */)
108+
]
109+
});
110+
```
111+
112+
## Gulp
113+
114+
Add [Gulp PostCSS] to your project:
115+
116+
```bash
117+
npm install gulp-postcss --save-dev
118+
```
119+
120+
Use [CSS Has Pseudo] in your Gulpfile:
121+
122+
```js
123+
const postcss = require('gulp-postcss');
124+
const postcssHasPseudo = require('css-has-pseudo/postcss');
125+
126+
gulp.task('css', () => gulp.src('./src/*.css').pipe(
127+
postcss([
128+
postcssHasPseudo(/* pluginOptions */)
129+
])
130+
).pipe(
131+
gulp.dest('.')
132+
));
133+
```
134+
135+
## Grunt
136+
137+
Add [Grunt PostCSS] to your project:
138+
139+
```bash
140+
npm install grunt-postcss --save-dev
141+
```
142+
143+
Use [CSS Has Pseudo] in your Gruntfile:
144+
145+
```js
146+
const postcssHasPseudo = require('css-has-pseudo/postcss');
147+
148+
grunt.loadNpmTasks('grunt-postcss');
149+
150+
grunt.initConfig({
151+
postcss: {
152+
options: {
153+
use: [
154+
postcssHasPseudo(/* pluginOptions */)
155+
]
156+
},
157+
dist: {
158+
src: '*.css'
159+
}
160+
}
161+
});
162+
```
163+
164+
[CSS Has Pseudo]: https://github.com/csstools/css-has-pseudo
165+
[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
166+
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
167+
[PostCSS]: https://github.com/postcss/postcss
168+
[PostCSS CLI]: https://github.com/postcss/postcss-cli
169+
[PostCSS Loader]: https://github.com/postcss/postcss-loader
170+
[React App Rewire PostCSS]: https://github.com/csstools/react-app-rewire-postcss
171+
[React App Rewired]: https://github.com/timarney/react-app-rewired

0 commit comments

Comments
 (0)