Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ESLint and enable more rules #572

Merged
merged 9 commits into from
Aug 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions .eslintrc

This file was deleted.

119 changes: 119 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 6,
sourceType: 'module'
},
extends: 'eslint:recommended',
env: {
'browser': true
},
rules: {
/* Possible Errors */

'no-console': 0,

/* Best Practices */

'eqeqeq': 2,
'no-eq-null': 2,
'no-labels': 2,
'no-multi-spaces': 2,
'no-new': 2,
'no-new-func': 2,
'no-new-wrappers': 2,
'no-octal-escape': 2,
'no-proto': 2,
'no-return-assign': 2,
'no-script-url': 2,
'no-self-compare': 2,
'no-sequences': 2,
'no-throw-literal': 2,
'no-unused-expressions': 2,
'no-useless-call': 2,
'no-useless-concat': 2,
'no-useless-escape': 2,
'no-void': 2,
'no-with': 2,
'yoda': 2,

/* Variables */

'no-shadow': 0,
'no-use-before-define': [2, {
'classes': false,
'functions': false,
}],

/* Stylistic Issues */

'array-bracket-spacing': 2,
'block-spacing': 2,
'camelcase': [0, {
'properties': 'always',
}],
'comma-spacing': [2, {
'before': false,
'after': true,
}],
'comma-style': 2,
'computed-property-spacing': 2,
'eol-last': 2,
'indent': [2, 2, {
'VariableDeclarator': {
'var': 2,
'let': 2,
'const': 3,
}
}],
'key-spacing': [2, {
'beforeColon': false,
'afterColon': true,
}],
'keyword-spacing': 2,
'linebreak-style': [2, 'unix'],
'max-len': [2, 250],
'max-nested-callbacks': [2, 5],
'new-cap': [2, {
'capIsNew': false,
}],
'new-parens': 2,
'no-array-constructor': 2,
'no-bitwise': 2,
'no-inline-comments': 0,
'no-new-object': 2,
'no-restricted-syntax': [2, 'WithStatement'],
'no-spaced-func': 2,
'no-trailing-spaces': 2,
'no-unneeded-ternary': 2,
'no-whitespace-before-property': 2,
'object-curly-spacing': [2, 'always'],
'operator-assignment': 2,
'semi': 2,
'semi-spacing': 2,
'space-before-blocks': 2,
'space-in-parens': 2,
'space-infix-ops': 2,
'space-unary-ops': 2,
'wrap-regex': 2,

/* ECMAScript 6 */

'arrow-body-style': 2,
'arrow-spacing': 2,
'constructor-super': 2,
'no-confusing-arrow': [2, {
'allowParens': true
}],
'no-const-assign': 2,
'no-dupe-class-members': 2,
'no-duplicate-imports': 2,
'no-new-symbol': 2,
'no-var': 2,
'object-shorthand': 2,
'prefer-spread': 2,
'prefer-template': 2,
'require-yield': 2,
'template-curly-spacing': 2,
},
};
32 changes: 0 additions & 32 deletions .jshintrc

This file was deleted.

