Permalink
Browse files

Updated docs, changelog.

  • Loading branch information...
arthurakay committed Dec 14, 2012
1 parent bf439a3 commit dd53fcddfbbd2d3fa2a228a5b95f41be8be6ca68
Showing with 188 additions and 0 deletions.
  1. +8 −0 CHANGELOG
  2. +1 −0 docs/output/LintRoller.util.js
  3. +174 −0 docs/source/util.html
  4. +5 −0 npm_update.sh
View
@@ -2,6 +2,14 @@
VERSION 2.x
===============
+Version 2.1.0 (December 14, 2012) - BREAKING CHANGES
+ - Moved code into /src/ folder
+ - Added "util" namespace and utilities
+ - Moved examples into /examples/ folder
+ - Updated documentation
+ - General refactoring
+
+
Version 2.0.0 (December 11, 2012) - BREAKING CHANGES ALL AROUND!
- Changed name from "PhantomLint" to "LintRoller"
- added JSHint support

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -0,0 +1,174 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>The source code</title>
+ <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+ <style type="text/css">
+ .highlight { display: block; background-color: #ddd; }
+ </style>
+ <script type="text/javascript">
+ function highlight() {
+ document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
+ }
+ </script>
+</head>
+<body onload="prettyPrint(); highlight();">
+ <pre class="prettyprint lang-js"><span id='LintRoller-util'>/**
+</span> * @class LintRoller.util
+ * @singleton
+ *
+ * Some additional utilities for cleaning up JavaScript lint.
+ */
+util = {
+
+<span id='LintRoller-util-method-init'> /**
+</span> * @private
+ */
+ init : function (parent) {
+ this.parent = parent;
+ return this;
+ },
+
+
+<span id='LintRoller-util-method-replaceTabsWithSpaces'> /**
+</span> * A utility that will eliminate all &quot;Mixed spaces with tabs.&quot; warnings by replacing tab characters with spaces.
+ *
+ * @param {Object} config A configuration object
+ * @param {Number} spacingChars The number of spaces to replace a tab
+ */
+ replaceTabsWithSpaces : function (config, spacingChars) {
+ this.parent.initConfigs(config);
+ this.parent.parseTree(config.filepaths);
+
+ this.parent.log('\nFilesystem has been parsed. Looping through available files...', true);
+
+ var msg = 'Mixed spaces and tabs.';
+ var offendingFiles = this.locateOffenders(msg);
+
+ //HOW MANY ERRORS?!?
+ this.parent.log(
+ 'Found ' + offendingFiles.length +
+ ' files matching the error &quot;' + msg +
+ '&quot; between ' + this.parent.linters.length + ' linters.',
+ true
+ );
+
+ try {
+ this.fixOffendingFiles(offendingFiles, spacingChars);
+ }
+ catch (e) {
+ this.parent.log(
+ 'An error has occurred: ' + e,
+ true
+ );
+
+ process.exit(1);
+ }
+
+ this.parent.log(
+ 'LintRoller has attempted to replace all tabs with ' + spacingChars + ' spaces.',
+ true
+ );
+
+ process.exit(0);
+ },
+
+
+<span id='LintRoller-util-method-locateOffenders'> /**
+</span> * @private
+ */
+ locateOffenders : function (msg) {
+ var offendingFiles = [],
+ linter, newFiles, i;
+
+ //find offending files
+ for (i = 0; i &lt; this.parent.linters.length; i++) {
+ linter = this.parent.linters[i];
+
+ newFiles = this.findLintErrors(linter, this.getLintOptions(linter), msg);
+ offendingFiles = offendingFiles.concat(newFiles);
+ }
+
+ return offendingFiles;
+ },
+
+
+<span id='LintRoller-util-method-fixOffendingFiles'> /**
+</span> * @private
+ */
+ fixOffendingFiles : function(offendingFiles, spacingChars) {
+ var i = 0,
+ spaces = '',
+ file, js;
+
+ for (i; i&lt;spacingChars; i++) {
+ spaces += ' ';
+ }
+
+ for (i=0; i &lt; offendingFiles.length; i++) {
+ file = offendingFiles[i];
+ js = this.parent.fs.readFileSync(file, 'utf8');
+
+ js = js.replace(/\t/g, spaces);
+
+ this.parent.fs.writeFileSync(file, js, 'utf8');
+ }
+ },
+
+
+<span id='LintRoller-util-method-getLintOptions'> /**
+</span> * @private
+ */
+ getLintOptions : function (linter) {
+ if (linter === this.parent.jsLint.lib) {
+ return this.parent.jsLint.options;
+ }
+
+ if (linter === this.parent.jsHint.lib) {
+ return this.parent.jsHint.options;
+ }
+
+ return {};
+ },
+
+
+<span id='LintRoller-util-method-findLintErrors'> /**
+</span> * @private
+ */
+ findLintErrors : function (linter, options, msg) {
+ var j = 0,
+ offendingFiles = [],
+ file, js;
+
+ for (j; j &lt; this.parent.files.length; j++) {
+
+ file = this.parent.files[j];
+ js = this.parent.fs.readFileSync(file, 'utf8');
+
+ var i = 0,
+ result = linter(js, options),
+ totalErrors = linter.errors.length,
+ error;
+
+ if (!result) {
+ for (i; i &lt; totalErrors; i++) {
+ error = linter.errors[i];
+
+ if (error &amp;&amp; error.reason === msg) {
+ offendingFiles.push(file);
+ break;
+ }
+ }
+ }
+ }
+
+ return offendingFiles;
+ }
+
+};
+
+module.exports = util;</pre>
+</body>
+</html>
View
@@ -0,0 +1,5 @@
+clear
+
+echo 'Updating NMP...'
+
+npm publish

0 comments on commit dd53fcd

Please sign in to comment.