This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

curved out from textlint

  • Loading branch information...
azu committed Jan 12, 2015
0 parents commit c37f46074fafaa255af5ed1933103e55c499468e
@@ -0,0 +1,82 @@
+### https://raw.github.com/github/gitignore/408c616ae0ad8f4b8101d8e876b9b67ac6b14059/Node.gitignore
+
+# Logs
+logs
+*.log
+
+# Runtime data
+pids
+*.pid
+*.seed
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+
+# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (http://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directory
+# Commenting this out is preferred by some people, see
+# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
+node_modules
+
+
+### https://raw.github.com/github/gitignore/408c616ae0ad8f4b8101d8e876b9b67ac6b14059/Global/JetBrains.gitignore
+
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
+
+*.iml
+
+## Directory-based project format:
+.idea/
+# if you remove the above rule, at least ignore the following:
+
+# User-specific stuff:
+# .idea/workspace.xml
+# .idea/tasks.xml
+# .idea/dictionaries
+
+# Sensitive or high-churn files:
+# .idea/dataSources.ids
+# .idea/dataSources.xml
+# .idea/sqlDataSources.xml
+# .idea/dynamic.xml
+# .idea/uiDesigner.xml
+
+# Gradle:
+# .idea/gradle.xml
+# .idea/libraries
+
+# Mongo Explorer plugin:
+# .idea/mongoSettings.xml
+
+## File-based project format:
+*.ipr
+*.iws
+
+## Plugin-specific files:
+
+# IntelliJ
+out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+
+
25 LICENSE
@@ -0,0 +1,25 @@
+Copyright (c) 2015 azu
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+Include:
+
+ ESLint
+ Copyright (c) 2013 Nicholas C. Zakas. All rights reserved.
+ https://github.com/eslint/eslint/blob/master/LICENSE
@@ -0,0 +1,54 @@
+# textlint-formatter
+
+[textlint](https://github.com/azu/textlint "azu/textlint") output formatter.
+
+## Installation
+
+```
+npm install textlint-formatter
+```
+
+## Usage
+
+See [formatters/](lib/formatters).
+
+Currently, you can use "stylish" (defaults), "compact", "checkstyle", "jslint-xml", "junit", "tap", "pretty-error".
+
+```js
+var createFormatter = require("textlint-formatter")
+var formatter = createFormatter({
+ formatterName: "stylish"
+});
+var output = formatter([
+ {
+ filePath: "./myfile.js",
+ messages: [
+ {
+ ruleId: "semi",
+ line: 1,
+ column: 23,
+ message: "Expected a semicolon."
+ }
+ ]
+ }
+]);
+console.log(output);
+/*
+./myfile.js
+ 1:23 warning Expected a semicolon semi
+
+✖ 1 problem
+*/
+```
+
+## Contributing
+
+1. Fork it!
+2. Create your feature branch: `git checkout -b my-new-feature`
+3. Commit your changes: `git commit -am 'Add some feature'`
+4. Push to the branch: `git push origin my-new-feature`
+5. Submit a pull request :D
+
+## License
+
+MIT
@@ -0,0 +1,7 @@
+declare module TextLintFormatter {
+ function format(results:TextLintResult[]):string;
+ interface options {
+ // formatter file name
+ formatterName?: string;
+ }
+}
@@ -0,0 +1,68 @@
+/**
+ * @fileoverview CheckStyle XML reporter
+ * @author Ian Christian Myers
+ */
+"use strict";
+
+//------------------------------------------------------------------------------
+// Helper Functions
+//------------------------------------------------------------------------------
+
+function getMessageType(message) {
+ if (message.fatal || message.severity === 2) {
+ return "error";
+ } else {
+ return "warning";
+ }
+}
+
+function xmlEscape(s) {
+ return ("" + s).replace(/[<>&"']/g, function(c) {
+ switch (c) {
+ case "<":
+ return "&lt;";
+ case ">":
+ return "&gt;";
+ case "&":
+ return "&amp;";
+ case "\"":
+ return "&quot;";
+ case "'":
+ return "&apos;";
+ // no default
+ }
+ });
+}
+
+//------------------------------------------------------------------------------
+// Public Interface
+//------------------------------------------------------------------------------
+
+module.exports = function(results) {
+
+ var output = "";
+
+ output += "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
+ output += "<checkstyle version=\"4.3\">";
+
+ results.forEach(function(result) {
+ var messages = result.messages;
+
+ output += "<file name=\"" + xmlEscape(result.filePath) + "\">";
+
+ messages.forEach(function(message) {
+ output += "<error line=\"" + xmlEscape(message.line) + "\" " +
+ "column=\"" + xmlEscape(message.column) + "\" " +
+ "severity=\"" + xmlEscape(getMessageType(message)) + "\" " +
+ "message=\"" + xmlEscape(message.message) +
+ (message.ruleId ? " (" + message.ruleId + ")" : "") + "\" />";
+ });
+
+ output += "</file>";
+
+ });
+
+ output += "</checkstyle>";
+
+ return output;
+};
@@ -0,0 +1,53 @@
+/**
+ * @fileoverview Compact reporter
+ * @author Nicholas C. Zakas
+ */
+"use strict";
+
+//------------------------------------------------------------------------------
+// Helper Functions
+//------------------------------------------------------------------------------
+
+function getMessageType(message) {
+ if (message.fatal || message.severity === 2) {
+ return "Error";
+ } else {
+ return "Warning";
+ }
+}
+
+
+//------------------------------------------------------------------------------
+// Public Interface
+//------------------------------------------------------------------------------
+
+module.exports = function(results) {
+
+ var output = "",
+ total = 0;
+
+ results.forEach(function(result) {
+
+ var messages = result.messages;
+ total += messages.length;
+
+ messages.forEach(function(message) {
+
+ output += result.filePath + ": ";
+ output += "line " + (message.line || 0);
+ output += ", col " + (message.column || 0);
+ output += ", " + getMessageType(message);
+ output += " - " + message.message;
+ output += message.ruleId ? " (" + message.ruleId + ")" : "";
+ output += "\n";
+
+ });
+
+ });
+
+ if (total > 0) {
+ output += "\n" + total + " problem" + (total !== 1 ? "s" : "");
+ }
+
+ return output;
+};
@@ -0,0 +1,40 @@
+/**
+ * @fileoverview JSLint XML reporter
+ * @author Ian Christian Myers
+ */
+"use strict";
+
+var xmlescape = require("xml-escape");
+
+//------------------------------------------------------------------------------
+// Public Interface
+//------------------------------------------------------------------------------
+
+module.exports = function(results) {
+
+ var output = "";
+
+ output += "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
+ output += "<jslint>";
+
+ results.forEach(function(result) {
+ var messages = result.messages;
+
+ output += "<file name=\"" + result.filePath + "\">";
+
+ messages.forEach(function(message) {
+ output += "<issue line=\"" + message.line + "\" " +
+ "char=\"" + message.column + "\" " +
+ "evidence=\"" + xmlescape(message.source || "") + "\" " +
+ "reason=\"" + xmlescape(message.message || "") +
+ (message.ruleId ? " (" + message.ruleId + ")" : "") + "\" />";
+ });
+
+ output += "</file>";
+
+ });
+
+ output += "</jslint>";
+
+ return output;
+};
Oops, something went wrong.

0 comments on commit c37f460

Please sign in to comment.