From a916a71ec393445d729a0f6f562fb11411ecefda Mon Sep 17 00:00:00 2001 From: zepumph Date: Thu, 17 Jan 2019 10:45:27 -0900 Subject: [PATCH] convert base config to idiomatic js, https://github.com/phetsims/tasks/issues/972 --- eslint/.eslintrc.js | 340 ++++++++++++++++++++++++++------------------ 1 file changed, 201 insertions(+), 139 deletions(-) diff --git a/eslint/.eslintrc.js b/eslint/.eslintrc.js index 1e0aa9d1..e6d62905 100644 --- a/eslint/.eslintrc.js +++ b/eslint/.eslintrc.js @@ -1,4 +1,4 @@ -// Copyright 2015-2018 University of Colorado Boulder +// Copyright 2015-2019 University of Colorado Boulder // @author Sam Reid // @author Michael Kauzmann @@ -7,157 +7,167 @@ /** * The base eslint configuration for the project + * values for rules: + * 0 - no error + * 1 - warn + * 2 - error */ module.exports = { + // Use all of the default rules from eslint, unless overridden below. - "extends": "eslint:recommended", + extends: 'eslint:recommended', // specify that this file is the root of the eslintrc tree, so eslint won't search past this file looking for a file // in a parent dir - "root": true, + root: true, + // The new rules, overrides, etc. - "rules": { + rules: { // Permit console.log statements (we have a lot of them) // TODO: Find a way to make sure no console.log statements make it to production. Can use the no-console rule // but we want to be able to use console.log during development. - "no-console": 0, + 'no-console': 0, // specify whether backticks, double or single quotes should be used (fixable) - "quotes": [ + quotes: [ 2, - "single" + 'single' ], + // No dangling commas, see https://github.com/phetsims/tasks/issues/940 - "comma-dangle": 2, + 'comma-dangle': 2, + // Prohibit for...of statements - "no-restricted-syntax": [ - "error", + 'no-restricted-syntax': [ + 2, { - "selector": "ForOfStatement", - "message": "Babel transpiles for...of to use Symbol which is not supported on all our platforms." + selector: 'ForOfStatement', + message: 'Babel transpiles for...of to use Symbol which is not supported on all our platforms.' } ], // require or disallow use of semicolons instead of ASI (fixable) - "semi": [ + semi: [ 2, - "always" + 'always' ], - "bad-text": 2, + 'bad-text': 2, // Custom rule for checking the copyright. - "copyright": 2, + copyright: 2, // Custom rule for checking TODOs have issues - "todo-should-have-issue": 2, + 'todo-should-have-issue': 2, // Custom rule for ensuring that images and text use scenery node - "no-html-constructors": 2, + 'no-html-constructors': 2, // Custom rule for avoiding Math.sign which is not supported on IE - "no-math-sign": 2, + 'no-math-sign': 2, // Custom rule for avoiding instanceof Array. - "no-instanceof-array": 2, + 'no-instanceof-array': 2, // disallow declaration of variables that are not used in the code (recommended) // Overriden to allow unused args - "no-unused-vars": [ + 'no-unused-vars': [ 2, { - "vars": "all", - "args": "none" + vars: 'all', + args: 'none' } ], // error when let is used but the variable is never reassigned, see https://github.com/phetsims/tasks/issues/973 - "prefer-const": [ - "error", + 'prefer-const': [ + 2, { - "destructuring": "any", - "ignoreReadBeforeAssign": false + destructuring: 'any', + ignoreReadBeforeAssign: false } ], - // "require-jsdoc": [ - // 2 - // ], // require the use of === and !== (fixable) - "eqeqeq": 2, + eqeqeq: 2, // specify curly brace conventions for all control statements - "curly": 2, - // "no-use-before-define": [ + curly: 2, + + // 'no-use-before-define': [ // 2 // ], // TODO: This may be good to have - // "new-cap": [ + // 'new-cap': [ // 2 // ], // disallow use of arguments.caller or arguments.callee - "no-caller": 2, + 'no-caller': 2, // disallow use of the new operator when not part of an assignment or comparison - "no-new": 2, + 'no-new': 2, // controls location of Use Strict Directives - "strict": 2, + strict: 2, // Avoid code that looks like two expressions but is actually one - "no-unexpected-multiline": 2, + 'no-unexpected-multiline': 2, // encourages use of dot notation whenever possible - "dot-notation": 2, + 'dot-notation': 2, // disallow adding to native types - "no-extend-native": 2, + 'no-extend-native': 2, // disallow use of assignment in return statement - "no-return-assign": 2, + 'no-return-assign': 2, // disallow comparisons where both sides are exactly the same - "no-self-compare": 2, + 'no-self-compare': 2, // disallow unnecessary .call() and .apply() // TODO: Under discussion in https://github.com/phetsims/scenery-phet/issues/193 - // "no-useless-call": 2, + // 'no-useless-call': 2, // disallow use of undefined when initializing variables - "no-undef-init": 2, + 'no-undef-init': 2, // - "require-statement-match": 2, - "phet-io-require-contains-ifphetio": 2, - "require-tandem-support": 0, + 'require-statement-match': 2, + 'phet-io-require-contains-ifphetio': 2, + 'require-tandem-support': 0, // Require @public/@private for this.something = result; - "property-visibility-annotation": 0, - "no-property-in-require-statement": 2, + 'property-visibility-annotation': 0, + 'no-property-in-require-statement': 2, // permit only one var declaration per line, see #390 - "one-var": [ + 'one-var': [ 2, - "never" + 'never' ], - "string-require-statement-match": 2, + 'string-require-statement-match': 2, + // require radix argument for parseInt - "radix": 2, + radix: 2, + // require default case for switch statements - "default-case": 2, + 'default-case': 2, + // do not allow fall-through cases in switch statements - "no-fallthrough": 2, + 'no-fallthrough': 2, + // consistently use 'self' as the alias for 'this' - "consistent-this": [ + 'consistent-this': [ 2, - "self" + 'self' ] // disallow trailing whitespace at the end of lines (fixable) - // "no-trailing-spaces": 2, + // 'no-trailing-spaces': 2, // USE THIS DURING CODE REVIEW // specify the maximum length of a line in your program - // "max-len": [ + // 'max-len': [ // 2, // // this many columns per line // 120, @@ -165,151 +175,203 @@ module.exports = { // 4 // ] }, - "env": { - "browser": true, - "es6": true + env: { + browser: true, + es6: true }, - "parserOptions": { - "ecmaVersion": 8 + parserOptions: { + ecmaVersion: 8 }, - "globals": { + globals: { + // Global symbols that are permissible to overwrite ----------------------- - "process": true, + process: true, + // allow assertions - "assert": true, + assert: true, + // allow slow assertions - "assertSlow": true, + assertSlow: true, + // scenery logging levels - "sceneryLog": true, + sceneryLog: true, + // scenery accessibility levels - "sceneryAccessibilityLog": true, + sceneryAccessibilityLog: true, + // we actually polyfill this, so allow it to be set - "Float32Array": true, - "phet": true, - "phetio": true, - "aqua": true, + Float32Array: true, + + phet: true, + phetio: true, + aqua: true, + // For use in aqua tests // underscore, lodash - "_": true, + _: true, + // read-only globals --------------------------------- // Javascript Set - "Set": false, + Set: false, + // jQuery - "$": false, + $: false, + // for full screen - "ActiveXObject": false, + ActiveXObject: false, + //for debugging on ipad - "alert": false, + alert: false, + // for Mocha tests - "afterEach": false, + afterEach: false, + // backbone is currently run outside of requirejs - "Backbone": false, + Backbone: false, + // for Mocha tests - "beforeEach": false, + beforeEach: false, + // BigRational - "bigRat": false, + bigRat: false, + // DOM.js - "Blob": false, + Blob: false, + // Box2D physics engine - "Box2D": false, + Box2D: false, - "Buffer": false, + Buffer: false, - "canvg": false, + canvg: false, - "clarinet": false, + clarinet: false, - "clearTimeout": false, + clearTimeout: false, + + console: false, - "console": false, // d3.js data visualization library - "d3": false, + d3: false, + // require.js - "define": false, + define: false, + // for Mocha unit tests - "describe": false, + describe: false, + + document: false, - "document": false, // For qunit - "dot": false, - "equal": false, + dot: false, + + equal: false, + // For file loading, see SaveLoadNode in Energy Skate Park: Basics - "FileReader": false, + FileReader: false, + // for linting Node.js code - "global": false, + global: false, + // jshashes library, for hashing strings (screenshot comparison) - "Hashes": false, + Hashes: false, + // for HTML entity parsing - "he": false, + he: false, + // for HTML => JSON parsing - "himalaya": false, + himalaya: false, + // for hightlighting - "hljs": false, + hljs: false, + //for web audio - "Howl": false, + Howl: false, + + HTMLCanvasElement: false, + HTMLImageElement: false, - "HTMLCanvasElement": false, - "HTMLImageElement": false, // for CODAP or other Concord communication - "iframePhone": false, + iframePhone: false, + // DOM.js - "Image": false, + Image: false, + // for Mocha unit tests - "it": false, + it: false, + // QUnit - "kite": false, + kite: false, + // for using native Map - "Map": false, + Map: false, + // QUnit - "QUnit": false, + QUnit: false, + // For KaTeX - "katex": false, - // For setting location.href to save to local file, see http"://stackoverflow.com/questions/2897619/using-html5-javascript-to-generate-and-save-a-file - "location": false, + katex: false, + + // For setting location.href to save to local file, see http://stackoverflow.com/questions/2897619/using-html5-javascript-to-generate-and-save-a-file + location: false, + // LZ-string, for compressing and decompressing strings - "LZString": false, + LZString: false, + // PhET-iO - "Metacog": false, + Metacog: false, + // as used in Gruntfile.js - "module": false, - // For Mobile Safari detection, see http"://stackoverflow.com/questions/3007480/determine-if-user-navigated-from-mobile-safari - "navigator": false, + module: false, + + // For Mobile Safari detection, see http://stackoverflow.com/questions/3007480/determine-if-user-navigated-from-mobile-safari + navigator: false, + // Numeric library used in energy skate park - "numeric": false, - "ok": false, + numeric: false, + + ok: false, + PIXI: false, - "PIXI": false, // For poly2tri triangulation library - "poly2tri": false, + poly2tri: false, + // Misc - "QueryStringMachine": false, + QueryStringMachine: false, - "readFile": false, // require.js - "require": false, + require: false, + + scenery: false, - "scenery": false, // For @mrdoob's stats + frame rate readout component - "Stats": false, + Stats: false, + // qunit - "test": false, + test: false, + // For three.js 3d things - "THREE": false, + THREE: false, + // sole/tween.js - "TWEEN": false, + TWEEN: false, + + Uint16Array: false, + Uint32Array: false, - "Uint16Array": false, - "Uint32Array": false, // for khronos webgl-debug.js debugging utilities - "WebGLDebugUtils": false, + WebGLDebugUtils: false, + // for WebSocket communication - "WebSocket": false, + WebSocket: false, + + window: false, - "window": false, // allow ajax requests directly - "XMLHttpRequest": false, - "toast": false, - "Fourier": false + XMLHttpRequest: false, + + toast: false, + Fourier: false } }; \ No newline at end of file