Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 259498 Details for
Bug 482619
[eslint] Consume the quotes rule
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Work in progress
482619.patch (text/plain), 45.14 KB, created by
Olivier Thomann
on 2016-02-02 14:29:17 EST
(
hide
)
Description:
Work in progress
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2016-02-02 14:29:17 EST
Size:
45.14 KB
patch
obsolete
>diff --git a/bundles/org.eclipse.orion.client.core/web/orion/metatype.js b/bundles/org.eclipse.orion.client.core/web/orion/metatype.js >index 380ce4f..62469e5 100644 >--- a/bundles/org.eclipse.orion.client.core/web/orion/metatype.js >+++ b/bundles/org.eclipse.orion.client.core/web/orion/metatype.js >@@ -138,6 +138,7 @@ > } > }); > } >+ this.dependsOn = attrJson.dependsOn || null; > }; > AttributeDefinitionImpl.prototype = { > getId: function() { >@@ -161,6 +162,9 @@ > }, > getDefaultValue: function() { > return this.defaultValue; >+ }, >+ getDependsOn: function() { >+ return this.dependsOn; > } > }; > >diff --git a/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/load-rules-async.js b/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/load-rules-async.js >index a51d147..8b6c72e 100644 >--- a/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/load-rules-async.js >+++ b/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/load-rules-async.js >@@ -35,9 +35,10 @@ > './rules/no-obj-calls', > './rules/no-self-compare', > './rules/no-irregular-whitespace', >+'./rules/quotes', > ], function(util, Logger, Finder, ProblemMessages, Estraverse, JsSyntax, > accessorPairs, noControlRegex, noDuplicateCase, noElseReturn, noEmptyCharClasses, >- noEmptyLabel, noEqNull, noExtraBoolCast, noExtraParens, noInvalidRegExp, noNegatedInLhs, noObjCalls, noSelfCompare, noIrregularWhitespace) { >+ noEmptyLabel, noEqNull, noExtraBoolCast, noExtraParens, noInvalidRegExp, noNegatedInLhs, noObjCalls, noSelfCompare, noIrregularWhitespace, quotes) { > > var rules = { > "curly": function(context) { >@@ -1758,7 +1759,8 @@ > } > } > }; >- } >+ }, >+ 'quotes': quotes, > }; > > function _mapCallees(arr, obj) { >@@ -1772,67 +1774,67 @@ > 'removeEventListener'], _callees); //$NON-NLS-1$ > > function _collectLinesWithStringLiterals(node, lineMap){ >- >- // Create a map of line numbers to a list of literal nodes >- if (typeof node.value === 'string' && node.value.length > 0){ >- if (node.value.toLowerCase() === 'use strict'){ >- return; >- } >- if(/^(?:[\.,-\/#!$%\^&\*;:{}=\-_`~()@\+\?><\[\]\+])$/.test(node.value)) { >- return; //don't nag about punctuation >- } else if(/^(?:==|!=|===|!==|=>)$/.test(node.value)) { >- return; //don't nag about operators >- } >- if (node.parent){ >- switch(node.parent.type) { >- case 'UnaryExpression': >- case 'MemberExpression': >- case 'SwitchCase': { >- return; >- } >- case 'BinaryExpression': { >- if(node.parent.operator !== '+') { >- return; >- } >- break; >- } >- case 'Property': { >- if(node.parent.key === node) { >- return; >- } >- var _p = node.parent.parent.parent; >- if(_p && _p.type === 'CallExpression' && _p.callee && _p.callee.name === 'define') { >- return; >- } >- break; >- } >- case 'NewExpression': >- case 'CallExpression': { >- var callee = node.parent.callee; >- if(callee) { >- if(callee.type === 'MemberExpression' && callee.property && _callees[callee.property.name]) { >- return; >- } else if(_callees[callee.name]) { >- return; >- } >- } >- break; >- } >- case 'ArrayExpression': { >- _p = node.parent.parent; >- if(_p.type === 'CallExpression' && (_p.callee.name === 'define' || _p.callee.name === 'require' || _p.callee.name === 'requirejs')) { >- return; >- } >- break; >- } >- } >- } >- var lineNum = node.loc.end.line; >- if (!lineMap[lineNum]){ >- lineMap[lineNum] = []; >- } >- lineMap[lineNum].push(node); >- } >+ >+ // Create a map of line numbers to a list of literal nodes >+ if (typeof node.value === 'string' && node.value.length > 0){ >+ if (node.value.toLowerCase() === 'use strict'){ >+ return; >+ } >+ if(/^(?:[\.,-\/#!$%\^&\*;:{}=\-_`~()@\+\?><\[\]\+])$/.test(node.value)) { >+ return; //don't nag about punctuation >+ } else if(/^(?:==|!=|===|!==|=>)$/.test(node.value)) { >+ return; //don't nag about operators >+ } >+ if (node.parent){ >+ switch(node.parent.type) { >+ case 'UnaryExpression': >+ case 'MemberExpression': >+ case 'SwitchCase': { >+ return; >+ } >+ case 'BinaryExpression': { >+ if(node.parent.operator !== '+') { >+ return; >+ } >+ break; >+ } >+ case 'Property': { >+ if(node.parent.key === node) { >+ return; >+ } >+ var _p = node.parent.parent.parent; >+ if(_p && _p.type === 'CallExpression' && _p.callee && _p.callee.name === 'define') { >+ return; >+ } >+ break; >+ } >+ case 'NewExpression': >+ case 'CallExpression': { >+ var callee = node.parent.callee; >+ if(callee) { >+ if(callee.type === 'MemberExpression' && callee.property && _callees[callee.property.name]) { >+ return; >+ } else if(_callees[callee.name]) { >+ return; >+ } >+ } >+ break; >+ } >+ case 'ArrayExpression': { >+ _p = node.parent.parent; >+ if(_p.type === 'CallExpression' && (_p.callee.name === 'define' || _p.callee.name === 'require' || _p.callee.name === 'requirejs')) { >+ return; >+ } >+ break; >+ } >+ } >+ } >+ var lineNum = node.loc.end.line; >+ if (!lineMap[lineNum]){ >+ lineMap[lineNum] = []; >+ } >+ lineMap[lineNum].push(node); >+ } > } > > return { >diff --git a/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/rules/quotes.js b/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/rules/quotes.js >new file mode 100644 >index 0000000..33ee9f0 >--- /dev/null >+++ b/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/rules/quotes.js >@@ -0,0 +1,198 @@ >+/*eslint-env amd */ >+define([ >+ '../util', >+ 'module' >+], function (utils, module) {/** >+ * @fileoverview A rule to choose between single and double quote marks >+ * @author Matt DuVall <http://www.mattduvall.com/>, Brandon Payton >+ * @copyright 2013 Matt DuVall. All rights reserved. >+ * See LICENSE file in root directory for full license. >+ */ >+ >+"use strict"; >+ >+//------------------------------------------------------------------------------ >+// Constants >+//------------------------------------------------------------------------------ >+ >+var QUOTE_SETTINGS = { >+ "double": { >+ quote: "\"", >+ alternateQuote: "'", >+ description: "doublequote", >+ convert: function(str) { >+ return str.replace(/(?:\\*)?'([^'\\]*\\.)*[^']*'/g, function (match) { >+ return match >+ // unescape single-quotes >+ .replace(/\\'/g, '\'') >+ // escape escapes >+ .replace(/(^|[^\\])(\\+)"/g, '$1$2\\\"') >+ // escape double-quotes >+ .replace(/([^\\])"/g, '$1\\\"') >+ // convert >+ .replace(/^'|'$/g, '"'); >+ }); >+ } >+ }, >+ "single": { >+ quote: "'", >+ alternateQuote: "\"", >+ description: "singlequote", >+ convert: function(str) { >+ return str.replace(/(?:\\*)?"([^"\\]*\\.)*[^"]*"/g, function (match) { >+ return match >+ // unescape double-quotes >+ .replace(/\\"/g, '"') >+ // escape escapes >+ .replace(/(^|[^\\])(\\+)'/g, '$1$2\\\'') >+ // escape single-quotes - round 1 >+ .replace(/([^\\])'/g, '$1\\\'') >+ // escape single-quotes - round 2 (for consecutive single-quotes) >+ .replace(/([^\\])'/g, '$1\\\'') >+ // convert >+ .replace(/^"|"$/g, '\''); >+ }); >+ } >+ }, >+ "backtick": { >+ quote: "`", >+ alternateQuote: "\"", >+ description: "backtick", >+ convert: function(str) { >+ return str.replace(/`/g, "\`").replace(/^(?:\\*)["']|(?:\\*)["']$/g, "`"); >+ } >+ } >+}; >+ >+var AVOID_ESCAPE = "avoid-escape", >+ FUNCTION_TYPE = /^(?:Arrow)?Function(?:Declaration|Expression)$/; >+ >+//------------------------------------------------------------------------------ >+// Rule Definition >+//------------------------------------------------------------------------------ >+ >+module.exports = function(context) { >+ /** >+ * Determines if a given node is part of JSX syntax. >+ * @param {ASTNode} node The node to check. >+ * @returns {boolean} True if the node is a JSX node, false if not. >+ * @private >+ */ >+ function isJSXElement(node) { >+ return node.type.indexOf("JSX") === 0; >+ } >+ >+ /** >+ * Checks whether or not a given node is a directive. >+ * The directive is a `ExpressionStatement` which has only a string literal. >+ * @param {ASTNode} node - A node to check. >+ * @returns {boolean} Whether or not the node is a directive. >+ * @private >+ */ >+ function isDirective(node) { >+ return node.type === "ExpressionStatement" && >+ node.expression.type === "Literal" && >+ typeof node.expression.value === "string"; >+ } >+ >+ /** >+ * Checks whether or not a given node is a part of directive prologues. >+ * See also: http://www.ecma-international.org/ecma-262/6.0/#sec-directive-prologues-and-the-use-strict-directive >+ * @param {ASTNode} node - A node to check. >+ * @returns {boolean} Whether or not the node is a part of directive prologues. >+ * @private >+ */ >+ function isPartOfDirectivePrologue(node) { >+ var block = node.parent.parent; >+ if (block.type !== "Program" && (block.type !== "BlockStatement" || !FUNCTION_TYPE.test(block.parent.type))) { >+ return false; >+ } >+ >+ // Check the node is at a prologue. >+ for (var i = 0; i < block.body.length; ++i) { >+ var statement = block.body[i]; >+ >+ if (statement === node.parent) { >+ return true; >+ } >+ if (!isDirective(statement)) { >+ break; >+ } >+ } >+ >+ return false; >+ } >+ >+ /** >+ * Checks whether or not a given node is allowed as non backtick. >+ * @param {ASTNode} node - A node to check. >+ * @returns {boolean} Whether or not the node is allowed as non backtick. >+ * @private >+ */ >+ function isAllowedAsNonBacktick(node) { >+ var parent = node.parent; >+ >+ switch (parent.type) { >+ // Directive Prologues. >+ case "ExpressionStatement": >+ return isPartOfDirectivePrologue(node); >+ >+ // LiteralPropertyName. >+ case "Property": >+ return parent.key === node && !parent.computed; >+ >+ // ModuleSpecifier. >+ case "ImportDeclaration": >+ case "ExportNamedDeclaration": >+ case "ExportAllDeclaration": >+ return parent.source === node; >+ >+ // Others don't allow. >+ default: >+ return false; >+ } >+ } >+ >+ return { >+ >+ "Literal": function(node) { >+ var val = node.value, >+ rawVal = node.raw, >+ quoteOption = context.options[0], >+ settings = QUOTE_SETTINGS[quoteOption || "double"], >+ avoidEscape = context.options[1] === AVOID_ESCAPE, >+ isValid; >+ >+ if (settings && typeof val === "string") { >+ isValid = (quoteOption === "backtick" && isAllowedAsNonBacktick(node)) || isJSXElement(node.parent) || utils.isSurroundedBy(rawVal, settings.quote); >+ >+ if (!isValid && avoidEscape) { >+ isValid = utils.isSurroundedBy(rawVal, settings.alternateQuote) && rawVal.indexOf(settings.quote) >= 0; >+ } >+ >+ if (!isValid) { >+ context.report({ >+ node: node, >+ message: "Strings must use " + settings.description + ".", >+ fix: function(fixer) { >+ return fixer.replaceText(node, settings.convert(node.raw)); >+ } >+ }); >+ } >+ } >+ } >+ }; >+ >+}; >+ >+module.exports.schema = [ >+ { >+ "enum": ["single", "double", "backtick"] >+ }, >+ { >+ "enum": ["avoid-escape"] >+ } >+]; >+ >+return module.exports; >+}); >diff --git a/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/util.js b/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/util.js >index 0e4443a..c6a00c6 100644 >--- a/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/util.js >+++ b/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/util.js >@@ -134,5 +134,16 @@ > return false; > }; > >+/** >+ * Validate that a string passed in is surrounded by the specified character >+ * @param {string} val The text to check. >+ * @param {string} character The character to see if it's surrounded by. >+ * @returns {boolean} True if the text is surrounded by the character, false if not. >+ * @private >+ */ >+exports.isSurroundedBy = function(val, character) { >+ return val[0] === character && val[val.length - 1] === character; >+}; >+ > return exports; > }); >diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/nls/root/messages.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/nls/root/messages.js >index ccd4d2d..67f9b6c 100644 >--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/nls/root/messages.js >+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/nls/root/messages.js >@@ -192,5 +192,13 @@ > 'no-irregular-whitespace' : 'Disallow irregular whitespace:', > 'no-self-assign' : 'Disallow self assignment:', > 'noShadowFixName' : 'Rename in scope', >- 'type-checked-consistent-return' : 'Discouraged inconsistent returns:' >+ 'type-checked-consistent-return' : 'Discouraged inconsistent returns:', >+ 'quote-style' : 'Enforce quote style:', >+ 'quote-value' : 'Quoting options:', >+ 'quote-noescape' : 'Ignore strings that require escaping existing quotes', >+ 'double' : 'double', >+ 'single' : 'single', >+ 'backtick' : 'backtick', >+ '_false' : 'false', >+ '_true' : 'true' > }); >diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/nls/root/problems.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/nls/root/problems.js >index eb82765..467f440 100644 >--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/nls/root/problems.js >+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/nls/root/problems.js >@@ -125,6 +125,7 @@ > 'no-self-assign' : 'Assigning to itself is pointless.', > 'type-checked-consistent-return-description' : 'Detect inconsistent return values', > 'inconsistent-return' : 'Inconsistent return types: \'{{type1}}\', \'{{type2}}\'', >+ 'quotes-description' : 'Ensure consistency for the quote style', > > //.tern-project file validation messages > 'notNum': "'${0}' must be a number", >diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js >index c1503de..88a011a 100644 >--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js >+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js >@@ -212,10 +212,9 @@ > response.args.path = rel[0].path; > ternWorker.postMessage(response); > }); >- } else { >- response.args.error = i18nUtil.formatMessage(javascriptMessages['failedToReadFile'], _l); >- ternWorker.postMessage(response); > } >+ response.args.error = i18nUtil.formatMessage(javascriptMessages['failedToReadFile'], _l); >+ ternWorker.postMessage(response); > } else { > response.args.error = i18nUtil.formatMessage(javascriptMessages['failedToReadFile'], _l); > ternWorker.postMessage(response); >@@ -1464,8 +1463,38 @@ > type: "number", //$NON-NLS-1$ > defaultValue: warning, > options: severities >- } >-] >+ }, >+ { >+ id: "quotes", //$NON-NLS-1$ >+ name: javascriptMessages["quote-style"], >+ type: "number", //$NON-NLS-1$ >+ defaultValue: ignore, >+ options: severities >+ }, >+ { >+ id: "quote-value", //$NON-NLS-1$ >+ name: javascriptMessages["quote-value"], >+ type: "string", //$NON-NLS-1$ >+ defaultValue: "single", >+ options: [ >+ {label: javascriptMessages.double, value: "double"}, >+ {label: javascriptMessages.single, value: "single"}, >+ {label: javascriptMessages.backtick, value: "backtick"} >+ ], >+ dependsOn: "quotes" >+ }, >+ { >+ id: "quote-noescape", //$NON-NLS-1$ >+ name: javascriptMessages["quote-noescape"], >+ type: "boolean", //$NON-NLS-1$ >+ defaultValue: false, >+ options: [ >+ {label: javascriptMessages._false, value: false}, >+ {label: javascriptMessages._true, value: true} >+ ], >+ dependsOn: "quotes" >+ }, >+ ] > }] > }); > >diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/ruleData.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/ruleData.js >index ee556ba..aba1a60 100644 >--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/ruleData.js >+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/ruleData.js >@@ -71,6 +71,7 @@ > "no-unused-vars" : 1, > "no-use-before-define" : 1, > "no-with" : 1, >+ "quotes": [1, "double", "avoid-escape"], > "radix" : 1, > "semi" : 1, > "type-checked-consistent-return" : 0, >@@ -86,43 +87,43 @@ > }, > "curly" : { > description: Messages['curly-description'], >- url: 'http://eslint.org/docs/rules/curly' >+ url: 'http://eslint.org/docs/rules/curly' > }, > "eqeqeq": { > description: Messages['eqeqeq-description'], >- url: "http://eslint.org/docs/rules/eqeqeq" >+ url: "http://eslint.org/docs/rules/eqeqeq" > }, > > "missing-doc" : { > description: Messages['missing-doc-description'], >- url: 'http://eslint.org/docs/rules/valid-jsdoc' >+ url: 'http://eslint.org/docs/rules/valid-jsdoc' > }, > "missing-nls" : { > description: Messages['missing-nls-description'] > }, > "new-parens" : { > description: Messages['new-parens-description'], >- url: 'http://eslint.org/docs/rules/new-parens' >+ url: 'http://eslint.org/docs/rules/new-parens' > }, > "no-caller": { > description: Messages['no-caller-description'], >- url: 'http://eslint.org/docs/rules/no-caller' >- }, >+ url: 'http://eslint.org/docs/rules/no-caller' >+ }, > "no-comma-dangle" : { > description: Messages['no-comma-dangle-description'], >- url: 'http://eslint.org/docs/rules/no-comma-dangle' >- }, >+ url: 'http://eslint.org/docs/rules/no-comma-dangle' >+ }, > "no-cond-assign" : { > description: Messages['no-cond-assign-description'], >- url: 'http://eslint.org/docs/rules/no-cond-assign' >- }, >+ url: 'http://eslint.org/docs/rules/no-cond-assign' >+ }, > "no-console" : { > description: Messages['no-console-description'], >- url: 'http://eslint.org/docs/rules/no-console' >- }, >+ url: 'http://eslint.org/docs/rules/no-console' >+ }, > "no-constant-condition" : { > description: Messages['no-constant-condition-description'], >- url: 'http://eslint.org/docs/rules/no-constant-condition' >+ url: 'http://eslint.org/docs/rules/no-constant-condition' > }, > "no-control-regex" : { > description: Messages['no-control-regex-description'], >@@ -130,11 +131,11 @@ > }, > "no-debugger" : { > description: Messages['no-debugger-description'], >- url: 'http://eslint.org/docs/rules/no-debugger' >+ url: 'http://eslint.org/docs/rules/no-debugger' > }, > "no-dupe-keys" : { > description: Messages['no-dupe-keys-description'], >- url: 'http://eslint.org/docs/rules/no-dupe-keys' >+ url: 'http://eslint.org/docs/rules/no-dupe-keys' > }, > "no-duplicate-case": { > description: Messages['no-duplicate-case-description'], >@@ -146,7 +147,7 @@ > }, > "no-empty-block" : { > description: Messages['no-empty-block-description'], >- url: 'http://eslint.org/docs/rules/no-empty' >+ url: 'http://eslint.org/docs/rules/no-empty' > }, > "no-empty-character-class" : { > description: Messages['no-empty-character-class-description'], >@@ -162,7 +163,7 @@ > }, > "no-eval" : { > description: Messages['no-eval-description'], >- url: 'http://eslint.org/docs/rules/no-eval' >+ url: 'http://eslint.org/docs/rules/no-eval' > }, > "no-extra-boolean-cast" : { > description: Messages['no-extra-boolean-cast-description'], >@@ -174,15 +175,15 @@ > }, > "no-extra-semi": { > description: Messages['no-extra-semi-description'], >- url: 'http://eslint.org/docs/rules/no-extra-semi' >+ url: 'http://eslint.org/docs/rules/no-extra-semi' > }, > "no-fallthrough" : { > description: Messages['no-fallthrough-description'], >- url: 'http://eslint.org/docs/rules/no-fallthrough' >- }, >+ url: 'http://eslint.org/docs/rules/no-fallthrough' >+ }, > "no-implied-eval" : { > description: Messages['no-implied-eval-description'], >- url: 'http://eslint.org/docs/rules/no-implied-eval' >+ url: 'http://eslint.org/docs/rules/no-implied-eval' > }, > "no-invalid-regexp": { > description: Messages['no-invalid-regexp-description'], >@@ -194,11 +195,11 @@ > }, > "no-iterator": { > description: Messages['no-iterator-description'], >- url: 'http://eslint.org/docs/rules/no-iterator' >- }, >+ url: 'http://eslint.org/docs/rules/no-iterator' >+ }, > "no-jslint" : { > description: Messages['no-jslint-description'] >- }, >+ }, > "no-mixed-spaces-and-tabs" : { > description: Messages['no-mixed-spaces-and-tabs-description'], > url: 'http://eslint.org/docs/rules/no-mixed-spaces-and-tabs' >@@ -213,15 +214,15 @@ > }, > "no-new-func" : { > description: Messages['no-new-func-description'], >- url: 'http://eslint.org/docs/rules/no-new-func' >+ url: 'http://eslint.org/docs/rules/no-new-func' > }, > "no-new-object" : { > description: Messages['no-new-object-description'], >- url: 'http://eslint.org/docs/rules/no-new-object' >+ url: 'http://eslint.org/docs/rules/no-new-object' > }, > "no-new-wrappers" : { > description: Messages['no-new-wrappers-description'], >- url: 'http://eslint.org/docs/rules/no-new-wrappers' >+ url: 'http://eslint.org/docs/rules/no-new-wrappers' > }, > "no-obj-calls" : { > description: Messages['no-obj-calls-description'], >@@ -229,19 +230,19 @@ > }, > "no-proto" : { > description: Messages['no-proto-description'], >- url: 'http://eslint.org/docs/rules/no-proto.html' >+ url: 'http://eslint.org/docs/rules/no-proto.html' > }, > "no-redeclare" : { > description: Messages['no-redeclare-description'], >- url: 'http://eslint.org/docs/rules/no-redeclare' >+ url: 'http://eslint.org/docs/rules/no-redeclare' > }, > "no-regex-spaces" : { > description: Messages['no-regex-spaces-description'], >- url: 'http://eslint.org/docs/rules/no-regex-spaces' >+ url: 'http://eslint.org/docs/rules/no-regex-spaces' > }, > "no-reserved-keys" : { > description: Messages['no-reserved-keys-description'], >- url: 'http://eslint.org/docs/rules/no-reserved-keys' >+ url: 'http://eslint.org/docs/rules/no-reserved-keys' > }, > "no-self-compare" : { > description: Messages['no-self-compare-description'], >@@ -253,67 +254,71 @@ > }, > "no-shadow" : { > description: Messages['no-shadow-description'], >- url: 'http://eslint.org/docs/rules/no-shadow' >+ url: 'http://eslint.org/docs/rules/no-shadow' > }, > "no-shadow-global" : { > description: Messages['no-shadow-global-description'] > }, > "no-sparse-arrays" : { > description: Messages['no-sparse-arrays-description'], >- url: 'http://eslint.org/docs/rules/no-sparse-arrays' >- }, >+ url: 'http://eslint.org/docs/rules/no-sparse-arrays' >+ }, > "no-throw-literal" : { > description: Messages['no-throw-literal-description'], >- url: 'http://eslint.org/docs/rules/no-throw-literal' >+ url: 'http://eslint.org/docs/rules/no-throw-literal' > }, > "no-undef" : { > description: Messages['no-undef-description'], >- url: 'http://eslint.org/docs/rules/no-undef' >+ url: 'http://eslint.org/docs/rules/no-undef' > }, > "no-undef-init" : { > description: Messages['no-undef-init-description'], >- url: 'http://eslint.org/docs/rules/no-undef-init.html' >+ url: 'http://eslint.org/docs/rules/no-undef-init.html' > }, > "no-unreachable" : { > description: Messages['no-unreachable-description'], >- url: 'http://eslint.org/docs/rules/no-unreachable' >- }, >+ url: 'http://eslint.org/docs/rules/no-unreachable' >+ }, > "no-unused-params" : { > description: Messages['no-unused-params-description'] > }, > "no-unused-vars" : { > description: Messages['no-unused-vars-description'], >- url: 'http://eslint.org/docs/rules/no-unused-vars' >+ url: 'http://eslint.org/docs/rules/no-unused-vars' > }, > "no-use-before-define" : { > description: Messages['no-use-before-define-description'], >- url: 'http://eslint.org/docs/rules/no-use-before-define' >+ url: 'http://eslint.org/docs/rules/no-use-before-define' > }, > "no-with" : { > description: Messages['no-with-description'], >- url: 'http://eslint.org/docs/rules/no-with' >+ url: 'http://eslint.org/docs/rules/no-with' > }, > "radix" : { > description: Messages['radix-description'], >- url: 'http://eslint.org/docs/rules/radix' >+ url: 'http://eslint.org/docs/rules/radix' > }, > "semi" : { > description: Messages['semi-description'], >- url: 'http://eslint.org/docs/rules/semi' >+ url: 'http://eslint.org/docs/rules/semi' > }, > "unnecessary-nls" : { > description: Messages['unnecessary-nls-description'] > }, > "use-isnan" : { > description: Messages['use-isnan-description'], >- url: 'http://eslint.org/docs/rules/use-isnan' >+ url: 'http://eslint.org/docs/rules/use-isnan' > }, > "valid-typeof" : { > description: Messages['valid-typeof-description'], >- url: 'http://eslint.org/docs/rules/valid-typeof' >+ url: 'http://eslint.org/docs/rules/valid-typeof' > }, > "type-checked-consistent-return" : { > description: Messages['type-checked-consistent-return-description'] >+ }, >+ "quotes" : { >+ description: Messages['quotes-description'], >+ url: 'http://eslint.org/docs/rules/quotes' > } > } > }; >diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/validator.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/validator.js >index 497deb9..c134647 100644 >--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/validator.js >+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/validator.js >@@ -43,7 +43,23 @@ > else { > this.rules[ruleId] = value; > } >+ } else if (Array.isArray(value)) { >+ this.rules[ruleId] = value; > } >+ }, >+ >+ getOption: function(ruleId, key) { >+ if(Array.isArray(this.rules[ruleId])) { >+ var ruleConfig = this.rules[ruleId]; >+ if (key) { >+ if (ruleConfig[1]) { >+ return ruleConfig[1][key] || null; >+ } >+ return null; >+ } >+ return ruleConfig[0] || null; >+ } >+ return this.rules[ruleId]; > }, > > setDefaults: function setDefaults() { >@@ -261,26 +277,62 @@ > if (!properties) { > return; > } >- var oldconfig = properties.pid === 'eslint.config'; >- var keys = Object.keys(properties); > var seen = Object.create(null); >- for(var i = 0; i < keys.length; i++) { >- var key = keys[i]; >- var ruleId = key; >- if(oldconfig && config.rules[key] !== config.defaults[key]) { >- //don't overwrite a new setting with an old one >- continue; >- } >- var legacy = this._legacy[ruleId]; >- if(typeof legacy === 'string') { >- ruleId = legacy; >- if(seen[ruleId]) { >- //don't overwrite a new pref name with a legacy one >+ var keys = Object.keys(properties); >+ var key, ruleId, legacy, index, len; >+ if (properties.pid === 'eslint.config.codestyle') { >+ // handle dependent options for quotes >+ for(index = 0, len = keys.length; index < len; index++) { >+ key = keys[index]; >+ ruleId = key; >+ if (key === 'quotes') { >+ // create the options array for quotes settings >+ if (properties[key] !== 0) { >+ var options = [properties[key]]; >+ options.push(properties['quote-value']); >+ if (properties['quote-noescape']) { >+ options.push("noescape"); >+ } >+ config.setOption(ruleId, options); >+ } else { >+ config.setOption(ruleId, 0); >+ } >+ } else if (key === 'quote-value' || key === 'quote-noescape') { >+ // these keys are handled by 'quotes' as dependents >+ continue; >+ } else { >+ legacy = this._legacy[ruleId]; >+ if(typeof legacy === 'string') { >+ ruleId = legacy; >+ if(seen[ruleId]) { >+ //don't overwrite a new pref name with a legacy one >+ continue; >+ } >+ } >+ seen[ruleId] = true; >+ config.setOption(ruleId, properties[key]); >+ } >+ } >+ } else { >+ var oldconfig = properties.pid === 'eslint.config'; >+ for(index = 0, len = keys.length; index < len; index++) { >+ key = keys[index]; >+ ruleId = key; >+ if(oldconfig && config.rules[key] !== config.defaults[key]) { >+ //don't overwrite a new setting with an old one > continue; >- } >- } >- seen[ruleId] = true; >- config.setOption(ruleId, properties[key]); >+ } >+ legacy = this._legacy[ruleId]; >+ if(typeof legacy === 'string') { >+ ruleId = legacy; >+ if(seen[ruleId]) { >+ //don't overwrite a new pref name with a legacy one >+ continue; >+ } >+ } >+ seen[ruleId] = true; >+ config.setOption(ruleId, properties[key]); >+ } > } > }, > >diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/settings/settingsRegistry.js b/bundles/org.eclipse.orion.client.ui/web/orion/settings/settingsRegistry.js >index 797a89e..6c199e1 100644 >--- a/bundles/org.eclipse.orion.client.ui/web/orion/settings/settingsRegistry.js >+++ b/bundles/org.eclipse.orion.client.ui/web/orion/settings/settingsRegistry.js >@@ -17,7 +17,7 @@ > var SETTINGS_PROP = 'settings'; //$NON-NLS-0$ > var DEFAULT_CATEGORY = 'unsorted'; //$NON-NLS-0$ > >- var hasOwnProperty = Object.prototype.hasOwnProperty; >+ var _hasOwnProperty = Object.prototype.hasOwnProperty; > > /** > * @param {String} type >@@ -27,8 +27,7 @@ > function equals(type, value, defaultValue) { > if (type === 'string') //$NON-NLS-0$ > return value === defaultValue || (value === '' && defaultValue === null); >- else >- return value === defaultValue; >+ return value === defaultValue; > } > > function getStringOrNull(obj, property) { >@@ -40,55 +39,55 @@ > * @class Represents the definition of a setting. > * @description Represents the definition of a setting. > */ >- /** >- * @name orion.settings.Setting#isDefaults >- * @function >- * @param {Object} properties A map of AttributeDefinition IDs to values. >- * @param {Object} [defaultProperties] If provided, gives a map of effective default values to compare properties >- * against. If not provided, the default values defined in the <tt>AttributeDefinition</tt>s are used. >- * @description Returns whether a given properties map is equivalent to the default value of this setting. >- * Default values are drawn either from <tt>defaultProperties</tt> if provided, otherwise from the <tt>AttributeDefinition</tt>. >- * </ul> >- * @returns {Boolean} <code>true</code> if the given <code>properties</code> map equals the defaults. >- */ >- /** >- * @name orion.settings.Setting#getCategory >- * @function >- * @description Returns the category. >- * @returns {String} The category. May be <code>null</code>. >- */ >- /** >- * @name orion.settings.Setting#getCategoryLabel >- * @function >- * @description Returns the category label. >- * @returns {String} The category label. May be <code>null</code>. >- */ >- /** >- * @name orion.settings.Setting#getPid >- * @function >- * @returns {String} >- */ >- /** >- * @name orion.settings.Setting#getObjectClassDefinitionId >- * @function >- * @returns {String} >- */ >- /** >- * @name orion.settings.Setting#getName >- * @function >- * @description Returns the name. >- * @returns {String} The name. May be <code>null</code>. >- */ >- /** >- * @name orion.settings.Setting#getAttributeDefinitions >- * @function >- * @returns {orion.metatype.AttributeDefinition[]} >- */ >- /** >- * @name orion.settings.Setting#getTags >- * @function >- * @returns {String[]} >- */ >+ /** >+ * @name orion.settings.Setting#isDefaults >+ * @function >+ * @param {Object} properties A map of AttributeDefinition IDs to values. >+ * @param {Object} [defaultProperties] If provided, gives a map of effective default values to compare properties >+ * against. If not provided, the default values defined in the <tt>AttributeDefinition</tt>s are used. >+ * @description Returns whether a given properties map is equivalent to the default value of this setting. >+ * Default values are drawn either from <tt>defaultProperties</tt> if provided, otherwise from the <tt>AttributeDefinition</tt>. >+ * </ul> >+ * @returns {Boolean} <code>true</code> if the given <code>properties</code> map equals the defaults. >+ */ >+ /** >+ * @name orion.settings.Setting#getCategory >+ * @function >+ * @description Returns the category. >+ * @returns {String} The category. May be <code>null</code>. >+ */ >+ /** >+ * @name orion.settings.Setting#getCategoryLabel >+ * @function >+ * @description Returns the category label. >+ * @returns {String} The category label. May be <code>null</code>. >+ */ >+ /** >+ * @name orion.settings.Setting#getPid >+ * @function >+ * @returns {String} >+ */ >+ /** >+ * @name orion.settings.Setting#getObjectClassDefinitionId >+ * @function >+ * @returns {String} >+ */ >+ /** >+ * @name orion.settings.Setting#getName >+ * @function >+ * @description Returns the name. >+ * @returns {String} The name. May be <code>null</code>. >+ */ >+ /** >+ * @name orion.settings.Setting#getAttributeDefinitions >+ * @function >+ * @returns {orion.metatype.AttributeDefinition[]} >+ */ >+ /** >+ * @name orion.settings.Setting#getTags >+ * @function >+ * @returns {String[]} >+ */ > function SettingImpl(json) { > this.pid = json.pid; > this.isRef = getStringOrNull(json, 'classId'); //$NON-NLS-0$ >@@ -98,7 +97,7 @@ > this.category = json.category || null; > this.categoryLabel = json.categoryLabel || null; > this.tags = json.tags; >- this.order = typeof(json.order) === 'number' && json.order > -1 ? json.order : 0; >+ this.order = typeof json.order === 'number' && json.order > -1 ? json.order : 0; > if (!this.pid) { throw new Error('Missing "pid" property'); } //$NON-NLS-0$ > } > SettingImpl.prototype = { >@@ -124,7 +123,7 @@ > return this.tags || []; > }, > /** >- * Allow settings to declare thier relative ordering on the generated page >+ * Allow settings to declare their relative ordering on the generated page > * @since 9.0 > */ > getOrder: function getOrder() { >@@ -134,10 +133,10 @@ > defaultProperties = defaultProperties || {}; > return this.getAttributeDefinitions().every(function(attributeDefinition) { > var attributeId = attributeDefinition.getId(); >- if (!(hasOwnProperty.call(properties, attributeId))) >+ if (!_hasOwnProperty.call(properties, attributeId)) > return true; // Attribute not set, so consider as equal to default > var value = properties[attributeId], defaultValue; >- if (hasOwnProperty.call(defaultProperties, attributeId)) >+ if (_hasOwnProperty.call(defaultProperties, attributeId)) > defaultValue = defaultProperties[attributeId]; > else > defaultValue = attributeDefinition.getDefaultValue(); >@@ -174,7 +173,7 @@ > setting.properties = ocd.getAttributeDefinitions(); > settingsMap[setting.getPid()] = setting; > var category = setting.getCategory() || DEFAULT_CATEGORY; >- if (!hasOwnProperty.call(categoriesMap, category)) { >+ if (!_hasOwnProperty.call(categoriesMap, category)) { > categoriesMap[category] = []; > } > categoriesMap[category].push(setting.getPid()); >@@ -203,6 +202,9 @@ > } > return ServiceTracker.prototype.addingService.call(this, serviceRef); > }; >+ /** >+ * @callback >+ */ > this.removedService = function(serviceRef, service) { > var settings = serviceRef.getProperty(SETTINGS_PROP); > for (var i=0; i < settings.length; i++) { >@@ -232,7 +234,7 @@ > */ > getSettings: function(category) { > var settingsMap = this.settingsMap; >- var pids = (typeof category === 'string') ? this.categories[category] : Object.keys(settingsMap); //$NON-NLS-0$ >+ var pids = typeof category === 'string' ? this.categories[category] : Object.keys(settingsMap); //$NON-NLS-0$ > if (!pids) { > return []; > } >diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js b/bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js >index 64100c5..652b785 100644 >--- a/bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js >+++ b/bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js >@@ -20,17 +20,14 @@ > 'orion/widgets/input/SettingsSelect', > 'i18n!orion/settings/nls/messages', > 'orion/i18nUtil', >- 'orion/metrics', > 'orion/commands' > ], function(mExplorer, mSection, Deferred, objects, mConfirmDialog, SettingsCheckbox, SettingsTextfield, >- SettingsSelect, messages, i18nUtil, mMetrics, Commands) { >+ SettingsSelect, messages, i18nUtil, Commands) { > var Explorer = mExplorer.Explorer, > SelectionRenderer = mExplorer.SelectionRenderer, > Section = mSection.Section, > Command = Commands.Command, > ConfirmDialog = mConfirmDialog.ConfirmDialog; >- >- var METRICS_MAXLENGTH = 256; > > /** > * @name orion.settings.ui.PropertyWidget >@@ -73,6 +70,7 @@ > > /** > * Widget displaying a string-typed plugin setting. Mixes in SettingsTextfield and PropertyWidget. >+ * @callback > */ > var PropertyTextField = function(options) { > PropertyWidget.apply(this, arguments); >@@ -89,7 +87,10 @@ > this.textfield.type = 'text'; //$NON-NLS-0$ > } > }, >- change: function(event) { >+ /** >+ * @callback >+ */ >+ change: function(_event) { > this.changeProperty(this.textfield.value); > }, > updateField: function(value) { >@@ -99,14 +100,15 @@ > > /** > * Widget displaying a boolean-typed plugin setting. Mixes in SettingsCheckbox and PropertyWidget. >+ * @callback > */ > var PropertyCheckbox = function(options) { > PropertyWidget.apply(this, arguments); > SettingsCheckbox.apply(this, arguments); > }; > objects.mixin(PropertyCheckbox.prototype, SettingsCheckbox.prototype, PropertyWidget.prototype, { >- change: function(event) { >- this.changeProperty(event.target.checked); //$NON-NLS-0$ >+ change: function(_event) { >+ this.changeProperty(_event.target.checked); //$NON-NLS-0$ > }, > postCreate: function() { > PropertyWidget.prototype.postCreate.call(this); >@@ -119,6 +121,7 @@ > > /** > * Widget displaying a plugin setting whose value is restricted to an enumerated set (options). Mixes in SettingsSelect and PropertyWidget. >+ * @callback > */ > var PropertySelect = function(options) { > PropertyWidget.apply(this, arguments); >@@ -129,13 +132,16 @@ > var values = this.property.getOptionValues(); > var labels = this.property.getOptionLabels(); // TODO nls > this.options = values.map(function(value, i) { >- var label = (typeof labels[i] === 'string' ? labels[i] : value); //$NON-NLS-0$ >+ var label = typeof labels[i] === 'string' ? labels[i] : value; //$NON-NLS-0$ > return {value: label, label: label}; > }); > SettingsSelect.prototype.postCreate.apply(this, arguments); > PropertyWidget.prototype.postCreate.apply(this, arguments); > }, >- change: function(event) { >+ /** >+ * @callback >+ */ >+ change: function(_event) { > SettingsSelect.prototype.change.apply(this, arguments); > var selectedOptionValue = this.property.getOptionValues()[this.getSelectedIndex()]; > if (typeof selectedOptionValue !== 'undefined') { //$NON-NLS-0$ >@@ -166,10 +172,10 @@ > }; > objects.mixin(PropertiesWidget.prototype, { //$NON-NLS-0$ > createElements: function() { >- var self = this; >+ var _self = this; > this.children = []; > this.initConfiguration().then(function(configuration) { >- self.createChildren(configuration); >+ _self.createChildren(configuration); > }); > }, > startup: function() { >@@ -188,13 +194,13 @@ > childWidget.show(); > }, > createChildren: function(configuration) { >- var self = this; >+ var _self = this; > this.setting.getAttributeDefinitions().forEach(function(property) { > var options = { > config: configuration, > property: property, >- changeProperty: self.changeProperty.bind(self, property) , >- serviceRegistry: self.serviceRegistry >+ changeProperty: _self.changeProperty.bind(_self, property) , >+ serviceRegistry: _self.serviceRegistry > }; > var widget; > if (property.getOptionValues()) { >@@ -211,7 +217,7 @@ > break; > } > } >- self.addChild(widget); >+ _self.addChild(widget); > }); > }, > initConfiguration: function() { >@@ -239,15 +245,15 @@ > initConfiguration: function() { > var configuration = this.config; > if (!configuration) { >- var pid = this.pid, self = this; >+ var pid = this.pid, _self = this; > this.configPromise = this.configPromise || > Deferred.all([ > this.configAdmin.getDefaultConfiguration(pid), > this.configAdmin.getConfiguration(pid) > ]).then(function(result) { >- self.defaultConfig = result[0]; >- self.config = result[1]; >- return self.config; >+ _self.defaultConfig = result[0]; >+ _self.config = result[1]; >+ return _self.config; > }); > return this.configPromise; > } >@@ -331,8 +337,11 @@ > rowElement.appendChild(settingSection); > // mNavUtils.addNavGrid(this.explorer.getNavDict(), setting, link); > }; >- SettingsRenderer.prototype.createPropertiesWidget = function(parent, setting, serviceRegistry) { >- return new PropertiesWidget({serviceRegistry: this.serviceRegistry, setting: setting, categoryTitle: this.explorer.categoryTitle}, parent); >+ /** >+ * @callback >+ */ >+ SettingsRenderer.prototype.createPropertiesWidget = function(_parent, setting, serviceRegistry) { >+ return new PropertiesWidget({serviceRegistry: this.serviceRegistry, setting: setting, categoryTitle: this.explorer.categoryTitle}, _parent); > }; > /** @callback */ > SettingsRenderer.prototype.renderTableHeader = function(tableNode) { >@@ -387,8 +396,8 @@ > }); > dialog.show(); > var _self = this; >- dialog.addEventListener("dismiss", function(event) { //$NON-NLS-0$ >- if (event.value) { >+ dialog.addEventListener("dismiss", function(_event) { //$NON-NLS-0$ >+ if (_event.value) { > if(data.items) { > _self.restore(data.items.pid); > } else { >@@ -404,8 +413,11 @@ > this.render(this.parent, this.serviceRegistry, this.settings, this.title); > } > SettingsList.prototype = { >- _makeSection: function(parent, sectionId, setting, title, hasMultipleSections) { >- var section = new Section(parent, { id: sectionId, title: title, useAuxStyle: true, >+ /** >+ * @callback >+ */ >+ _makeSection: function(_parent, sectionId, setting, title, hasMultipleSections) { >+ var section = new Section(_parent, { id: sectionId, title: title, useAuxStyle: true, > canHide: hasMultipleSections, onExpandCollapse: true}); > return section; > }, >@@ -434,14 +446,14 @@ > }.bind(this)); > } > }, >- render: function(parent, serviceRegistry, settings, categoryTitle) { >+ render: function(_parent, serviceRegistry, settings, categoryTitle) { > // FIXME Section forces a singleton id, bad > var idPrefix = 'pluginsettings-'; //$NON-NLS-0$ > > for (var i=0; i<settings.length; i++) { > var sectionId = idPrefix + 'section' + i; //$NON-NLS-0$ > var setting = settings[i]; >- var section = this._makeSection(parent, sectionId, setting, setting.getName() || "Unnamed", settings.length > 1); //$NON-NLS-0$ >+ var section = this._makeSection(_parent, sectionId, setting, setting.getName() || "Unnamed", settings.length > 1); //$NON-NLS-0$ > this.commandRegistry.renderCommands("restoreDefaults", section.getActionElement(), settings[i], this, "button"); //$NON-NLS-1$ //$NON-NLS-0$ > > // Add a class name based on the category (all settings on the page have the same category currently)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 482619
: 259498