Skip to content

Commit

Permalink
Get lint running
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinlough committed Mar 30, 2022
1 parent e5230a5 commit 8a5e42d
Show file tree
Hide file tree
Showing 15 changed files with 404 additions and 312 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
- browser-tools/install-chromedriver
- node/install-packages:
pkg-manager: yarn
- run: JOBS=1 ./node_modules/.bin/ember test
- run: JOBS=1 npm run lint
- run: JOBS=1 ./node_modules/.bin/ember test
- run: JOBS=1 ./node_modules/.bin/ember try:one ember-lts-3.16
- run: JOBS=1 ./node_modules/.bin/ember try:one ember-release
- run: JOBS=1 ./node_modules/.bin/ember try:one ember-default-with-jquery
workflows:
tests:
jobs:
Expand Down
29 changes: 17 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@ module.exports = {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true,
},
legacyDecorators: true
}
},
plugins: ['ember'],
extends: [
'eslint:recommended',
'plugin:ember/recommended',
'plugin:prettier/recommended',
'plugin:prettier/recommended'
],
env: {
browser: true,
browser: true
},
rules: {
'ember/no-classic-components': 'off'
},
rules: {},
overrides: [
// node files
{
Expand All @@ -32,22 +34,25 @@ module.exports = {
'./testem.js',
'./blueprints/*/index.js',
'./config/**/*.js',
'./tests/dummy/config/**/*.js',
'./tests/dummy/config/**/*.js'
],
parserOptions: {
sourceType: 'script',
sourceType: 'script'
},
env: {
browser: false,
node: true,
node: true
},
plugins: ['node'],
extends: ['plugin:node/recommended'],
extends: ['plugin:node/recommended']
},
{
// Test files:
// test files
files: ['tests/**/*-test.{js,ts}'],
extends: ['plugin:qunit/recommended'],
},
],
rules: {
'qunit/no-assert-equal': 'off'
}
}
]
};
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

module.exports = {
singleQuote: true,
trailingComma: 'none'
};
2 changes: 1 addition & 1 deletion .template-lintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

