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

Add formatting to eslint #455

Merged
merged 3 commits into from Jul 14, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 16 additions & 21 deletions .eslintrc.js
Expand Up @@ -5,26 +5,21 @@ module.exports = {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true
}
legacyDecorators: true,
},
},
plugins: [
'ember'
],
plugins: ['ember'],
globals: {
"$": false,
"twttr": false,
"emojione": false
$: false,
twttr: false,
emojione: false,
},
extends: [
'eslint:recommended',
'plugin:ember/recommended'
],
extends: ['eslint:recommended', 'plugin:ember/recommended', 'plugin:prettier/recommended'],
env: {
browser: true
browser: true,
},
rules: {
'ember/no-jquery': 'error'
'ember/no-jquery': 'error',
},
overrides: [
// node files
Expand All @@ -37,23 +32,23 @@ module.exports = {
'blueprints/*/index.js',
'config/**/*.js',
'lib/*/index.js',
'server/**/*.js'
'server/**/*.js',
],
parserOptions: {
sourceType: 'script'
sourceType: 'script',
},
env: {
browser: false,
node: true
node: true,
},
plugins: ['node'],
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
// add your custom rules and overrides for node files here

// this can be removed once the following is fixed
// https://github.com/mysticatea/eslint-plugin-node/issues/77
'node/no-unpublished-require': 'off'
})
}
]
'node/no-unpublished-require': 'off',
}),
},
],
};
12 changes: 12 additions & 0 deletions .prettierrc
@@ -0,0 +1,12 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"printWidth": 120,
mcfiredrill marked this conversation as resolved.
Show resolved Hide resolved
"proseWrap": "preserve",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false,
"quoteProps": "as-needed"
}
4 changes: 2 additions & 2 deletions .template-lintrc.js
Expand Up @@ -3,6 +3,6 @@
module.exports = {
extends: 'octane',
rules: {
'no-bare-strings': true
}
'no-bare-strings': true,
},
};
4 changes: 2 additions & 2 deletions app/adapters/application.js
@@ -1,14 +1,14 @@
import ActiveModelAdapter from 'active-model-adapter';
/* eslint-disable ember/no-mixins */
import FastbootAdapter from 'ember-data-storefront/mixins/fastboot-adapter';
import ENV from "datafruits13/config/environment";
import ENV from 'datafruits13/config/environment';

