Skip to content

Commit 0d08922

Browse files
committed
Merge pull request #388 from SassDoc/eslint
[RFR] Switch to ESlint
2 parents 45d9d28 + b8c4746 commit 0d08922

15 files changed

Lines changed: 95 additions & 136 deletions

File tree

.eslintrc

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
parser: "babel-eslint"
2+
3+
env:
4+
node: true
5+
mocha: true
6+
7+
ecmaFeatures:
8+
arrowFunctions: true
9+
blockBindings: true
10+
classes: true
11+
defaultParams: true
12+
destructuring: true
13+
forOf: true
14+
modules: true
15+
objectLiteralComputedProperties: true
16+
objectLiteralDuplicateProperties: true
17+
objectLiteralShorthandMethods: true
18+
objectLiteralShorthandProperties: true
19+
templateStrings: true
20+
restParams: true
21+
spread: true
22+
superInFunctions: true
23+
24+
rules:
25+
no-global-strict: 0
26+
strict: 1
27+
no-undef: 1
28+
no-use-before-define: 0
29+
consistent-return: 0
30+
comma-dangle: "always-multiline"
31+
no-process-exit: 0
32+
33+
quotes: [2, "single"]
34+
indent: [2, 2]
35+
no-mixed-spaces-and-tabs: [1, "smart-tabs"]
36+
no-spaced-func: 1
37+
space-after-keywords: [1, "always"]
38+
space-before-function-parentheses: {"anonymous": "always", "named": "never"}
39+
space-before-function-paren: {"anonymous": "always", "named": "never"}
40+
space-before-blocks: "always"
41+
space-in-brackets: "always"
42+
no-underscore-dangle: 0

.jshintrc

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

.jshintrc.yaml

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

Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ dist:
1313
# Code quality
1414
# ============
1515

16-
lint: .jshintrc
17-
$(BIN)jshint --verbose bin/sassdoc index.js src test
18-
19-
.jshintrc: .jshintrc.yaml
20-
$(BIN)js-yaml $< > $@
16+
lint:
17+
$(BIN)eslint bin/sassdoc index.js src test
2118