module.exports = {
extends: 'recommended',
extends: 'recommended'
};
64 changes: 41 additions & 23 deletions addon/components/tag-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const KEY_CODES = {
const TAG_CLASS = 'emberTagInput-tag';
const REMOVE_CONFIRMATION_CLASS = 'emberTagInput-tag--remove';

export default Component.extend({
export default class TagInput extends Component {
layout,

classNameBindings: [':emberTagInput', 'readOnly:emberTagInput--readOnly'],
Expand All @@ -34,16 +34,20 @@ export default Component.extend({
placeholder: '',

ariaLabel: '',
_isRemoveButtonVisible: computed('showRemoveButtons', 'readOnly', function() {
return this.get('showRemoveButtons') && !this.get('readOnly');
}),
_isRemoveButtonVisible: computed(
'showRemoveButtons',
'readOnly',
function () {
return this.showRemoveButtons && !this.readOnly;
}
),

onKeyUp: false,

addNewTag(tag) {
const tags = this.get('tags');
const addTag = this.get('addTag');
const allowDuplicates = this.get('allowDuplicates');
const tags = this.tags;
const addTag = this.addTag;
const allowDuplicates = this.allowDuplicates;

if (!allowDuplicates && tags && tags.indexOf(tag) >= 0) {
return false;
Expand All @@ -53,18 +57,19 @@ export default Component.extend({
},

didInsertElement() {
this._super(...arguments);
this.initEvents();
},

dispatchKeyUp(value) {
if (this.get('onKeyUp')) {
this.get('onKeyUp')(value);
if (this.onKeyUp) {
this.onKeyUp(value);
}
},

_onContainerClick() {
const newTagInput = this.element.querySelector('.js-ember-tag-input-new');
const isReadOnly = this.get('readOnly');
const isReadOnly = this.readOnly;

if (!isReadOnly) {
newTagInput.focus();
Expand All @@ -73,20 +78,26 @@ export default Component.extend({

_onInputKeyDown(e) {
if (!this.readOnly) {
const allowSpacesInTags = this.get('allowSpacesInTags');
const tags = this.get('tags');
const backspaceRegex = new RegExp(String.fromCharCode(KEY_CODES.BACKSPACE), 'g');
const allowSpacesInTags = this.allowSpacesInTags;
const tags = this.tags;
const backspaceRegex = new RegExp(
String.fromCharCode(KEY_CODES.BACKSPACE),
'g'
);
const newTag = e.target.value.trim().replace(backspaceRegex, '');

if (e.which === KEY_CODES.BACKSPACE) {
if (newTag.length === 0 && tags.length > 0) {
const removeTagAtIndex = this.get('removeTagAtIndex');
const removeTagAtIndex = this.removeTagAtIndex;

if (this.get('removeConfirmation')) {
const tags = this.element.querySelectorAll('.' + TAG_CLASS)
if (this.removeConfirmation) {
const tags = this.element.querySelectorAll('.' + TAG_CLASS);
const lastTag = tags[tags.length - 1];

if (lastTag && !lastTag.classList.contains(REMOVE_CONFIRMATION_CLASS)) {
if (
lastTag &&
!lastTag.classList.contains(REMOVE_CONFIRMATION_CLASS)
) {
lastTag.classList.add(REMOVE_CONFIRMATION_CLASS);
return;
}
Expand All @@ -95,7 +106,11 @@ export default Component.extend({
removeTagAtIndex(tags.length - 1);
}
} else {
if (e.which === KEY_CODES.COMMA || (!allowSpacesInTags && e.which === KEY_CODES.SPACE) || e.which === KEY_CODES.ENTER) {
if (
e.which === KEY_CODES.COMMA ||
(!allowSpacesInTags && e.which === KEY_CODES.SPACE) ||
e.which === KEY_CODES.ENTER
) {
if (newTag.length > 0) {
if (this.addNewTag(newTag)) {
e.target.value = '';
Expand All @@ -104,9 +119,12 @@ export default Component.extend({
e.preventDefault();
}

[].forEach.call(this.element.querySelectorAll('.' + TAG_CLASS), function(tagEl) {
tagEl.classList.remove(REMOVE_CONFIRMATION_CLASS);
});
[].forEach.call(
this.element.querySelectorAll('.' + TAG_CLASS),
function (tagEl) {
tagEl.classList.remove(REMOVE_CONFIRMATION_CLASS);
}
);
}
}
},
Expand Down Expand Up @@ -143,8 +161,8 @@ export default Component.extend({

actions: {
removeTag(index) {
const removeTagAtIndex = this.get('removeTagAtIndex');
const removeTagAtIndex = this.removeTagAtIndex;
removeTagAtIndex(index);
}
}
});
}
15 changes: 1 addition & 14 deletions config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const getChannelURL = require('ember-source-channel-url');

module.exports = async function() {
module.exports = async function () {
return {
useYarn: true,
scenarios: [
Expand All @@ -21,19 +21,6 @@ module.exports = async function() {
'ember-source': await getChannelURL('release')
}
}
},
{
name: 'ember-default-with-jquery',
env: {
EMBER_OPTIONAL_FEATURES: JSON.stringify({
'jquery-integration': true
})
},
npm: {
devDependencies: {
'@ember/jquery': '^0.5.1'
}
}
}
]
};
Expand Down
4 changes: 2 additions & 2 deletions config/environment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

module.exports = function(env) {
module.exports = function (env) {
let ENV = {
APP: {}
};
Expand All @@ -10,4 +10,4 @@ module.exports = function(env) {
}

return ENV;
}
};
6 changes: 3 additions & 3 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ module.exports = function (defaults) {
return maybeEmbroider(app, {
skipBabel: [
{
package: 'qunit',
},
],
package: 'qunit'
}
]
});
};
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

module.exports = {
name: require('./package').name,
name: require('./package').name
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"ember-source-channel-url": "^3.0.0",
"ember-template-lint": "^4.3.0",
"ember-try": "^1.4.0",
"eslint": "^8.12.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-ember": "^10.5.9",
"eslint-plugin-node": "^11.1.0",
Expand Down
14 changes: 5 additions & 9 deletions testem.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
/*jshint node:true*/
module.exports = {
"framework": "qunit",
"test_page": "tests/index.html?hidepassed",
"disable_watching": true,
"launch_in_ci": [
"Chrome"
],
"launch_in_dev": [
"Chrome"
],
framework: 'qunit',
test_page: 'tests/index.html?hidepassed',
disable_watching: true,
launch_in_ci: ['Chrome'],
launch_in_dev: ['Chrome'],
browser_args: {
Chrome: [
'--disable-dev-shm-usage',
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@placeholder="Add a tag..."
@ariaLabel="Add a tag input field"
@addTag={{this.addTag}}
@removeTagAtIndex={{this.removeTag}}
@removeTagAtIndex={{this.removeTagAtIndex}}
@onKeyUp={{this.onKeyUp}}
as |tag|>
{{tag}}
Expand All @@ -22,7 +22,7 @@
@placeholder="Add a tag..."
@ariaLabel="Add a tag input field"
@addTag={{this.addTag}}
@removeTagAtIndex={{this.removeTag}}
@removeTagAtIndex={{this.removeTagAtIndex}}
@onKeyUp={{this.onKeyUp}}
@readOnly={{this.readOnly}}
as |tag|>
Expand Down
9 changes: 6 additions & 3 deletions tests/helpers/module-for-acceptance.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';
import { Promise } from 'rsvp';

export default function(name, options = {}) {
export default function (name, options = {}) {
module(name, {
beforeEach() {
this.application = startApp();
Expand All @@ -14,8 +14,11 @@ export default function(name, options = {}) {
},

afterEach() {
let afterEach = options.afterEach && options.afterEach.apply(this, arguments);
return Promise.resolve(afterEach).then(() => destroyApp(this.application));
let afterEach =
options.afterEach && options.afterEach.apply(this, arguments);
return Promise.resolve(afterEach).then(() =>
destroyApp(this.application)
);
}
});
}
Loading

0 comments on commit 8a5e42d

Please sign in to comment.