From 3d47c1cbd4f7e0ecf3c2708b9a6929ecdede51ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Buscht=C3=B6ns?= Date: Wed, 21 Jun 2017 14:04:00 +0200 Subject: [PATCH] eslint/ember-suave: sensibly configure and fix linter errors --- .eslintrc.js | 3 +++ addon/-private/global-options.js | 1 + addon/-private/sync-array-proxy.js | 3 ++- addon/classes/Column.js | 5 +++-- addon/classes/Row.js | 8 ++++++-- addon/classes/Table.js | 5 +++-- addon/components/lt-column-resizer.js | 3 ++- addon/mixins/draggable-column.js | 5 +++-- addon/mixins/table-header.js | 5 +++-- tests/.eslintrc.js | 3 +++ tests/dummy/app/adapters/application.js | 4 ++-- tests/dummy/app/app.js | 8 ++++---- tests/dummy/app/breakpoints.js | 1 + tests/dummy/app/components/code-panel.js | 4 +++- tests/dummy/app/components/columns/draggable-table.js | 3 ++- tests/dummy/app/components/columns/grouped-table.js | 3 ++- tests/dummy/app/components/columns/resizable-table.js | 3 ++- tests/dummy/app/components/cookbook/client-side-table.js | 3 ++- tests/dummy/app/components/cookbook/custom-row-table.js | 3 ++- .../components/cookbook/horizontal-scrolling-table.js | 3 ++- tests/dummy/app/components/cookbook/paginated-table.js | 3 ++- .../dummy/app/components/cookbook/table-actions-table.js | 3 ++- tests/dummy/app/components/responsive-table.js | 3 ++- tests/dummy/app/components/rows/expandable-table.js | 3 ++- tests/dummy/app/components/rows/selectable-table.js | 3 ++- tests/dummy/app/components/scrolling-table.js | 3 ++- tests/dummy/app/components/simple-table.js | 3 ++- tests/dummy/app/mixins/table-common.js | 5 +++-- tests/dummy/app/models/user.js | 9 +++------ tests/dummy/app/router.js | 1 + tests/dummy/app/routes/table-route.js | 9 +++++++-- tests/helpers/create-click-event.js | 2 +- 32 files changed, 80 insertions(+), 43 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 7a8a44bc..3bd8a36a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -12,5 +12,8 @@ module.exports = { browser: true }, rules: { + 'generator-star-spacing': ['error', { before: false, after: false }], + 'ember-suave/require-access-in-comments': 'off', + 'ember-suave/no-const-outside-module-scope': 'off' } }; diff --git a/addon/-private/global-options.js b/addon/-private/global-options.js index 49c5c96b..4d33cde4 100644 --- a/addon/-private/global-options.js +++ b/addon/-private/global-options.js @@ -1,6 +1,7 @@ import Ember from 'ember'; import config from 'ember-get-config'; +// eslint-disable-next-line ember-suave/no-direct-property-access const assign = Ember.assign || Ember.merge; const globalOptions = config['ember-light-table'] || {}; diff --git a/addon/-private/sync-array-proxy.js b/addon/-private/sync-array-proxy.js index 109111ba..8bc81477 100644 --- a/addon/-private/sync-array-proxy.js +++ b/addon/-private/sync-array-proxy.js @@ -1,13 +1,14 @@ import Ember from 'ember'; const { + ArrayProxy, assert, isArray } = Ember; const EMPTY_ARRAY = []; -export default Ember.ArrayProxy.extend({ +export default ArrayProxy.extend({ /** * The model that will be synchronized to the content of this proxy * @property syncArray diff --git a/addon/classes/Column.js b/addon/classes/Column.js index 6da8a43b..305ae4a3 100644 --- a/addon/classes/Column.js +++ b/addon/classes/Column.js @@ -5,14 +5,15 @@ const { isEmpty, makeArray, computed, - A: emberArray + A: emberArray, + Object: EmberObject } = Ember; /** * @module Table * @class Column */ -export default class Column extends Ember.Object.extend({ +export default class Column extends EmberObject.extend({ /** * Whether the column can be hidden. * diff --git a/addon/classes/Row.js b/addon/classes/Row.js index 5bfae3d4..e314b667 100644 --- a/addon/classes/Row.js +++ b/addon/classes/Row.js @@ -1,13 +1,17 @@ import Ember from 'ember'; -const { computed, guidFor } = Ember; +const { + computed, + guidFor, + ObjectProxy +} = Ember; /** * @module Table * @extends Ember.ObjectProxy * @class Row */ -export default class Row extends Ember.ObjectProxy.extend({ +export default class Row extends ObjectProxy.extend({ /** * Whether the row is hidden. * diff --git a/addon/classes/Table.js b/addon/classes/Table.js index 59650947..8cd8be49 100644 --- a/addon/classes/Table.js +++ b/addon/classes/Table.js @@ -8,7 +8,8 @@ const { get, computed, isNone, - A: emberArray + A: emberArray, + Object: EmberObject } = Ember; const RowSyncArrayProxy = SyncArrayProxy.extend({ @@ -30,7 +31,7 @@ const RowSyncArrayProxy = SyncArrayProxy.extend({ * @module Table * @class Table */ -export default class Table extends Ember.Object.extend({ +export default class Table extends EmberObject.extend({ /** * @property columns * @type {Ember.Array} diff --git a/addon/components/lt-column-resizer.js b/addon/components/lt-column-resizer.js index cdf395e9..ca196dd1 100644 --- a/addon/components/lt-column-resizer.js +++ b/addon/components/lt-column-resizer.js @@ -3,12 +3,13 @@ import layout from '../templates/components/lt-column-resizer'; const { $, + Component, computed } = Ember; const TOP_LEVEL_CLASS = '.ember-light-table'; -export default Ember.Component.extend({ +export default Component.extend({ layout, classNameBindings: [':lt-column-resizer', 'isResizing'], column: null, diff --git a/addon/mixins/draggable-column.js b/addon/mixins/draggable-column.js index 64bfb274..688d0321 100644 --- a/addon/mixins/draggable-column.js +++ b/addon/mixins/draggable-column.js @@ -2,12 +2,13 @@ import Ember from 'ember'; const { run, - computed + computed, + Mixin } = Ember; let sourceColumn; -export default Ember.Mixin.create({ +export default Mixin.create({ classNameBindings: ['isDragging', 'isDragTarget', 'dragDirection'], attributeBindings: ['isDraggable:draggable'], diff --git a/addon/mixins/table-header.js b/addon/mixins/table-header.js index 3e06552a..f4273c2a 100644 --- a/addon/mixins/table-header.js +++ b/addon/mixins/table-header.js @@ -1,7 +1,8 @@ import Ember from 'ember'; const { - computed + computed, + Mixin } = Ember; /** @@ -14,7 +15,7 @@ const { * @private */ -export default Ember.Mixin.create({ +export default Mixin.create({ /** * @property table * @type {Table} diff --git a/tests/.eslintrc.js b/tests/.eslintrc.js index 0992d043..6f5bb66b 100644 --- a/tests/.eslintrc.js +++ b/tests/.eslintrc.js @@ -5,5 +5,8 @@ module.exports = { globals: { $: false, server: false + }, + rules: { + 'ember-suave/no-direct-property-access': 'off' } }; diff --git a/tests/dummy/app/adapters/application.js b/tests/dummy/app/adapters/application.js index 6a1e0d9d..1019b938 100644 --- a/tests/dummy/app/adapters/application.js +++ b/tests/dummy/app/adapters/application.js @@ -1,6 +1,6 @@ -import DS from 'ember-data'; +import RESTAdapter from 'ember-data/adapters/rest'; import ENV from '../config/environment'; -export default DS.RESTAdapter.extend({ +export default RESTAdapter.extend({ namespace: `${ENV.rootURL}api` }); diff --git a/tests/dummy/app/app.js b/tests/dummy/app/app.js index 831ad610..4372a448 100644 --- a/tests/dummy/app/app.js +++ b/tests/dummy/app/app.js @@ -3,11 +3,11 @@ import Resolver from './resolver'; import loadInitializers from 'ember-load-initializers'; import config from './config/environment'; -let App; +const { + Application +} = Ember; -Ember.MODEL_FACTORY_INJECTIONS = true; - -App = Ember.Application.extend({ +const App = Application.extend({ modulePrefix: config.modulePrefix, podModulePrefix: config.podModulePrefix, Resolver diff --git a/tests/dummy/app/breakpoints.js b/tests/dummy/app/breakpoints.js index 1d03d266..d0ef5d8e 100644 --- a/tests/dummy/app/breakpoints.js +++ b/tests/dummy/app/breakpoints.js @@ -1,3 +1,4 @@ +/* eslint-disable key-spacing */ export default { mobile: '(max-width: 768px)', tablet: '(min-width: 769px) and (max-width: 992px)', diff --git a/tests/dummy/app/components/code-panel.js b/tests/dummy/app/components/code-panel.js index 9ae73b68..2322af1f 100644 --- a/tests/dummy/app/components/code-panel.js +++ b/tests/dummy/app/components/code-panel.js @@ -1,7 +1,9 @@ import Ember from 'ember'; import layout from '../templates/components/code-panel'; -export default Ember.Component.extend({ +const { Component } = Ember; + +export default Component.extend({ layout, collapse: true, title: '', diff --git a/tests/dummy/app/components/columns/draggable-table.js b/tests/dummy/app/components/columns/draggable-table.js index ca032a78..f3dc9556 100644 --- a/tests/dummy/app/components/columns/draggable-table.js +++ b/tests/dummy/app/components/columns/draggable-table.js @@ -3,10 +3,11 @@ import Ember from 'ember'; import TableCommon from '../../mixins/table-common'; const { + Component, computed } = Ember; -export default Ember.Component.extend(TableCommon, { +export default Component.extend(TableCommon, { columns: computed(function() { return [{ label: 'User Details', diff --git a/tests/dummy/app/components/columns/grouped-table.js b/tests/dummy/app/components/columns/grouped-table.js index d706cd4b..6c2d5b05 100644 --- a/tests/dummy/app/components/columns/grouped-table.js +++ b/tests/dummy/app/components/columns/grouped-table.js @@ -3,10 +3,11 @@ import Ember from 'ember'; import TableCommon from '../../mixins/table-common'; const { + Component, computed } = Ember; -export default Ember.Component.extend(TableCommon, { +export default Component.extend(TableCommon, { columns: computed(function() { return [{ label: 'User Details', diff --git a/tests/dummy/app/components/columns/resizable-table.js b/tests/dummy/app/components/columns/resizable-table.js index f5be68f4..02ff6951 100644 --- a/tests/dummy/app/components/columns/resizable-table.js +++ b/tests/dummy/app/components/columns/resizable-table.js @@ -3,10 +3,11 @@ import Ember from 'ember'; import TableCommon from '../../mixins/table-common'; const { + Component, computed } = Ember; -export default Ember.Component.extend(TableCommon, { +export default Component.extend(TableCommon, { columns: computed(function() { return [{ label: 'User Details', diff --git a/tests/dummy/app/components/cookbook/client-side-table.js b/tests/dummy/app/components/cookbook/client-side-table.js index c5d63240..6b62b36c 100644 --- a/tests/dummy/app/components/cookbook/client-side-table.js +++ b/tests/dummy/app/components/cookbook/client-side-table.js @@ -4,10 +4,11 @@ import TableCommon from '../../mixins/table-common'; import { task, timeout } from 'ember-concurrency'; const { + Component, computed } = Ember; -export default Ember.Component.extend(TableCommon, { +export default Component.extend(TableCommon, { query: '', // No need for `enableSync` here diff --git a/tests/dummy/app/components/cookbook/custom-row-table.js b/tests/dummy/app/components/cookbook/custom-row-table.js index 4eaaf2b8..6b864f2e 100644 --- a/tests/dummy/app/components/cookbook/custom-row-table.js +++ b/tests/dummy/app/components/cookbook/custom-row-table.js @@ -3,10 +3,11 @@ import Ember from 'ember'; import TableCommon from '../../mixins/table-common'; const { + Component, computed } = Ember; -export default Ember.Component.extend(TableCommon, { +export default Component.extend(TableCommon, { columns: computed(function() { return [{ label: 'Avatar', diff --git a/tests/dummy/app/components/cookbook/horizontal-scrolling-table.js b/tests/dummy/app/components/cookbook/horizontal-scrolling-table.js index 79387bb7..434e43c1 100644 --- a/tests/dummy/app/components/cookbook/horizontal-scrolling-table.js +++ b/tests/dummy/app/components/cookbook/horizontal-scrolling-table.js @@ -3,10 +3,11 @@ import Ember from 'ember'; import TableCommon from '../../mixins/table-common'; const { + Component, computed } = Ember; -export default Ember.Component.extend(TableCommon, { +export default Component.extend(TableCommon, { columns: computed(function() { return [{ label: 'Avatar', diff --git a/tests/dummy/app/components/cookbook/paginated-table.js b/tests/dummy/app/components/cookbook/paginated-table.js index 2f23c26e..20ec93af 100644 --- a/tests/dummy/app/components/cookbook/paginated-table.js +++ b/tests/dummy/app/components/cookbook/paginated-table.js @@ -3,10 +3,11 @@ import Ember from 'ember'; import TableCommon from '../../mixins/table-common'; const { + Component, computed } = Ember; -export default Ember.Component.extend(TableCommon, { +export default Component.extend(TableCommon, { columns: computed(function() { return [{ label: 'Avatar', diff --git a/tests/dummy/app/components/cookbook/table-actions-table.js b/tests/dummy/app/components/cookbook/table-actions-table.js index b88aaabb..abab8540 100644 --- a/tests/dummy/app/components/cookbook/table-actions-table.js +++ b/tests/dummy/app/components/cookbook/table-actions-table.js @@ -3,10 +3,11 @@ import Ember from 'ember'; import TableCommon from '../../mixins/table-common'; const { + Component, computed } = Ember; -export default Ember.Component.extend(TableCommon, { +export default Component.extend(TableCommon, { columns: computed(function() { return [{ label: 'Avatar', diff --git a/tests/dummy/app/components/responsive-table.js b/tests/dummy/app/components/responsive-table.js index fb16250d..d442a541 100644 --- a/tests/dummy/app/components/responsive-table.js +++ b/tests/dummy/app/components/responsive-table.js @@ -3,10 +3,11 @@ import Ember from 'ember'; import TableCommon from '../mixins/table-common'; const { + Component, computed } = Ember; -export default Ember.Component.extend(TableCommon, { +export default Component.extend(TableCommon, { columns: computed(function() { return [{ width: '40px', diff --git a/tests/dummy/app/components/rows/expandable-table.js b/tests/dummy/app/components/rows/expandable-table.js index 83fdf47a..ddfda502 100644 --- a/tests/dummy/app/components/rows/expandable-table.js +++ b/tests/dummy/app/components/rows/expandable-table.js @@ -3,10 +3,11 @@ import Ember from 'ember'; import TableCommon from '../../mixins/table-common'; const { + Component, computed } = Ember; -export default Ember.Component.extend(TableCommon, { +export default Component.extend(TableCommon, { columns: computed(function() { return [{ label: 'First Name', diff --git a/tests/dummy/app/components/rows/selectable-table.js b/tests/dummy/app/components/rows/selectable-table.js index f78308e5..a7aaca5e 100644 --- a/tests/dummy/app/components/rows/selectable-table.js +++ b/tests/dummy/app/components/rows/selectable-table.js @@ -3,10 +3,11 @@ import Ember from 'ember'; import TableCommon from '../../mixins/table-common'; const { + Component, computed } = Ember; -export default Ember.Component.extend(TableCommon, { +export default Component.extend(TableCommon, { hasSelection: computed.notEmpty('table.selectedRows'), columns: computed(function() { diff --git a/tests/dummy/app/components/scrolling-table.js b/tests/dummy/app/components/scrolling-table.js index af26d79c..2a82dc93 100644 --- a/tests/dummy/app/components/scrolling-table.js +++ b/tests/dummy/app/components/scrolling-table.js @@ -3,10 +3,11 @@ import Ember from 'ember'; import TableCommon from '../mixins/table-common'; const { + Component, computed } = Ember; -export default Ember.Component.extend(TableCommon, { +export default Component.extend(TableCommon, { currentScrollOffset: 0, scrollTo: 0, scrollToRow: null, diff --git a/tests/dummy/app/components/simple-table.js b/tests/dummy/app/components/simple-table.js index fe6f0318..15ad89e9 100644 --- a/tests/dummy/app/components/simple-table.js +++ b/tests/dummy/app/components/simple-table.js @@ -3,10 +3,11 @@ import Ember from 'ember'; import TableCommon from '../mixins/table-common'; const { + Component, computed } = Ember; -export default Ember.Component.extend(TableCommon, { +export default Component.extend(TableCommon, { columns: computed(function() { return [{ label: 'Avatar', diff --git a/tests/dummy/app/mixins/table-common.js b/tests/dummy/app/mixins/table-common.js index 053b3b74..2a411c0b 100644 --- a/tests/dummy/app/mixins/table-common.js +++ b/tests/dummy/app/mixins/table-common.js @@ -6,10 +6,11 @@ import { task } from 'ember-concurrency'; const { inject, isEmpty, - computed + computed, + Mixin } = Ember; -export default Ember.Mixin.create({ +export default Mixin.create({ store: inject.service(), page: 0, diff --git a/tests/dummy/app/models/user.js b/tests/dummy/app/models/user.js index c8ebacd9..ec28b4f7 100644 --- a/tests/dummy/app/models/user.js +++ b/tests/dummy/app/models/user.js @@ -1,10 +1,7 @@ -import DS from 'ember-data'; +import Model from 'ember-data/model'; +import attr from 'ember-data/attr'; -const { - attr -} = DS; - -export default DS.Model.extend({ +export default Model.extend({ firstName: attr('string'), lastName: attr('string'), company: attr('string'), diff --git a/tests/dummy/app/router.js b/tests/dummy/app/router.js index f6ac9f14..8be38e04 100644 --- a/tests/dummy/app/router.js +++ b/tests/dummy/app/router.js @@ -1,6 +1,7 @@ import Ember from 'ember'; import config from './config/environment'; +// eslint-disable-next-line ember-suave/no-direct-property-access const Router = Ember.Router.extend({ location: config.locationType, rootURL: config.rootURL diff --git a/tests/dummy/app/routes/table-route.js b/tests/dummy/app/routes/table-route.js index 45599e79..58637e11 100644 --- a/tests/dummy/app/routes/table-route.js +++ b/tests/dummy/app/routes/table-route.js @@ -1,8 +1,13 @@ import Ember from 'ember'; -export default Ember.Route.extend({ +const { + A, + Route +} = Ember; + +export default Route.extend({ model() { - return Ember.A([]); + return A([]); }, resetController(controller, isExiting) { diff --git a/tests/helpers/create-click-event.js b/tests/helpers/create-click-event.js index 2a198831..20dd7a5d 100644 --- a/tests/helpers/create-click-event.js +++ b/tests/helpers/create-click-event.js @@ -1,5 +1,5 @@ export default function createClickEvent(opts = {}) { - let e = $.Event('click'); + let e = new $.Event('click'); Object.keys(opts).forEach((o) => e[o] = opts[o]); return e; }