Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Commit 74b4b08

Browse files
committed
Merge pull request #114 from jonathanKingston/eslint-integration
Adding in ESLint and fixing basic errors to match #104
2 parents f8dabb5 + 7883208 commit 74b4b08

14 files changed

+149
-269
lines changed

.eslintrc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
ecmaFeatures:
3+
modules: true
4+
5+
env:
6+
es6: true
7+
browser: true
8+
node: true
9+
10+
# 0: off, 1: warning, 2: error
11+
rules:
12+
# semicolons are useless
13+
semi: [2, "never"]
14+
15+
quotes: [2, "double"]
16+
17+
# 2 spaces indentation
18+
indent: [2, 2]
19+
20+
# trailing coma are cool for diff
21+
comma-dangle: [2, "always-multiline"]
22+
23+
# enforce comma at eol (never before)
24+
comma-style: [2, "last"]

.jscsrc

Lines changed: 0 additions & 131 deletions
This file was deleted.

.jshintrc

Lines changed: 0 additions & 9 deletions
This file was deleted.

index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Modules dependencies
33
*/
4-
var Postcss = require("postcss")
4+
var postcss = require("postcss")
55
var assign = require("object-assign")
66
var caniuse = require("caniuse-api")
77

@@ -31,7 +31,7 @@ var caniuseFeaturesMap = {
3131
// autoprefixer: [null] // will always be null since autoprefixer does the same game as we do
3232
}
3333

34-
var features = {
34+
var libraryFeatures = {
3535
// Reminder: order is important
3636
customProperties: function(options) { return require("postcss-custom-properties")(options) },
3737
calc: function(options) { return require("postcss-calc")(options)},
@@ -50,7 +50,7 @@ var features = {
5050
pseudoClassMatches: function(options) { return require("postcss-selector-matches")(options)},
5151
pseudoClassNot: function(options) { return require("postcss-selector-not")(options)},
5252
colorRgba: function(options) { return require("postcss-color-rgba-fallback")(options)},
53-
autoprefixer: function(options) { return require("autoprefixer-core")(options).postcss}
53+
autoprefixer: function(options) { return require("autoprefixer-core")(options).postcss},
5454
}
5555

5656
/**
@@ -98,19 +98,19 @@ function cssnext(string, options) {
9898
if (features.autoprefixer.browsers === undefined) {delete features.autoprefixer.browsers}
9999
}
100100

101-
var postcss = Postcss()
101+
var postcssInstance = postcss()
102102

103103
// only enable import & url if fs module is available
104104
var fs = require("fs")
105105
if (fs && fs.readFile) {
106106
// @import
107107
if (options.import !== false) {
108-
postcss.use(require("postcss-import")(typeof options.import === "object" ? options.import : undefined))
108+
postcssInstance.use(require("postcss-import")(typeof options.import === "object" ? options.import : undefined))
109109
}
110110

111111
// url() adjustements
112112
if (options.url !== false) {
113-
postcss.use(require("postcss-url")(typeof options.url === "object" ? options.url : undefined))
113+
postcssInstance.use(require("postcss-url")(typeof options.url === "object" ? options.url : undefined))
114114
}
115115
}
116116

@@ -135,19 +135,19 @@ function cssnext(string, options) {
135135
)
136136
)
137137
) {
138-
postcss.use(cssnext.features[key](typeof features[key] === "object" ? features[key] : undefined))
138+
postcssInstance.use(cssnext.features[key](typeof features[key] === "object" ? features[key] : undefined))
139139
}
140140
})
141141

142142
// minification
143143
if (options.compress) {
144144
var csswring = require("csswring")
145-
postcss.use(typeof options.compress === "object" ? csswring(options.compress) : csswring)
145+
postcssInstance.use(typeof options.compress === "object" ? csswring(options.compress) : csswring)
146146
}
147147

148148
// classic API if string is passed
149149
if (typeof string === "string") {
150-
var result = postcss.process(string, options)
150+
var result = postcssInstance.process(string, options)
151151

152152
// default behavior, cssnext returns a css string if no or inline sourcemap
153153
if (options.map === null || (options.map === true || options.map.inline)) {
@@ -159,7 +159,7 @@ function cssnext(string, options) {
159159
}
160160
// or return the postcss instance that can be consumed as a postcss plugin
161161
else {
162-
return postcss
162+
return postcssInstance
163163
}
164164
}
165165

@@ -168,4 +168,4 @@ function cssnext(string, options) {
168168
*
169169
* @type {Object}
170170
*/
171-
cssnext.features = features
171+
cssnext.features = libraryFeatures

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,14 @@
6262
},
6363
"devDependencies": {
6464
"browserify": "^8.1.1",
65-
"jscs": "^1.6.2",
66-
"jshint": "^2.5.6",
65+
"eslint": "^0.20.0",
6766
"microtime": "^1.2.0",
6867
"tape": "^3.0.0"
6968
},
7069
"scripts": {
7170
"standalone": "browserify --standalone cssnext index.js -o dist/cssnext.js",
72-
"jscs": "jscs .",
73-
"jshint": "jshint . --exclude-path .gitignore",
74-
"pretest": "npm run jscs && npm run jshint && npm run standalone",
71+
"eslint": "eslint --ignore-path .gitignore -f tap .",
72+
"pretest": "npm run eslint && npm run standalone",
7573
"test": "tape test/*.js"
7674
},
7775
"bin": {

test/cases.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ test("use case: use plugin options", function(t) {
2929
{
3030
features: {
3131
customProperties: {
32-
preserve: true
33-
}
34-
}
32+
preserve: true,
33+
},
34+
},
3535
}
3636
),
3737
utils.readFixture("cases/plugin-options.expected"),

0 commit comments

Comments
 (0)