export default class Application extends ActiveModelAdapter.extend(FastbootAdapter) {
host = ENV.API_HOST;

buildURL() {
var base;
base = super.buildURL.apply(this, arguments); //eslint-disable-line ember/no-ember-super-in-es-classes
return "" + base + ".json";
return '' + base + '.json';
}
}
6 changes: 4 additions & 2 deletions app/adapters/gif.js
Expand Up @@ -4,9 +4,11 @@ import JSONAPIAdapter from '@ember-data/adapter/json-api';
@classic
export default class Gif extends JSONAPIAdapter {
// https://api.giphy.com/v1/gifs/search?api_key=OJAyf3JHblNAu9hHhmccbPrH4wCN0pJQ&q=garfield&limit=25&offset=0&rating=G&lang=en
host = "https://api.giphy.com";
host = 'https://api.giphy.com';

urlForQuery(query) {
return `${this.urlPrefix()}/v1/gifs/search?api_key=OJAyf3JHblNAu9hHhmccbPrH4wCN0pJQ&q=${query.query}&limit=25&offset=0&rating=G&lang=en`;
return `${this.urlPrefix()}/v1/gifs/search?api_key=OJAyf3JHblNAu9hHhmccbPrH4wCN0pJQ&q=${
query.query
}&limit=25&offset=0&rating=G&lang=en`;
}
}
2 changes: 1 addition & 1 deletion app/adapters/scheduled-show.js
Expand Up @@ -4,7 +4,7 @@ import ApplicationAdapter from './application';
@classic
export default class ScheduledShow extends ApplicationAdapter {
urlForQueryRecord(query) {
if(query.next){
if (query.next) {
return `${this.urlPrefix()}/scheduled_shows/next`;
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/blog-post-preview.js
Expand Up @@ -13,7 +13,7 @@ export default class BlogPostPreview extends Component {
}).firstObject;
if (!body) {
body = this.post.blogPostBodies.filter((body) => {
return body.language == "en";
return body.language == 'en';
}).firstObject;
}
return body;
Expand Down
2 changes: 1 addition & 1 deletion app/components/blog-post.js
Expand Up @@ -13,7 +13,7 @@ export default class BlogPost extends Component {
}).firstObject;
if (!body) {
body = this.post.blogPostBodies.filter((body) => {
return body.language == "en";
return body.language == 'en';
}).firstObject;
}
return body;
Expand Down
4 changes: 2 additions & 2 deletions app/components/chat-lazy-image.js
@@ -1,14 +1,14 @@
import classic from 'ember-classic-decorator';
import { observes } from '@ember-decorators/object';
/* eslint ember/no-observers: 0 */
import LazyImage from 'ember-lazy-image/components/lazy-image'
import LazyImage from 'ember-lazy-image/components/lazy-image';
import '@ember/object';

@classic
export default class ChatLazyImage extends LazyImage {
@observes('loaded')
adjustScrollingIfImageLoaded() {
if(this.loaded === true){
if (this.loaded === true) {
this.adjustScrolling();
}
}
Expand Down
12 changes: 6 additions & 6 deletions app/components/chat-messages.js
Expand Up @@ -5,9 +5,9 @@ import Component from '@ember/component';
import { debounce } from '@ember/runloop';

@classic
@tagName("ul")
@tagName('ul')
export default class ChatMessages extends Component {
elementId = "messages";
elementId = 'messages';

touchMove() {
this.onScroll();
Expand All @@ -19,17 +19,17 @@ export default class ChatMessages extends Component {

@action
setupAutoscroll() {
if(this.scrolledToBottom()){
if (this.scrolledToBottom()) {
this.set('willAutoscroll', true);
}else{
} else {
this.newMessagesAvailable();
this.set('willAutoscroll', false);
}
}

@action
adjustScrolling() {
if(this.willAutoscroll){
if (this.willAutoscroll) {
const messages = document.getElementById('messages');
//$('#messages')[0].scrollTop = $('#messages')[0].scrollHeight;
messages.scrollTop = messages.scrollHeight;
Expand All @@ -43,7 +43,7 @@ export default class ChatMessages extends Component {
}

didInsertElement() {
this.element.addEventListener("scroll", () => {
this.element.addEventListener('scroll', () => {
debounce(this, this.onScroll, 500);
});
}
Expand Down
6 changes: 3 additions & 3 deletions app/components/container/datafruits-player.js
Expand Up @@ -6,11 +6,11 @@ export default class _DatafruitsPlayer extends DatafruitsPlayer {
track = null;

didInsertElement() {
if(this.track){
if (this.track) {
this.set('playingPodcast', true);
super.didInsertElement(...arguments);
this.playTrack();
}else{
} else {
super.didInsertElement(...arguments);
}
}
Expand All @@ -21,7 +21,7 @@ export default class _DatafruitsPlayer extends DatafruitsPlayer {
this.set('title', track.title);
this.set('playTime', 0.0);

let audioTag = document.getElementById("radio-player");
let audioTag = document.getElementById('radio-player');
audioTag.src = track.cdnUrl;
}
}
60 changes: 37 additions & 23 deletions app/components/datafruits-chat-input-message.js
Expand Up @@ -3,12 +3,12 @@ import { action } from '@ember/object';
import { tagName } from '@ember-decorators/component';
import { inject as service } from '@ember/service';
import { oneWay } from '@ember/object/computed';
import emojiStrategy from "../emojiStrategy";
import emojiStrategy from '../emojiStrategy';
import Component from '@ember/component';
import { Textcomplete, Textarea } from 'textcomplete';

@classic
@tagName("span")
@tagName('span')
export default class DatafruitsChatInputMessage extends Component {
@service
chat;
Expand All @@ -28,7 +28,7 @@ export default class DatafruitsChatInputMessage extends Component {
sendGif(gif) {
this.set('inputMessage', gif.url);
this.set('showingGifSearch', false);
this.element.querySelector("#send-message-button").focus();
this.element.querySelector('#send-message-button').focus();
}

@action
Expand All @@ -39,60 +39,74 @@ export default class DatafruitsChatInputMessage extends Component {
@action
sendMessage() {
const message = this.inputMessage;
if(message){
this.chat.push("new:msg", { user: this.username, body: message, timestamp: Date.now() });
if (message) {
this.chat.push('new:msg', { user: this.username, body: message, timestamp: Date.now() });
this.set('inputMessage', '');
}
}

didInsertElement() {
let emojiComplete = {
id: "emojis",
id: 'emojis',
//match: /\B:([\-+\w]*)$/,
match: /(^|\s):([a-z0-9+\-_]*)$/,

search: function (term, callback) {
var results = [];
var results2 = [];
var results3 = [];
for(let [shortname, data] of Object.entries(emojiStrategy)) {
if(shortname.indexOf(term) > -1) { results.push(shortname); }
else {
if((data.aliases !== null) && (data.aliases.indexOf(term) > -1)) {
for (let [shortname, data] of Object.entries(emojiStrategy)) {
if (shortname.indexOf(term) > -1) {
results.push(shortname);
} else {
if (data.aliases !== null && data.aliases.indexOf(term) > -1) {
results2.push(shortname);
}
else if((data.keywords !== null) && (data.keywords.indexOf(term) > -1)) {
} else if (data.keywords !== null && data.keywords.indexOf(term) > -1) {
results3.push(shortname);
}
}
}
if(term.length >= 3) {
results.sort(function(a,b) { return (a.length > b.length); });
results2.sort(function(a,b) { return (a.length > b.length); });
if (term.length >= 3) {
results.sort(function (a, b) {
return a.length > b.length;
});
results2.sort(function (a, b) {
return a.length > b.length;
});
results3.sort();
}
var newResults = results.concat(results2).concat(results3);

callback(newResults);
},
template: function (shortname) {
if(emojiStrategy[shortname].custom){
return '<img class="emojione" src="/assets/images/emojis/'+emojiStrategy[shortname].unicode+'.png"> '+shortname;
}else{
return '<img class="emojione" src="//cdn.jsdelivr.net/emojione/assets/4.0/png/32/'+emojiStrategy[shortname].unicode+'.png"> '+shortname;
if (emojiStrategy[shortname].custom) {
return (
'<img class="emojione" src="/assets/images/emojis/' +
emojiStrategy[shortname].unicode +
'.png"> ' +
shortname
);
} else {
return (
'<img class="emojione" src="//cdn.jsdelivr.net/emojione/assets/4.0/png/32/' +
emojiStrategy[shortname].unicode +
'.png"> ' +
shortname
);
}
},
replace: function (shortname) {
return shortname;
},
};
let usernameComplete = {
id: "usernames",
id: 'usernames',
match: /(^|\s)(\w{2,})$/,
search: (term, callback) => {
let matches;
matches = this.joinedUsers.filter((word) => {
return (word.indexOf(term) === 0) && (word !== this.username);
return word.indexOf(term) === 0 && word !== this.username;
});
callback(matches);
},
Expand All @@ -104,8 +118,8 @@ export default class DatafruitsChatInputMessage extends Component {
let emojiTextcomplete = new Textcomplete(editor, {
dropdown: {
maxCount: 25,
placement: 'top'
}
placement: 'top',
},
});
emojiTextcomplete.register([emojiComplete, usernameComplete]);
}
Expand Down