Browse Source

Fix all linting issues

pull/1378/head
Samuel Attard 6 years ago
parent
commit
1e6d9e15bf
  1. 2
      .eslintrc
  2. 7
      gulpfile.babel.js
  3. 5
      src/inject/.eslintrc
  4. 1
      src/inject/GPMWebView/interface/errorHandler.js
  5. 2
      src/inject/generic/index.js
  6. 2
      src/inject/lastFM.js
  7. 4
      src/main/configureBrowser.js
  8. 1
      src/main/features/core/keyboardShortcuts.js
  9. 12
      src/main/features/core/tray.js
  10. 1
      src/main/features/index.js
  11. 2
      src/main/features/win32/notificationPolyfill.js
  12. 2
      src/main/utils/PlaybackAPI.js
  13. 2
      src/main/utils/Settings.js
  14. 0
      test/.eslintrc
  15. 6
      test/electron/jsonCreator_spec.js
  16. 4
      test/electron/lyrics/_lyricsSource_spec.js
  17. 18
      test/electron/lyrics/lyrics_spec.js
  18. 8
      test/electron/settings_spec.js
  19. 6
      test/electron/translations_spec.js
  20. 9
      test/electron/webSocketAPI_spec.js

2
.eslintrc

@ -15,7 +15,9 @@
},
"rules": {
"max-len": [1, 120],
"import/no-extraneous-dependencies": 0,
"import/no-unresolved": 0,
"import/prefer-default-export": 0,
"global-require": 0,
"no-underscore-dangle": 0,
"consistent-return": 0

7
gulpfile.babel.js

@ -10,6 +10,7 @@ import cssmin from 'gulp-cssmin';
import { createWindowsInstaller as electronInstaller } from 'electron-winstaller';
import fs from 'fs';
import header from 'gulp-header';
import lec from 'gulp-line-ending-corrector';
import less from 'gulp-less';
import packager from 'electron-packager';
import nodePath from 'path';
@ -137,6 +138,12 @@ const cleanGlob = (glob) => {
};
};
gulp.task('fix-eol', () =>
gulp.src('src/**/*.js')
.pipe(lec({verbose:true, eolc: 'LF', encoding:'utf8'}))
.pipe(gulp.dest('src'))
)
gulp.task('clean', cleanGlob(['./build', './dist']));
gulp.task('clean-dist-win', cleanGlob(`./dist/${packageJSON.productName}-win32-ia32`));
gulp.task('clean-dist-darwin', cleanGlob(`./dist/${packageJSON.productName}-darwin-ia32`));

5
src/inject/.eslintrc

@ -0,0 +1,5 @@
{
"env": {
"browser": true
}
}

1
src/inject/GPMWebView/interface/errorHandler.js

@ -21,6 +21,7 @@ ${details.error.stack.length > 1200 ? '%0A...Some of the stack is missing' : ''}
\`\`\`
%0A
This issue was created automatically inside the \`uncaughtException\` handler`;
remote.shell.openExternal(`https://github.com/MarshallOfSound/Google-Play-Music-Desktop-Player-UNOFFICIAL-/issues/new?title=${title}&body=${body}`); // eslint-disable-line
toast.hide();
buttonEvent.preventDefault();

2
src/inject/generic/index.js