5 changes: 2 additions & 3 deletions app/adapters/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,10 @@ export default Ember.Object.extend({
* @return {Boolean} result of the comparison
*/
function compareVersion(version1, version2) {
var compared, i;
version1 = cleanupVersion(version1).split('.');
version2 = cleanupVersion(version2).split('.');
for (i = 0; i < 3; i++) {
compared = compare(+version1[i], +version2[i]);
for (let i = 0; i < 3; i++) {
let compared = compare(+version1[i], +version2[i]);
if (compared !== 0) {
return compared;
}
Expand Down
4 changes: 2 additions & 2 deletions app/adapters/bookmarklet.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default BasicAdapter.extend({
*/
onVersionMismatch(goToVersion) {
this.sendMessage({ name: 'version-mismatch', version: goToVersion });
window.location.href = `../panes-${goToVersion.replace(/\./g, '-')}/index.html` + window.location.search;
window.location.href = `../panes-${goToVersion.replace(/\./g, '-')}/index.html${window.location.search}`;
},

_connect() {
Expand All @@ -58,5 +58,5 @@ export default BasicAdapter.extend({


function loadPageVar (sVar) {
return decodeURI(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + encodeURI(sVar).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
return decodeURI(window.location.search.replace(new RegExp(`^(?:.*[&\\?]${encodeURI(sVar).replace(/[\.\+\*]/g, "\\$&")}(?:\\=([^&]*))?)?.*$`, "i"), "$1"));
}
2 changes: 1 addition & 1 deletion app/adapters/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default BasicAdapter.extend({
this.sendMessage({
type: 'devtools:openSource',
url: file,
line: line
line
});
}

Expand Down
4 changes: 1 addition & 3 deletions app/adapters/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ export default BasicAdapter.extend({
this.get('socket').emit('emberInspectorMessage', options);
},

socket: computed(() => {
return window.EMBER_INSPECTOR_CONFIG.remoteDebugSocket;
}),
socket: computed(() => window.EMBER_INSPECTOR_CONFIG.remoteDebugSocket),

_connect() {
this.get('socket').on('emberInspectorMessage', message => {
Expand Down
2 changes: 1 addition & 1 deletion app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ App.initializer({
// register and inject adapter
let Adapter;
if (Ember.typeOf(instance.adapter) === 'string') {
Adapter = instance.resolveRegistration('adapter:' + instance.adapter);
Adapter = instance.resolveRegistration(`adapter:${instance.adapter}`);
} else {
Adapter = instance.adapter;
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/deprecation-item-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default Component.extend({
url: computed('model.map.source', 'model.map.line', 'known', function() {
let source = this.get('model.map.source');
if (this.get('known')) {
return source + ':' + this.get('model.map.line');
return `${source}:${this.get('model.map.line')}`;
} else {
return 'Unkown source';
}
Expand Down
10 changes: 5 additions & 5 deletions app/components/drag-handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export default Ember.Component.extend({
let $container = this.$().parent();
let $containerOffsetLeft = $container.offset().left;
let $containerOffsetRight = $containerOffsetLeft + $container.width();
let namespace = 'drag-' + this.get('elementId');
let namespace = `drag-${this.get('elementId')}`;

this.sendAction('action', true);

Ember.$('body').on('mousemove.' + namespace, e => {
Ember.$('body').on(`mousemove.${namespace}`, e => {
let position = this.get('isLeft') ?
e.pageX - $containerOffsetLeft :
$containerOffsetRight - e.pageX;
Expand All @@ -27,17 +27,17 @@ export default Ember.Component.extend({
this.set('position', position);
}
})
.on('mouseup.' + namespace + ' mouseleave.' + namespace, () => {
.on(`mouseup.${namespace} mouseleave.${namespace}`, () => {
this.stopDragging();
});
},

stopDragging() {
this.sendAction('action', false);
Ember.$('body').off('.drag-' + this.get('elementId'));
Ember.$('body').off(`.drag-${this.get('elementId')}`);
},

willDestroyElement: function() {
willDestroyElement() {
this._super();
this.stopDragging();
},
Expand Down
3 changes: 2 additions & 1 deletion app/components/draggable-column.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// A wrapper for a resizable-column and a drag-handle component

import Ember from "ember";
const { Component, computed } = Ember;

const { Component } = Ember;

export default Component.extend({
tagName: '', // Prevent wrapping in a div
Expand Down
4 changes: 2 additions & 2 deletions app/components/main-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default Component.extend({
updateHeight: null,

didInsertElement() {
$(window).on('resize.view-' + this.get('elementId'), () => {
$(window).on(`resize.view-${this.get('elementId')}`, () => {
this._updateHeightDebounce = debounce(this, '_updateHeight', 200);
});
schedule('afterRender', this, '_updateHeight');
Expand All @@ -24,7 +24,7 @@ export default Component.extend({
},

willDestroyElement() {
$(window).off('.view-' + this.get('elementId'));
$(window).off(`.view-${this.get('elementId')}`);
cancel(this._updateHeightDebounce);
return this._super(...arguments);
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/mixin-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default Component.extend({
let value = this.get('model.value.inspect');
let type = this.get('model.value.type');
if (type === 'type-string') {
value = '"' + value + '"';
value = `"${value}"`;
}
if (!this.get('isDate')) {
this.set('txtValue', value);
Expand Down
2 changes: 1 addition & 1 deletion app/components/object-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default Component.extend({
trail: computed('model.[]', function() {
let nested = this.get('model').slice(1);
if (nested.length === 0) { return ""; }
return "." + nested.mapBy('property').join(".");
return `.${nested.mapBy('property').join(".")}`;
}),

isNested: computed('model.[]', function() {
Expand Down
5 changes: 3 additions & 2 deletions app/components/promise-item.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Ember from "ember";
const { Component, computed, String: { htmlSafe }, getOwner, isEmpty } = Ember;
const { alias, notEmpty, empty, gt, equal } = computed;

const { Component, computed, String: { htmlSafe }, isEmpty } = Ember;
const { notEmpty, gt, equal } = computed;

const COLOR_MAP = {
red: '#ff2717',
Expand Down
4 changes: 1 addition & 3 deletions app/components/record-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ export default Component.extend({

columns: computed('modelTypeColumns.[]', 'model.columnValues', function() {
let columns = this.get('modelTypeColumns') || [];
return columns.map(col => {
return { name: col.name, value: this.get('model.columnValues.' + col.name) };
});
return columns.map(col => ({ name: col.name, value: this.get(`model.columnValues.${col.name}`) }));
}),

click() {
Expand Down
13 changes: 7 additions & 6 deletions app/components/render-item.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Ember from 'ember';
import escapeRegExp from "ember-inspector/utils/escape-reg-exp";
const { Component, computed, isEmpty, run, on, observer, String: { htmlSafe } } = Ember;
const { gt, readOnly } = computed;

const { Component, computed, isEmpty, isNone, run, on, observer, String: { htmlSafe } } = Ember;
const { gt } = computed;
const { once } = run;

export default Component.extend({
Expand Down Expand Up @@ -42,7 +43,7 @@ export default Component.extend({

level: computed('target.level', function() {
let parentLevel = this.get('target.level');
if (parentLevel == null) {
if (isNone(parentLevel)) {
parentLevel = -1;
}
return parentLevel + 1;
Expand All @@ -68,10 +69,10 @@ export default Component.extend({
let d = new Date(this.get('model.timestamp'));
let ms = d.getMilliseconds();
let seconds = d.getSeconds();
let minutes = d.getMinutes().toString().length === 1 ? '0' + d.getMinutes() : d.getMinutes();
let hours = d.getHours().toString().length === 1 ? '0' + d.getHours() : d.getHours();
let minutes = d.getMinutes().toString().length === 1 ? `0${d.getMinutes()}` : d.getMinutes();
let hours = d.getHours().toString().length === 1 ? `0${d.getHours()}` : d.getHours();

return hours + ':' + minutes + ':' + seconds + ':' + ms;
return `${hours}:${minutes}:${seconds}:${ms}`;
}),

actions: {
Expand Down
Loading