From db7e65deb18f4203a99be75cf7ad61140799a695 Mon Sep 17 00:00:00 2001 From: Jeff Williams Date: Sat, 19 Apr 2014 10:44:07 -0700 Subject: [PATCH] enable ESLint `quotes` rule (and associated cleanup) --- .eslintrc | 2 +- lib/jsdoc/augment.js | 12 ++++++------ lib/jsdoc/config.js | 20 ++++++++++---------- lib/jsdoc/doclet.js | 2 +- lib/jsdoc/name.js | 4 ++-- lib/jsdoc/package.js | 2 +- lib/jsdoc/util/markdown.js | 6 +++--- plugins/markdown.js | 4 ++-- plugins/railsTemplate.js | 2 +- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/.eslintrc b/.eslintrc index 9443d7f8..780c060a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -113,7 +113,7 @@ "no-underscore-dangle": 0, "no-wrap-func": 2, "one-var": 0, - "quotes": 0, // TODO: enable with "single", "avoid-escape" + "quotes": [2, "single", "avoid-escape"], "quote-props": 0, "semi": [2, "always"], "sort-vars": 0, // TODO: enable diff --git a/lib/jsdoc/augment.js b/lib/jsdoc/augment.js index 7d2c43e9..7a3778ff 100644 --- a/lib/jsdoc/augment.js +++ b/lib/jsdoc/augment.js @@ -9,7 +9,7 @@ function mapDependencies(index) { doclets = index[name]; for (var i = 0, ii = doclets.length; i < ii; ++i) { doc = doclets[i]; - if (doc.kind === "class" || doc.kind === "external") { + if (doc.kind === 'class' || doc.kind === 'external') { dependencies[name] = {}; len = doc.augments && doc.augments.length || 0; for (var j = 0; j < len; ++j) { @@ -63,7 +63,7 @@ function getMembers(longname, docs) { var candidate, members = []; for (var i = 0, ii = docs.length; i < ii; ++i) { candidate = docs[i]; - if (candidate.memberof === longname && candidate.scope === "instance") { + if (candidate.memberof === longname && candidate.scope === 'instance') { members.push(candidate); } } @@ -71,7 +71,7 @@ function getMembers(longname, docs) { } function getAdditions(doclets, docs, longnames) { - var doop = require("jsdoc/util/doop").doop; + var doop = require('jsdoc/util/doop'); var additions = []; var doc; @@ -86,7 +86,7 @@ function getAdditions(doclets, docs, longnames) { for (var i = 0, ii = doclets.length; i < ii; i++) { doc = doclets[i]; parents = doc.augments; - if (parents && doc.kind === "class") { + if (parents && doc.kind === 'class') { for (var j = 0, jj = parents.length; j < jj; j++) { members = getMembers(parents[j], docs); for (var k = 0, kk = members.length; k < kk; k++) { @@ -99,9 +99,9 @@ function getAdditions(doclets, docs, longnames) { member.inherited = true; member.memberof = doc.longname; - parts = member.longname.split("#"); + parts = member.longname.split('#'); parts[0] = doc.longname; - member.longname = parts.join("#"); + member.longname = parts.join('#'); // if the child doesn't override the parent member, add the parent member if (longnames.indexOf(member.longname) === -1) { diff --git a/lib/jsdoc/config.js b/lib/jsdoc/config.js index 91454595..6e95bfdd 100644 --- a/lib/jsdoc/config.js +++ b/lib/jsdoc/config.js @@ -25,18 +25,18 @@ function mergeRecurse(target, source) { // required config values, override these defaults in your config.json if necessary var defaults = { - "tags": { - "allowUnknownTags": true + tags: { + allowUnknownTags: true }, - "templates": { - "monospaceLinks": false, - "cleverLinks": false + templates: { + monospaceLinks: false, + cleverLinks: false }, - "source": { - "includePattern": ".+\\.js(doc)?$", - "excludePattern": "" + source: { + includePattern: '.+\\.js(doc)?$', + excludePattern: '' }, - "plugins": [] + plugins: [] }; /** @@ -45,7 +45,7 @@ var defaults = { @param {string} [json] - The contents of config.json. */ function Config(json) { - json = JSON.parse( (json || "{}") ); + json = JSON.parse( (json || '{}') ); this._config = mergeRecurse(defaults, json); } diff --git a/lib/jsdoc/doclet.js b/lib/jsdoc/doclet.js index bf91e35c..c68386ae 100644 --- a/lib/jsdoc/doclet.js +++ b/lib/jsdoc/doclet.js @@ -79,7 +79,7 @@ function unwrap(docletSrc) { // use the /m flag on regex to avoid having to guess what this platform's newline is docletSrc = docletSrc.replace(/^\/\*\*+/, '') // remove opening slash+stars - .replace(/\**\*\/$/, "\\Z") // replace closing star slash with end-marker + .replace(/\**\*\/$/, '\\Z') // replace closing star slash with end-marker .replace(/^\s*(\* ?|\\Z)/gm, '') // remove left margin like: spaces+star or spaces+end-marker .replace(/\s*\\Z$/g, ''); // remove end-marker diff --git a/lib/jsdoc/name.js b/lib/jsdoc/name.js index f76d697d..8a01aab6 100644 --- a/lib/jsdoc/name.js +++ b/lib/jsdoc/name.js @@ -165,8 +165,8 @@ function quoteUnsafe(name, kind) { // docspaced names may have unsafe characters // TODO: make this a private method, or remove it if possible RegExp.escape = RegExp.escape || function(str) { - var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"); // .*+?|()[]{}\ - return str.replace(specials, "\\$&"); + var specials = new RegExp('[.*+?|()\\[\\]{}\\\\]', 'g'); // .*+?|()[]{}\ + return str.replace(specials, '\\$&'); }; /** diff --git a/lib/jsdoc/package.js b/lib/jsdoc/package.js index ede64313..135c9abc 100644 --- a/lib/jsdoc/package.js +++ b/lib/jsdoc/package.js @@ -16,7 +16,7 @@ @param {string} json - The contents of package.json. */ exports.Package = function(json) { - json = json || "{}"; + json = json || '{}'; /** The source files associated with this package. @type {Array} diff --git a/lib/jsdoc/util/markdown.js b/lib/jsdoc/util/markdown.js index bebb3169..3c883da4 100644 --- a/lib/jsdoc/util/markdown.js +++ b/lib/jsdoc/util/markdown.js @@ -18,16 +18,16 @@ var parserNames = { * * @deprecated Replaced by "marked," as markdown-js does not support inline HTML. */ - evilstreak: "marked", + evilstreak: 'marked', /** * The "GitHub-flavored Markdown" parser. * @deprecated Replaced by "marked." */ - gfm: "marked", + gfm: 'marked', /** * The "[Marked](https://github.com/chjj/marked)" parser. */ - marked: "marked" + marked: 'marked' }; /** diff --git a/plugins/markdown.js b/plugins/markdown.js index 9d7db537..7c7df69d 100644 --- a/plugins/markdown.js +++ b/plugins/markdown.js @@ -8,7 +8,7 @@ 'use strict'; var conf = env.conf.markdown; -var defaultTags = [ "classdesc", "description", "params", "properties", "returns", "see"]; +var defaultTags = [ 'classdesc', 'description', 'params', 'properties', 'returns', 'see']; var hasOwnProp = Object.prototype.hasOwnProperty; var parse = require('jsdoc/util/markdown').getParser(); var tags = []; @@ -40,7 +40,7 @@ function process(doclet) { return; } - if (typeof doclet[tag] === "string" && shouldProcessString(tag, doclet[tag]) ) { + if (typeof doclet[tag] === 'string' && shouldProcessString(tag, doclet[tag]) ) { doclet[tag] = parse(doclet[tag]); } else if ( Array.isArray(doclet[tag]) ) { diff --git a/plugins/railsTemplate.js b/plugins/railsTemplate.js index 2328efcd..6a408f68 100644 --- a/plugins/railsTemplate.js +++ b/plugins/railsTemplate.js @@ -14,7 +14,7 @@ exports.handlers = { */ beforeParse: function(e) { if (e.filename.match(/\.erb$/)) { - e.source = e.source.replace(/<%.*%>/g, ""); + e.source = e.source.replace(/<%.*%>/g, ''); } } }; \ No newline at end of file