Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
[fixed] SASSLint to adjust to the fact that scss-lint no longer p…
Browse files Browse the repository at this point in the history
…rints errors to stderr, which also makes `SASS#lint` obsolete
  • Loading branch information
thealjey committed Jul 27, 2016
1 parent 70c3625 commit 0aca3bd
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 323 deletions.
172 changes: 1 addition & 171 deletions docs/SASS.html
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ <h5>Parameters:</h5>
<ul class="dummy">
<li>
<a href="SASS.js.html">SASS.js</a>,
<a href="SASS.js.html#sunlight-1-line-74">line 74</a>
<a href="SASS.js.html#sunlight-1-line-52">line 52</a>
</li>
</ul>
</dd>
Expand Down Expand Up @@ -788,176 +788,6 @@ <h5>Example</h5>



</dd>



<hr>
<dt>
<h4 class="name" id="lint"><span class="type-signature"></span>lint(paths, callback)</h4>


</dt>
<dd>


<div class="description">
<p>Performs linting</p>
</div>








<h5>Parameters:</h5>


<table class="params table table-striped">
<thead>
<tr>

<th>Name</th>


<th>Type</th>





<th class="last">Description</th>
</tr>
</thead>

<tbody>


<tr>

<td class="name"><code>paths</code></td>


<td class="type">


<span class="param-type">Array.&lt;string></span>




</td>





<td class="description last"><p>an array of paths to lint</p></td>
</tr>



<tr>

<td class="name"><code>callback</code></td>


<td class="type">


<span class="param-type">function</span>




</td>





<td class="description last"><p>a callback function</p></td>
</tr>


</tbody>
</table>




<dl class="details">





























<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="SASS.js.html">SASS.js</a>,
<a href="SASS.js.html#sunlight-1-line-52">line 52</a>
</li>
</ul>
</dd>







</dl>















<h5>Example</h5>

<pre class="sunlight-highlight-javascript">sass.lint([&#x27;/path/to/the/input/file.scss&#x27;, &#x27;/lint/this/directory/too&#x27;], () =&gt; {
// successfully linted
});</pre>



</dd>

</dl>
Expand Down
24 changes: 1 addition & 23 deletions docs/SASS.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,28 +140,6 @@ <h1 class="page-title">Source: SASS.js</h1>
this.linter = new SASSLint(...excludeLinter);
}

/**
* Performs linting
*
* @memberof SASS
* @instance
* @method lint
* @param {Array&lt;string>} paths - an array of paths to lint
* @param {Function} callback - a callback function
* @example
* sass.lint(['/path/to/the/input/file.scss', '/lint/this/directory/too'], () => {
* // successfully linted
* });
*/
lint(paths: Array&lt;string>, callback: () => void) {
this.linter.run(paths, linterErr => {
if (linterErr) {
return console.error(linterErr);
}
callback();
});
}

