Permalink
Browse files

Switch to ESLint

  • Loading branch information...
1 parent 44c3654 commit ceee400e4b0359317f9dcfc31ed9316da746ab51 @Hirse Hirse committed Jun 11, 2016
Showing with 210 additions and 50 deletions.
  1. +1 −0 .eslintignore
  2. +194 −0 .eslintrc.yml
  3. +0 −36 .jshintrc
  4. +2 −2 external/sass/beautify.js
  5. +2 −1 external/sass/domain.js
  6. +11 −11 main.js
View
@@ -0,0 +1 @@
+thirdparty/**/*.js
View
@@ -0,0 +1,194 @@
+---
+ env:
+ browser: true
+
+ globals:
+ $: false
+ brackets: false
+ define: false
+
+ rules:
+ # Possible Errors
+ comma-dangle: 2 # require or disallow trailing commas
+ no-cond-assign: 1 # disallow assignment operators in conditional expressions
+ no-console: 0 # disallow the use of console
+ no-constant-condition: 2 # disallow constant expressions in conditions
+ no-control-regex: 1 # disallow control characters in regular expressions
+ no-debugger: 2 # disallow the use of debugger
+ no-dupe-args: 2 # disallow duplicate arguments in function definitions
+ no-dupe-keys: 2 # disallow duplicate keys in object literals
+ no-duplicate-case: 2 # disallow duplicate case labels
+ no-empty: 1 # disallow empty block statements
+ no-empty-character-class: 1 # disallow empty character classes in regular expressions
+ no-ex-assign: 1 # disallow reassigning exceptions in catch clauses
+ no-extra-boolean-cast: 1 # disallow unnecessary boolean casts
+ no-extra-parens: 1 # disallow unnecessary parentheses
+ no-extra-semi: 1 # disallow unnecessary semicolons
+ no-func-assign: 2 # disallow reassigning function declarations
+ no-inner-declarations: 1 # disallow function or var declarations in nested blocks
+ no-invalid-regexp: 2 # disallow invalid regular expression strings in RegExp constructors
+ no-irregular-whitespace: 1 # disallow irregular whitespace outside of strings and comments
+ no-negated-in-lhs: 1 # disallow negating the left operand in in expressions
+ no-obj-calls: 1 # disallow calling global object properties as functions
+ no-prototype-builtins: 1 # Disallow use of Object.prototypes builtins directly
+ no-regex-spaces: 1 # disallow multiple spaces in regular expression literals
+ no-sparse-arrays: 1 # disallow sparse arrays
+ no-unexpected-multiline: 1 # disallow confusing multiline expressions
+ no-unreachable: 2 # disallow unreachable code after return, throw, continue, and break statements
+ no-unsafe-finally: 1 # disallow control flow statements in finally blocks
+ use-isnan: 2 # require calls to isNaN() when checking for NaN
+ valid-jsdoc: 1 # enforce valid JSDoc comments
+ valid-typeof: 2 # enforce comparing typeof expressions against valid strings
+ # Best Practices
+ accessor-pairs: 1 # enforce getter and setter pairs in objects
+ array-callback-return: 1 # enforce return statements in callbacks of array methods
+ block-scoped-var: 1 # enforce the use of variables within the scope they are defined
+ complexity: 0 # enforce a maximum cyclomatic complexity allowed in a program
+ consistent-return: 1 # require return statements to either always or never specify values
+ curly: 1 # enforce consistent brace style for all control statements
+ default-case: 1 # require default cases in switch statements
+ dot-location: 0 # enforce consistent newlines before and after dots
+ dot-notation: 1 # enforce dot notation whenever possible
+ eqeqeq: 1 # require the use of === and !==
+ guard-for-in: 0 # require for-in loops to include an if statement
+ no-alert: 1 # disallow the use of alert, confirm, and prompt
+ no-caller: 2 # disallow the use of arguments.caller or arguments.callee
+ no-case-declarations: 1 # disallow lexical declarations in case clauses
+ no-div-regex: 1 # disallow division operators explicitly at the beginning of regular expressions
+ no-else-return: 0 # disallow else blocks after return statements in if statements
+ no-empty-function: 1 # disallow empty functions
+ no-empty-pattern: 1 # disallow empty destructuring patterns
+ no-eq-null: 1 # disallow null comparisons without type-checking operators
+ no-eval: 2 # disallow the use of eval()
+ no-extend-native: 2 # disallow extending native types
+ no-extra-bind: 2 # disallow unnecessary calls to .bind()
+ no-extra-label: 2 # disallow unnecessary labels
+ no-fallthrough: 0 # disallow fallthrough of case statements
+ no-floating-decimal: 1 # disallow leading or trailing decimal points in numeric literals
+ no-implicit-coercion: 1 # disallow shorthand type conversions
+ no-implicit-globals: 2 # disallow var and named function declarations in the global scope
+ no-implied-eval: 2 # disallow the use of eval()-like methods
+ no-invalid-this: 0 # disallow this keywords outside of classes or class-like objects
+ no-iterator: 1 # disallow the use of the __iterator__ property
+ no-labels: 1 # disallow labeled statements
+ no-lone-blocks: 1 # disallow unnecessary nested blocks
+ no-loop-func: 1 # disallow function declarations and expressions inside loop statements
+ no-magic-numbers: 0 # disallow magic numbers
+ no-multi-spaces: 1 # disallow multiple spaces
+ no-multi-str: 1 # disallow multiline strings
+ no-native-reassign: 1 # disallow reassigning native objects
+ no-new: 1 # disallow new operators outside of assignments or comparisons
+ no-new-func: 2 # disallow new operators with the Function object
+ no-new-wrappers: 2 # disallow new operators with the String, Number, and Boolean objects
+ no-octal: 2 # disallow octal literals
+ no-octal-escape: 1 # disallow octal escape sequences in string literals
+ no-param-reassign: 0 # disallow reassigning function parameters
+ no-proto: 2 # disallow the use of the __proto__ property
+ no-redeclare: 2 # disallow var redeclaration
+ no-return-assign: 1 # disallow assignment operators in return statements
+ no-script-url: 2 # disallow javascript: urls
+ no-self-assign: 2 # disallow assignments where both sides are exactly the same
+ no-self-compare: 2 # disallow comparisons where both sides are exactly the same
+ no-sequences: 1 # disallow comma operators
+ no-throw-literal: 1 # disallow throwing literals as exceptions
+ no-unmodified-loop-condition: 1 # disallow unmodified loop conditions
+ no-unused-expressions: 1 # disallow unused expressions
+ no-unused-labels: 1 # disallow unused labels
+ no-useless-call: 2 # disallow unnecessary calls to .call() and .apply()
+ no-useless-concat: 2 # disallow unnecessary concatenation of literals or template literals
+ no-useless-escape: 1 # disallow unnecessary escape characters
+ no-void: 1 # disallow void operators
+ no-warning-comments: 0 # disallow specified warning terms in comments
+ no-with: 1 # disallow with statements
+ radix: 1 # enforce the consistent use of the radix argument when using parseInt()
+ vars-on-top: 0 # require var declarations be placed at the top of their containing scope
+ wrap-iife: 0 # require parentheses around immediate function invocations
+ yoda: 1 # require or disallow “Yoda” conditions
+ # Strict Mode
+ strict: 1 # require or disallow strict mode directives
+ # Variables
+ init-declarations: 0 # require or disallow initialization in var declarations
+ no-catch-shadow: 1 # disallow catch clause parameters from shadowing variables in the outer scope
+ no-delete-var: 2 # disallow deleting variables
+ no-label-var: 2 # disallow labels that share a name with a variable
+ no-restricted-globals: 0 # disallow specified global variables
+ no-shadow: 1 # disallow var declarations from shadowing variables in the outer scope
+ no-shadow-restricted-names: 2 # disallow identifiers from shadowing restricted names
+ no-undef: 2 # disallow the use of undeclared variables unless mentioned in /*global */ comments
+ no-undef-init: 2 # disallow initializing variables to undefined
+ no-undefined: 1 # disallow the use of undefined as an identifier
+ no-unused-vars: 1 # disallow unused variables
+ no-use-before-define: 1 # disallow the use of variables before they are defined
+ # Stylistic Issues
+ array-bracket-spacing: 1 # enforce consistent spacing inside array brackets
+ block-spacing: 1 # enforce consistent spacing inside single-line blocks
+ brace-style: 1 # enforce consistent brace style for blocks
+ camelcase: [1, {properties: never}] # enforce camelcase naming convention
+ comma-spacing: 1 # enforce consistent spacing before and after commas
+ comma-style: 1 # enforce consistent comma style
+ computed-property-spacing: 1 # enforce consistent spacing inside computed property brackets
+ consistent-this: 1 # enforce consistent naming when capturing the current execution context
+ eol-last: 1 # enforce at least one newline at the end of files
+ func-names: 0 # enforce named function expressions
+ func-style: 0 # enforce the consistent use of either function declarations or expressions
+ id-blacklist: 0 # disallow specified identifiers
+ id-length: 1 # enforce minimum and maximum identifier lengths
+ id-match: 0 # require identifiers to match a specified regular expression
+ indent: [2, 4, {SwitchCase: 1}] # enforce consistent indentation
+ jsx-quotes: 0 # enforce the consistent use of either double or single quotes in JSX attributes
+ key-spacing: 1 # enforce consistent spacing between keys and values in object literal properties
+ keyword-spacing: 1 # enforce consistent spacing before and after keywords
+ linebreak-style: 0 # enforce consistent linebreak style
+ lines-around-comment: 0 # require empty lines around comments
+ max-depth: 0 # enforce a maximum depth that blocks can be nested
+ max-len: 0 # enforce a maximum line length
+ max-lines: 0 # enforce a maximum file length
+ max-nested-callbacks: 0 # enforce a maximum depth that callbacks can be nested
+ max-params: 0 # enforce a maximum number of parameters in function definitions
+ max-statements: 0 # enforce a maximum number of statements allowed in function blocks
+ max-statements-per-line: 1 # enforce a maximum number of statements allowed per line
+ new-cap: 1 # require constructor function names to begin with a capital letter
+ new-parens: 1 # require parentheses when invoking a constructor with no arguments
+ newline-after-var: 0 # require or disallow an empty line after var declarations
+ newline-before-return: 0 # require an empty line before return statements
+ newline-per-chained-call: 0 # require a newline after each call in a method chain
+ no-array-constructor: 2 # disallow Array constructors
+ no-bitwise: 0 # disallow bitwise operators
+ no-continue: 1 # disallow continue statements
+ no-inline-comments: 0 # disallow inline comments after code
+ no-lonely-if: 1 # disallow if statements as the only statement in else blocks
+ no-mixed-operators: 0 # disallow mixes of different operators
+ no-mixed-spaces-and-tabs: 1 # disallow mixed spaces and tabs for indentation
+ no-multiple-empty-lines: 1 # disallow multiple empty lines
+ no-negated-condition: 1 # disallow negated conditions
+ no-nested-ternary: 1 # disallow nested ternary expressions
+ no-new-object: 1 # disallow Object constructors
+ no-plusplus: 0 # disallow the unary operators ++ and --
+ no-restricted-syntax: 0 # disallow specified syntax
+ no-spaced-func: 1 # disallow spacing between function identifiers and their applications
+ no-ternary: 0 # disallow ternary operators
+ no-trailing-spaces: 1 # disallow trailing whitespace at the end of lines
+ no-underscore-dangle: 0 # disallow dangling underscores in identifiers
+ no-unneeded-ternary: 1 # disallow ternary operators when simpler alternatives exist
+ no-whitespace-before-property: 0 # disallow whitespace before properties
+ object-curly-spacing: 1 # enforce consistent spacing inside braces
+ object-property-newline: 1 # enforce placing object properties on separate lines
+ one-var: 0 # enforce variables to be declared either together or separately in functions
+ one-var-declaration-per-line: 0 # require or disallow newlines around var declarations
+ operator-assignment: 0 # require or disallow assignment operator shorthand where possible
+ operator-linebreak: 0 # enforce consistent linebreak style for operators
+ padded-blocks: [1, never] # require or disallow padding within blocks
+ quote-props: 0 # require quotes around object literal property names
+ quotes: [1, single] # enforce the consistent use of either backticks, double, or single quotes
+ require-jsdoc: 0 # require JSDoc comments
+ semi: 1 # require or disallow semicolons instead of ASI
+ semi-spacing: 1 # enforce consistent spacing before and after semicolons
+ sort-vars: 0 # require variables within the same declaration block to be sorted
+ space-before-blocks: 1 # enforce consistent spacing before blocks
+ space-before-function-paren: [1, {anonymous: always, named: never}] # enforce consistent spacing before function definition opening parenthesis
+ space-in-parens: 1 # enforce consistent spacing inside parentheses
+ space-infix-ops: 1 # require spacing around operators
+ space-unary-ops: 1 # enforce consistent spacing before or after unary operators
+ spaced-comment: 1 # enforce consistent spacing after the // or /* in a comment
+ unicode-bom: 1 # require or disallow the Unicode BOM
+ wrap-regex: 0 # require parenthesis around regex literals
View
@@ -1,36 +0,0 @@
-{
- "bitwise": true,
- "camelcase": false,
- "curly": true,
- "eqeqeq": false,
- "es3": false,
- "forin": false,
- "freeze": true,
- "globalstrict": false,
- "immed": true,
- "indent": 4,
- "latedef": true,
- "maxlen": 200,
- "newcap": true,
- "noarg": true,
- "nocomma": false,
- "noempty": true,
- "nonbsp": true,
- "nonew": false,
- "notypeof": false,
- "quotmark": true,
- "singleGroups": false,
- "undef": true,
- "unused": true,
-
- "browser": true,
- "jquery": true,
-
- "globals": {
- "Mustache": false,
- "brackets": false,
- "console": false,
- "define": false,
- "require": false
- }
-}
@@ -4,12 +4,12 @@ define(function (require, exports, module) {
var PREFIX = 'bb.beautify';
var PATH_PREF = 'external.sass';
- /* beautify preserve:start */
+ /* beautify preserve:start *//* eslint-disable no-multi-spaces */
var DocumentManager = brackets.getModule('document/DocumentManager');
var PreferencesManager = brackets.getModule('preferences/PreferencesManager');
var ExtensionUtils = brackets.getModule('utils/ExtensionUtils');
var NodeDomain = brackets.getModule('utils/NodeDomain');
- /* beautify preserve:end */
+ /* eslint-enable no-multi-spaces *//* beautify preserve:end */
var Strings = require('strings');
@@ -1,4 +1,5 @@
-/* jshint node: true */
+/* eslint-env node */
+/* eslint-disable strict */
(function () {
'use strict';
View
@@ -22,7 +22,7 @@ define(function (require, exports, module) {
}
];
- /* beautify preserve:start */
+ /* beautify preserve:start *//* eslint-disable no-multi-spaces */
var CommandManager = brackets.getModule('command/CommandManager');
var Commands = brackets.getModule('command/Commands');
var Menus = brackets.getModule('command/Menus');
@@ -39,7 +39,7 @@ define(function (require, exports, module) {
var ExtensionUtils = brackets.getModule('utils/ExtensionUtils');
var DefaultDialogs = brackets.getModule('widgets/DefaultDialogs');
var Dialogs = brackets.getModule('widgets/Dialogs');
- /* beautify preserve:end */
+ /* eslint-enable no-multi-spaces *//* beautify preserve:end */
var Strings = require('strings');
var DialogContentTemplate = require('text!templates/dialog-content.html');
@@ -167,17 +167,17 @@ define(function (require, exports, module) {
}
}
}
- if (!externalBeautifier) {
- var formattedText = beautifiers[beautifier](unformattedText, currentOptions);
- if (formattedText !== unformattedText) {
- batchUpdate(formattedText, range);
- }
- } else {
+ if (externalBeautifier) {
beautifiers[beautifier](unformattedText, currentOptions, function (formattedText) {
if (formattedText !== unformattedText) {
batchUpdate(formattedText, range);
}
});
+ } else {
+ var formattedText = beautifiers[beautifier](unformattedText, currentOptions);
+ if (formattedText !== unformattedText) {
+ batchUpdate(formattedText, range);
+ }
}
}
@@ -210,15 +210,15 @@ define(function (require, exports, module) {
try {
options = $.extend(true, {}, defaultOptions, JSON.parse(content));
return;
- } catch (e) {
+ } catch (error) {
console.error('Brackets Beautify - Error parsing options (' + optionsFile.fullPath + '). Using default.');
}
}
options = defaultOptions;
});
}
- function loadOptionsOnChange(e, document) {
+ function loadOptionsOnChange(error, document) {
if (document.file.fullPath === ProjectManager.getProjectRoot().fullPath + OPTIONS_FILE_NAME) {
loadOptions(document.file);
}
@@ -261,7 +261,7 @@ define(function (require, exports, module) {
.attr('href', '#')
.attr('title', Strings.BEAUTIFY)
.on('click', format)
- .appendTo($('#main-toolbar .buttons'))
+ .appendTo($('#main-toolbar .buttons'));
AppInit.appReady(function () {
DocumentManager.on('documentSaved.beautify', onSave);

0 comments on commit ceee400

Please sign in to comment.