@ -2,6 +2,7 @@ import '../rendererEmitter';
import './core';
import SettingsController from '../../main/utils/Settings';
if (process.env.TEST_SPEC) {
global.Settings = new SettingsController('.test', true);
} else {
@ -14,6 +15,7 @@ require(`./${process.platform}`);
document.addEventListener('DOMContentLoaded', () => {
require('./windowThemeHandler');
require('./translations');
setTimeout(() => require('electron').remote.getCurrentWindow().show(), 100);
const nativeFrameAtLaunch = Settings.get('nativeFrame');

2
src/inject/lastFM.js

@ -1,6 +1,6 @@
import { remote } from 'electron';
import './rendererEmitter';
import './generic/translations';
import { remote } from 'electron';
let warnOnce = true;

4
src/main/configureBrowser.js

@ -3,8 +3,8 @@ import path from 'path';
export default () => {
const screenSize = screen.getPrimaryDisplay().workAreaSize;
const defaultHeight = screenSize.height * 3 / 4;
const defaultWidth = screenSize.width * 3 / 4;
const defaultHeight = (screenSize.height * 3) / 4;
const defaultWidth = (screenSize.width * 3) / 4;
const baseConfig = {

1
src/main/features/core/keyboardShortcuts.js

@ -5,6 +5,7 @@ import { globalShortcut } from 'electron';
let keyRegisterFn = (...args) => globalShortcut.register(...args);
if (process.platform === 'win32') {
const hook = require('ll-keyboard-hook-win');
keyRegisterFn = (key, fn) => {
hook.on('down', key, fn);
};

12
src/main/features/core/tray.js

@ -15,14 +15,12 @@ let audioDeviceMenu = [
if (process.platform === 'darwin') {
appIcon = new Tray(path.resolve(`${__dirname}/../../../assets/img/macTemplate.png`));
} else if (WindowManager.getWindowManagerGDMName() === 'kde-plasma') {
// TODO: Change this back to ico when electron supports it on linux
// appIcon = new Tray(path.resolve(`${__dirname}/../../../assets/img/main.ico`));
appIcon = new Tray(path.resolve(`${__dirname}/../../../assets/img/main_tray.png`));
} else {
if (WindowManager.getWindowManagerGDMName() === 'kde-plasma') {
// TODO: Change this back to ico when electron supports it on linux
// appIcon = new Tray(path.resolve(`${__dirname}/../../../assets/img/main.ico`));
appIcon = new Tray(path.resolve(`${__dirname}/../../../assets/img/main_tray.png`));
} else {
appIcon = new Tray(path.resolve(`${__dirname}/../../../assets/img/main_tray.png`));
}
appIcon = new Tray(path.resolve(`${__dirname}/../../../assets/img/main_tray.png`));
}
const setContextMenu = () => {

1
src/main/features/index.js

@ -1,2 +1,3 @@
import './core';
require(`./${process.platform}`);

2
src/main/features/win32/notificationPolyfill.js

@ -29,7 +29,7 @@ class Notification {
const windowID = WindowManager.add(this.window, 'notify');
Emitter.executeOnWindow(windowID, (opts) => {
window.NOTIFY_DATA = opts;
window.NOTIFY_DATA = opts; // eslint-disable-line
}, this.options);
setTimeout(() => {

2
src/main/utils/PlaybackAPI.js

@ -1,6 +1,6 @@
import _ from 'lodash';
import fs from 'fs';
import createJSON from './_jsonCreator';
import _ from 'lodash';
class PlaybackAPI {
constructor() {

2
src/main/utils/Settings.js

@ -64,7 +64,7 @@ class Settings {
}
_save(force) {
const now = (new Date).getTime();
const now = (new Date()).getTime();
// During some save events (like resize) we need to queue the disk writes
// so that we don't blast the disk every millisecond
if ((now - this.lastSync > 250 || force)) {

0
test/spectron/.eslintrc → test/.eslintrc

6
test/electron/jsonCreator_spec.js

@ -6,12 +6,12 @@ import mkdirp from 'mkdirp';
import os from 'os';
import path from 'path';
chai.use(chaiFs);
chai.should();
// Actual Test Imports
import jsonCreator from '../../build/main/utils/_jsonCreator';
chai.use(chaiFs);
chai.should();
describe('JSONCreator', () => {
it('should return a valid path', () => {
const jsonPath = jsonCreator('test');

4
test/electron/lyrics/_lyricsSource_spec.js

@ -2,11 +2,11 @@
import chai from 'chai';
import { givenAsync } from 'mocha-testdata';
chai.should();
// Actual Test Imports
import { validSongs, invalidSongs } from '../testdata/lyrics';
chai.should();
export default (source, format, name, timeout) => {
describe(`with the ${name} Source`, function lyricsSourceTestScope() {
if (timeout) {

18
test/electron/lyrics/lyrics_spec.js

@ -2,21 +2,21 @@
import chai from 'chai';
import { givenAsync } from 'mocha-testdata';
chai.should();
import attemptLyricsWikia from '../../../build/main/features/core/lyrics/source_lyricsWikia';
import attemptMetroLyrics from '../../../build/main/features/core/lyrics/source_metroLyrics';
// Mock expected globals
global.PlaybackAPI = {
on: () => {},
};
import lyricsSourceSpec from './_lyricsSource_spec';
import { validSongs, invalidSongs } from '../testdata/lyrics';
// Actual Test Imports
const resolveLyrics = require('../../../build/main/features/core/lyrics').resolveLyrics;
import attemptLyricsWikia from '../../../build/main/features/core/lyrics/source_lyricsWikia';
import attemptMetroLyrics from '../../../build/main/features/core/lyrics/source_metroLyrics';
chai.should();
import lyricsSourceSpec from './_lyricsSource_spec';
import { validSongs, invalidSongs } from '../testdata/lyrics';
// Mock expected globals
global.PlaybackAPI = {
on: () => {},
};
describe('Lyrics Resolver', () => {
givenAsync(...validSongs).it('should resolve when given a valid song object', (done, song) => {

8
test/electron/settings_spec.js

@ -2,14 +2,14 @@
import chai from 'chai';
import chaiFs from 'chai-fs';
const expect = chai.expect;
// Actual Test Imports
import Settings from '../../build/main/utils/Settings';
import initialSettings from '../../build/main/utils/_initialSettings';
const expect = chai.expect;
chai.use(chaiFs);
chai.should();
// Actual Test Imports
import Settings from '../../build/main/utils/Settings';
import initialSettings from '../../build/main/utils/_initialSettings';
describe('Settings', () => {
let settings;

6
test/electron/translations_spec.js

@ -4,12 +4,12 @@ import chaiFs from 'chai-fs';
import fs from 'fs';
import path from 'path';
chai.use(chaiFs);
chai.should();
// Actual Test Imports
import TranslationProvider from '../../build/_locales/_provider';
chai.use(chaiFs);
chai.should();
describe('Translations', () => {
let provider;

9
test/electron/webSocketAPI_spec.js

@ -4,15 +4,14 @@ import chaiSinon from 'sinon-chai';
import sinon from 'sinon';
import WebSocket from 'ws';
const expect = chai.expect;
chai.use(chaiSinon);
chai.should();
// Test Classes
import Emitter from '../../build/main/utils/Emitter';
import PlaybackAPI from '../../build/main/utils/PlaybackAPI';
const expect = chai.expect;
chai.use(chaiSinon);
chai.should();
// Moch the required Settings API
global.Settings = {
get: (key, def) => {

Loading…
Cancel
Save