2219
test: test/data/expected.stream.json dist
2320
$(BIN)mocha test/**/*.test.js

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@
102102
},
103103
"devDependencies": {
104104
"babel": "4.6.*",
105+
"babel-eslint": "^2.0.2",
105106
"coveralls": "^2.11.2",
106107
"dateformat": "^1.0.11",
108+
"eslint": "^0.18.0",
107109
"istanbul": "^0.3.5",
108110
"jsesc": "^0.5.0",
109111
"jshint": "^2.6.3",

src/annotation/annotations/example.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default function example() {
1414
name: 'example',
1515

1616
parse(text) {
17-
let example = {
17+
let instance = {
1818
type: 'scss', // Default to `scss`.
1919
code: text,
2020
};
@@ -24,17 +24,17 @@ export default function example() {
2424

2525
if (optionalType.trim().length !== 0) {
2626
let typeDesc = descRegEx.exec(optionalType);
27-
example.type = typeDesc[1];
27+
instance.type = typeDesc[1];
2828
if (typeDesc[2].length !== 0) {
29-
example.description = typeDesc[2];
29+
instance.description = typeDesc[2];
3030
}
31-
example.code = text.substr(optionalType.length + 1); // Remove the type
31+
instance.code = text.substr(optionalType.length + 1); // Remove the type
3232
}
3333

3434
// Remove all leading/trailing line breaks.
35-
example.code = example.code.replace(/^\n|\n$/g, '');
35+
instance.code = instance.code.replace(/^\n|\n$/g, '');
3636

37-
return example;
37+
return instance;
3838
},
3939
};
4040
}

src/annotation/annotations/require.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default function (env) {
6060

6161
let functions = searchForMatches(
6262
item.context.code,
63-
new RegExp('(@include)?\\s*([a-z0-9_-]+)\\s*\\(','ig'), // Literal destorys Syntax
63+
new RegExp('(@include)?\\s*([a-z0-9_-]+)\\s*\\(', 'ig'), // Literal destorys Syntax
6464
isAnnotatedByHand.bind(null, handWritten, 'function'),
6565
2 // Get the second matching group instead of 1
6666
);
@@ -187,12 +187,12 @@ function isAnnotatedByHand(handWritten, type, name) {
187187
return false;
188188
}
189189

190-
function searchForMatches(code, regex, isAnnotatedByHand, id = 1) {
190+
function searchForMatches(code, regex, isAnnotatedByHandProxy, id = 1) {
191191
let match;
192192
let matches = [];
193193

194194
while ((match = regex.exec(code))) {
195-
if (!isAnnotatedByHand(match[id]) && (id <= 1 || match[id-1] === undefined)) {
195+
if (!isAnnotatedByHandProxy(match[id]) && (id <= 1 || match[id-1] === undefined)) {
196196
matches.push(match[id]);
197197
}
198198
}

src/environment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export default class Environment extends EventEmitter {
225225

226226
if (typeof this.theme !== 'function') {
227227
this.emit('error', new errors.SassDocError(
228-
`Given theme is ${str(this.theme)}, expected ${str(str)}.`
228+
`Given theme is ${str(this.theme)}, expected ${str(str)}.` // eslint-disable-line comma-spacing
229229
));
230230

231231
return this.defaultTheme();

src/sassdoc.js

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import exclude from './exclude';
99
import recurse from './recurse';
1010

1111
import fs from 'fs';
12-
import path from 'path'; // jshint ignore:line
13-
import difference from 'lodash.difference'; // jshint ignore:line
12+
import path from 'path';
13+
import difference from 'lodash.difference';
1414
import safeWipe from 'safe-wipe';
1515
import vfs from 'vinyl-fs';
1616
import converter from 'sass-convert';
17-
import pipe from 'multipipe'; // jshint ignore:line
17+
import pipe from 'multipipe';
1818
import through from 'through2';
1919
const mkdir = denodeify(require('mkdirp'));
2020

@@ -81,13 +81,13 @@ function ensureLogger(config) {
8181
* @see srcEnv
8282
*/
8383
export default function sassdoc(...args) {
84-
return srcEnv(documentize, stream)(...args); // jshint ignore:line
84+
return srcEnv(documentize, stream)(...args);
8585

8686
/**
8787
* Safely wipe and re-create the destination directory.
8888
* @return {Promise}
8989
*/
90-
function refresh(env) { // jshint ignore:line
90+
function refresh(env) {
9191
return safeWipe(env.dest, {
9292
force: true,
9393
parent: is.string(env.src) || is.array(env.src) ? g2b(env.src) : null,
@@ -107,7 +107,7 @@ export default function sassdoc(...args) {
107107
* Render theme with parsed data context.
108108
* @return {Promise}
109109
*/
110-
function theme(env) { // jshint ignore:line
110+
function theme(env) {
111111
let promise = env.theme(env.dest, env);
112112

113113
if (!is.promise(promise)) {
@@ -126,9 +126,7 @@ export default function sassdoc(...args) {
126126
* Execute full SassDoc sequence from a source directory.
127127
* @return {Promise}
128128
*/
129-
async function documentize(env) { // jshint ignore:line
130-
/* jshint ignore:start */
131-
129+
async function documentize(env) {
132130
init(env);
133131
let data = await baseDocumentize(env);
134132

@@ -142,8 +140,6 @@ export default function sassdoc(...args) {
142140
}
143141

144142
return data;
145-
146-
/* jshint ignore:end */
147143
}
148144

149145
/**
@@ -161,8 +157,6 @@ export default function sassdoc(...args) {
161157
onEmpty(data, env);
162158
});
163159

164-
/* jshint ignore:start */
165-
166160
/**
167161
* Returned Promise await the full sequence,
168162
* instead of just the parsing step.
@@ -190,8 +184,6 @@ export default function sassdoc(...args) {
190184

191185
});
192186

193-
/* jshint ignore:end */
194-
195187
return filter;
196188
}
197189
}
@@ -203,8 +195,7 @@ export default function sassdoc(...args) {
203195
* @return {Promise | Stream}
204196
* @see srcEnv
205197
*/
206-
export function parse(...args) { // jshint ignore:line
207-
/* jshint ignore:start */
198+
export function parse(...args) {
208199

209200
return srcEnv(documentize, stream)(...args);
210201

@@ -217,30 +208,28 @@ export function parse(...args) { // jshint ignore:line
217208
return data;
218209
}
219210

220-
/* jshint ignore:end */
221-
222211
/**
223212
* Don't pass files through, but pass final data at the end.
224213
* @return {Stream}
225214
*/
226-
function stream(env) { // jshint ignore:line
227-
let parse = parseFilter(env);
215+
function stream(env) {
216+
let parseStream = parseFilter(env);
228217

229218
let filter = through.obj((file, enc, cb) => cb(), function (cb) {
230-
parse.promise.then(data => {
219+
parseStream.promise.then(data => {
231220
this.push(data);
232221
cb();
233222
}, cb);
234223
});
235224

236-
return pipe(parse, filter);
225+
return pipe(parseStream, filter);
237226
}
238227
}
239228

240229
/**
241230
* Source directory fetching and parsing.
242231
*/
243-
async function baseDocumentize(env) { // jshint ignore:line
232+
async function baseDocumentize(env) {
244233
let filter = parseFilter(env);
245234

246235
filter.promise
@@ -259,21 +248,18 @@ async function baseDocumentize(env) { // jshint ignore:line
259248
});
260249
});
261250

262-
let streams = [ // jshint ignore:line
251+
let streams = [
263252
vfs.src(env.src),
264253
recurse(),
265254
exclude(env.exclude || []),
266255
converter({ from: 'sass', to: 'scss' }),
267256
filter
268257
];
269258

270-
/* jshint ignore:start */
271-
272259
let pipeline = () => {
273260
return new Promise((resolve, reject) => {
274-
pipe(...streams, err => {
275-
err ? reject(err) : resolve();
276-
})
261+
pipe(...streams, err =>
262+
err ? reject(err) : resolve())
277263
.resume(); // Drain.
278264
});
279265
};
@@ -286,8 +272,6 @@ async function baseDocumentize(env) { // jshint ignore:line
286272
}
287273

288274
return env.data;
289-
290-
/* jshint ignore:end */
291275
}
292276

293277
/**
@@ -367,15 +351,15 @@ function onEmpty(data, env) {
367351
* Init timer.
368352
* @param {Object} env
369353
*/
370-
function init(env) { // jshint ignore:line
354+
function init(env) {
371355
env.logger.time('SassDoc');
372356
}
373357

374358
/**
375359
* Log final success message.
376360
* @param {Object} env
377361
*/
378-
function okay(env) { // jshint ignore:line
362+
function okay(env) {
379363
env.logger.log('Process over. Everything okay!');
380364
env.logger.timeEnd('SassDoc', '%s completed after %dms');
381365
}

test/annotations/content.test.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,9 @@ describe('#content', function () {
1111
assert.deepEqual(content.parse('\nTest\n\nTest\t'), 'Test\n\nTest');
1212
});
1313

14-
it('should add @content to all items that contain it in item.context.code', function(){
14+
it('should add @content to all items that contain it in item.context.code', function () {
1515

16-
assert.deepEqual(
17-
content.autofill({
18-
context : {
19-
code : '@content'
20-
}
21-
}),
22-
''
23-
);
16+
assert.deepEqual(content.autofill({ context: { code: '@content' }}), '');
2417

2518
});
2619
});

0 commit comments

Comments
 (0)