Skip to content

Commit

Permalink
Merge pull request #229 from ChristianMurphy/renovate/eslint-config-g…
Browse files Browse the repository at this point in the history
…oogle-0.x

chore: update dependency eslint-config-google to v0.10.0
  • Loading branch information
ChristianMurphy committed Sep 22, 2018
2 parents 6026035 + 8813dbc commit e17924c
Show file tree
Hide file tree
Showing 9 changed files with 362 additions and 286 deletions.
39 changes: 20 additions & 19 deletions README.md
@@ -1,14 +1,15 @@

# Postcss combine duplicated selectors

<!-- current project status -->

[![npm](https://img.shields.io/npm/v/postcss-combine-duplicated-selectors.svg)](https://www.npmjs.com/package/postcss-combine-duplicated-selectors)
[![Linux Build Status](https://travis-ci.org/ChristianMurphy/postcss-combine-duplicated-selectors.svg?branch=master)](https://travis-ci.org/ChristianMurphy/postcss-combine-duplicated-selectors)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/2dq6frg0c72il8v5/branch/master?svg=true)](https://ci.appveyor.com/project/ChristianMurphy/postcss-combine-duplicated-selectors/branch/master)
[![Dependency Status](https://david-dm.org/ChristianMurphy/postcss-combine-duplicated-selectors.svg)](https://david-dm.org/ChristianMurphy/postcss-combine-duplicated-selectors)
[![devDependency Status](https://david-dm.org/ChristianMurphy/postcss-combine-duplicated-selectors/dev-status.svg)](https://david-dm.org/ChristianMurphy/postcss-combine-duplicated-selectors?type=dev)

<!-- standards and technologies used in project -->

[![Built with PostCSS](https://img.shields.io/badge/built_with-postcss-blue.svg)](http://postcss.org/)
[![Semver](http://img.shields.io/SemVer/2.0.0.png)](http://semver.org/spec/v2.0.0.html)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
Expand All @@ -25,56 +26,56 @@ In order to use this you will need to have [postcss](https://github.com/postcss/

### Using PostCSS JS API

``` js
```js
'use strict';

const fs = require('fs');
const postcss = require('postcss');
const css = fs.readFileSync('src/app.css');

postcss([require('postcss-combine-duplicated-selectors')])
.process(css, {from: 'src/app.css', to: 'app.css'})
.then((result) => {
fs.writeFileSync('app.css', result.css);
if (result.map) fs.writeFileSync('app.css.map', result.map);
});
.process(css, {from: 'src/app.css', to: 'app.css'})
.then((result) => {
fs.writeFileSync('app.css', result.css);
if (result.map) fs.writeFileSync('app.css.map', result.map);
});
```

### Using PostCSS CLI

``` sh
```sh
postcss style.css --use postcss-combine-duplicated-selectors --output newcss.css
```

## Example

Input

``` css
```css
.module {
color: green
color: green;
}
.another-module {
color: blue
color: blue;
}
.module {
background: red
background: red;
}
.another-module {
background: yellow
background: yellow;
}
```

Output

``` css
```css
.module {
color: green;
background: red
background: red;
}
.another-module {
color: blue;
background: yellow
background: yellow;
}
```

Expand All @@ -84,7 +85,7 @@ Duplicated properties can optionally be combined.

Set the `removeDuplicatedProperties` option to `true` to enable.

``` js
```js
const postcss = require('postcss');
const combineSelectors = require('postcss-combine-duplicated-selectors');

Expand All @@ -93,7 +94,7 @@ postcss([combineSelectors({removeDuplicatedProperties: true})]);

When enabled the following css

``` css
```css
.a {
height: 10px;
background: orange;
Expand All @@ -112,4 +113,4 @@ will combine into

### Media Queries

If you have code with media queries, pass code through [*mq-packer*](https://github.com/hail2u/node-css-mqpacker) before *postcss-combine-duplicated-selectors* to ensure optimal results.
If you have code with media queries, pass code through [_mq-packer_](https://github.com/hail2u/node-css-mqpacker) before _postcss-combine-duplicated-selectors_ to ensure optimal results.
19 changes: 12 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -42,7 +42,7 @@
"@commitlint/travis-cli": "7.1.2",
"ava": "0.25.0",
"eslint": "5.6.0",
"eslint-config-google": "0.9.1",
"eslint-config-google": "0.10.0",
"eslint-plugin-ava": "5.1.1",
"eslint-plugin-markdown": "1.0.0-beta.8",
"husky": "0.14.3",
Expand Down
14 changes: 7 additions & 7 deletions src/index.js
Expand Up @@ -51,10 +51,10 @@ function removeDupProperties(selector) {
}

const uniformStyle = parser(
(selector) => {
normalizeAttributes(selector);
sortGroups(selector);
}
(selector) => {
normalizeAttributes(selector);
sortGroups(selector);
}
);

const defaultOptions = {
Expand Down Expand Up @@ -89,9 +89,9 @@ module.exports = postcss.plugin(name, (options) => {
}

const selector = uniformStyle.processSync(
rule.selector, {
lossless: false,
}
rule.selector, {
lossless: false,
}
);

if (map.has(selector)) {
Expand Down

0 comments on commit e17924c

Please sign in to comment.