/**
* Wraps {@link SASSCompiler#fe} to add linting
*
Expand All @@ -179,7 +157,7 @@ <h1 class="page-title">Source: SASS.js</h1>
* });
*/
fe(inPath: string, outPath: string, lintPaths: Array&lt;string> = [], callback: () => void = noop) {
this.lint(lintPaths.concat([inPath]), () => {
this.linter.run(lintPaths.concat([inPath]), () => {
this.compiler.fe(inPath, outPath, callback);
});
}
Expand Down
6 changes: 3 additions & 3 deletions docs/SASSLint.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ <h5>Parameters:</h5>
<ul class="dummy">
<li>
<a href="SASSLint.js.html">SASSLint.js</a>,
<a href="SASSLint.js.html#sunlight-1-line-9">line 9</a>
<a href="SASSLint.js.html#sunlight-1-line-8">line 8</a>
</li>
</ul>
</dd>
Expand Down Expand Up @@ -367,7 +367,7 @@ <h5>Parameters:</h5>



<td class="description last"><p>a callback function, accepts 1 argument: an error message or null</p></td>
<td class="description last"><p>a callback function, executed only on success</p></td>
</tr>


Expand Down Expand Up @@ -412,7 +412,7 @@ <h5>Parameters:</h5>
<ul class="dummy">
<li>
<a href="SASSLint.js.html">SASSLint.js</a>,
<a href="SASSLint.js.html#sunlight-1-line-50">line 50</a>
<a href="SASSLint.js.html#sunlight-1-line-49">line 49</a>
</li>
</ul>
</dd>
Expand Down
11 changes: 7 additions & 4 deletions docs/SASSLint.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ <h1 class="page-title">Source: SASSLint.js</h1>
<pre
class="sunlight-highlight-javascript linenums">/* @flow */

import type {NativeProcessCallback} from './typedef';
import {NativeProcess} from './NativeProcess';
import {join} from 'path';

Expand Down Expand Up @@ -145,7 +144,7 @@ <h1 class="page-title">Source: SASSLint.js</h1>
* @instance
* @method run
* @param {Array&lt;string>} paths - an array of paths to files/directories to lint
* @param {Function} callback - a callback function, accepts 1 argument: an error message or null
* @param {Function} callback - a callback function, executed only on success
* @example
* // lint "style.scss" as well as the entire contents of the "sass" directory
* linter.run([join(__dirname, 'style.scss'), join(__dirname, 'sass')], error => {
Expand All @@ -155,13 +154,17 @@ <h1 class="page-title">Source: SASSLint.js</h1>
* // there were no linting errors
* });
*/
run(paths: Array&lt;string>, callback: NativeProcessCallback) {
run(paths: Array&lt;string>, callback: () => void) {
const args = paths.concat(['-c', config]);

if (this.excludeLinter) {
args.push('-x', this.excludeLinter);
}
this.proc.run(callback, args);
this.proc.run(stderr => {
if (null === stderr) {
callback();
}
}, args, {stdio: 'inherit'});
}

}
Expand Down
2 changes: 1 addition & 1 deletion docs/quicksearch.html

Large diffs are not rendered by default.

44 changes: 10 additions & 34 deletions lib/SASS.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,19 @@ var SASS = exports.SASS = function () {
}

/**
* Performs linting
* Wraps {@link SASSCompiler#fe} to add linting
*
* @memberof SASS
* @instance
* @method lint
* @param {Array<string>} paths - an array of paths to lint
* @param {Function} callback - a callback function
* @method fe
* @param {string} inPath - the input path
* @param {string} outPath - the output path
* @param {Array<string>} [lintPaths=[]] - an array of paths to files/directories to lint
* @param {Function} [callback=function () {}] - a callback function
* @return {void}
* @example
* sass.lint(['/path/to/the/input/file.scss', '/lint/this/directory/too'], () => {
* // successfully linted
* compiler.fe('/path/to/an/input/file.js', '/path/to/the/output/file.js', ['/lint/this/directory/too'], () => {
* // the code has passed all the checks and has been compiled successfully
* });
*/

Expand All @@ -82,40 +85,13 @@ var SASS = exports.SASS = function () {
*/


SASS.prototype.lint = function lint(paths, callback) {
this.linter.run(paths, function (linterErr) {
if (linterErr) {
return console.error(linterErr);
}
callback();
});
};

/**
* Wraps {@link SASSCompiler#fe} to add linting
*
* @memberof SASS
* @instance
* @method fe
* @param {string} inPath - the input path
* @param {string} outPath - the output path
* @param {Array<string>} [lintPaths=[]] - an array of paths to files/directories to lint
* @param {Function} [callback=function () {}] - a callback function
* @return {void}
* @example
* compiler.fe('/path/to/an/input/file.js', '/path/to/the/output/file.js', ['/lint/this/directory/too'], () => {
* // the code has passed all the checks and has been compiled successfully
* });
*/


SASS.prototype.fe = function fe(inPath, outPath) {
var _this = this;

var lintPaths = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2];
var callback = arguments.length <= 3 || arguments[3] === undefined ? _noop2.default : arguments[3];

this.lint(lintPaths.concat([inPath]), function () {
this.linter.run(lintPaths.concat([inPath]), function () {
_this.compiler.fe(inPath, outPath, callback);
});
};
Expand Down
9 changes: 6 additions & 3 deletions lib/SASSLint.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ var config = (0, _path.join)(__dirname, '..', 'config', 'scsslint.yml');
* const linter = new SASSLint();
*/


var SASSLint = exports.SASSLint = function () {

/** @constructs */
Expand Down Expand Up @@ -61,7 +60,7 @@ var SASSLint = exports.SASSLint = function () {
* @instance
* @method run
* @param {Array<string>} paths - an array of paths to files/directories to lint
* @param {Function} callback - a callback function, accepts 1 argument: an error message or null
* @param {Function} callback - a callback function, executed only on success
* @example
* // lint "style.scss" as well as the entire contents of the "sass" directory
* linter.run([join(__dirname, 'style.scss'), join(__dirname, 'sass')], error => {
Expand Down Expand Up @@ -89,7 +88,11 @@ var SASSLint = exports.SASSLint = function () {
if (this.excludeLinter) {
args.push('-x', this.excludeLinter);
}
this.proc.run(callback, args);
this.proc.run(function (stderr) {
if (null === stderr) {
callback();
}
}, args, { stdio: 'inherit' });
};

return SASSLint;
Expand Down
Loading

0 comments on commit 0aca3bd

Please sign in to comment.