Skip to content
This repository has been archived by the owner on Jun 6, 2022. It is now read-only.

Commit

Permalink
3.0.0 (switch to postcss 5.x)
Browse files Browse the repository at this point in the history
  • Loading branch information
MoOx committed Aug 25, 2015
1 parent 5c3f711 commit a96a660
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
15 changes: 10 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# babel support more syntax stuff than eslint for now
parser: babel-eslint

root: true
extends: eslint:recommended

ecmaFeatures:
modules: true

Expand All @@ -20,18 +23,20 @@ rules:
brace-style: [2, "stroustrup"]
comma-dangle: [2, "always-multiline"]
comma-style: [2, "last"]
computed-property-spacing: [2, "never"]
dot-location: [2, "property"]

one-var: [2, "never"]
#no-var: [2]
no-var: [2]
prefer-const: [2]
no-bitwise: [2]

object-shorthand: [2, "methods"]
object-curly-spacing: [2, "never"]
array-bracket-spacing: [2, "never"]
computed-property-spacing: [2, "never"]

space-unary-ops: [2, {"words": true, "nonwords": false}]
space-after-keywords: [2, "always"]
space-before-blocks: [2, "always"]
space-before-function-paren: [2, "never"]
space-in-brackets: [2, "never"]
space-in-parens: [2, "never"]
spaced-line-comment: [2, "always"]
spaced-comment: [2, "always"]
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 3.0.0 - 2015-08-25

- Removed: compatibility with postcss v4.x
- Added: compatibility with postcss v5.x

# 2.3.0 - 2015-07-14

* Fixed: Nested/mixed selectors now works correctly
Expand Down
16 changes: 5 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-custom-selectors",
"version": "2.3.0",
"version": "3.0.0",
"description": "PostCSS plugin to transform W3C CSS Extensions(Custom Selectors) to more compatible CSS",
"keywords": [
"postcss",
Expand All @@ -18,27 +18,21 @@
"type": "git",
"url": "https://github.com/postcss/postcss-custom-selectors.git"
},
"homepage": "https://github.com/postcss/postcss-custom-selectors",
"bugs": {
"url": "https://github.com/postcss/postcss-custom-selectors/issues"
},
"main": "dist/index.js",
"files": [
"CHANGELOG.md",
"LICENSE",
"dist",
"README-zh.md"
],
"main": "dist/index.js",
"dependencies": {
"balanced-match": "^0.2.0",
"postcss": "^4.1.7",
"postcss-selector-matches": "^1.2.1"
"postcss": "^5.0.0",
"postcss-selector-matches": "^2.0.0"
},
"devDependencies": {
"babel": "^5.5.8",
"babel-eslint": "^3.1.15",
"babel-tape-runner": "^1.1.0",
"eslint": "^0.23.0",
"eslint": "^1.0.0",
"tape": "^4.0.0"
},
"scripts": {
Expand Down
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ export default postcss.plugin("postcss-custom-selectors", function(options) {

const transformMatchesOnRule = transformMatches
? (rule) => replaceRuleSelector(rule, {
lineBreak,
})
lineBreak,
})
: (rule) => rule.selector

return function(css, result) {
const toRemove = []
const customSelectors = {}

// first, read custom selectors
css.eachAtRule(function(rule) {
css.walkAtRules(function(rule) {
if (rule.name !== "custom-selector") {
return
}
Expand All @@ -47,7 +47,7 @@ export default postcss.plugin("postcss-custom-selectors", function(options) {
})

// Convert those selectors to :matches()
css.eachRule(function(rule) {
css.walkRules(function(rule) {
if (rule.selector.indexOf(":--") > -1) {
rule.selector = rule.selector.replace(
CUSTOM_SELECTOR_RE,
Expand All @@ -71,7 +71,7 @@ export default postcss.plugin("postcss-custom-selectors", function(options) {
})

toRemove.forEach(function(rule) {
rule.removeSelf()
rule.remove()
})

}
Expand Down
8 changes: 4 additions & 4 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var test = require("tape")
var postcss = require("postcss")
var plugin = require("../src")
import test from "tape"
import postcss from "postcss"
import plugin from "../src"

function transform(input, opts = {}, postcssOpts = {}) {
return postcss()
Expand Down Expand Up @@ -268,7 +268,7 @@ main #nav .bar + p {
"should transform local extensions"
)

var postcssPlugin = postcss().use(plugin())
const postcssPlugin = postcss().use(plugin())
t.ok(
postcssPlugin.process("@custom-selector :--foobar .foo;:--foobar{}").css,
"should not create a memory"
Expand Down

0 comments on commit a96a660

Please sign in to comment.