Skip to content

Commit

Permalink
style: update to latest google code style formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianMurphy committed Sep 22, 2018
1 parent fe281e2 commit 8813dbc
Show file tree
Hide file tree
Showing 7 changed files with 349 additions and 278 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.
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 8813dbc

Please sign in to comment.