Skip to content

Commit

Permalink
build: bump eslint to 7.28.0
Browse files Browse the repository at this point in the history
- switch from babel-eslint to babel/eslint-parser
- switch from eslint-loader to eslint-webpack-plugin
- fix various new linting errors
  • Loading branch information
bastimeyer committed Jun 9, 2021
1 parent efb0f0e commit 90ca211
Show file tree
Hide file tree
Showing 13 changed files with 420 additions and 491 deletions.
12 changes: 7 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

"extends": "eslint:recommended",

"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"parserOptions": {
"requireConfigFile": false,
"ecmaVersion": 2017,
"ecmaFeatures": {
"legacyDecorators": true
Expand All @@ -19,9 +20,7 @@
"browser": true
},

"globals": {
"DEBUG": true
},
"globals": {},

"rules": {
"no-empty": "off",
Expand Down Expand Up @@ -54,6 +53,7 @@
"semi": "error",
"no-sequences": "error",
"no-var": "error",
"no-redeclare": [ "error", { "builtinGlobals": true } ],
"no-useless-escape": "off",
"quotes": [ "error", "double" ],
"prefer-template": "error",
Expand All @@ -70,6 +70,8 @@
"capIsNew": false,
"properties": false
}],
"new-parens": "error"
"new-parens": "error",

"no-console": "error"
}
}
17 changes: 7 additions & 10 deletions build/tasks/webpack/configurators/code-quality.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
const { pRoot } = require( "../paths" );

const ESLintWebpackPlugin = require( "eslint-webpack-plugin" );


/**
* Code quality related configurations
*/
module.exports = {
common( config ) {
// eslint loader
config.module.rules.unshift({
enforce: "pre",
test: /\.js$/,
include: pRoot,
loader: "eslint-loader",
options: {
failOnError: true
}
});
config.plugins.push( new ESLintWebpackPlugin({
context: pRoot,
emitError: true,
failOnError: true
}) );
}
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
},
"devDependencies": {
"@babel/core": "7.14.3",
"@babel/eslint-parser": "7.14.4",
"@babel/plugin-proposal-class-properties": "7.13.0",
"@babel/plugin-proposal-decorators": "7.14.2",
"@babel/plugin-transform-block-scoping": "7.14.4",
Expand All @@ -43,7 +44,6 @@
"@ember/test-helpers": "0.7.27",
"@ember-decorators/argument": "0.8.21",
"@glimmer/syntax": "0.47.4",
"babel-eslint": "10.0.1",
"babel-loader": "8.0.5",
"babel-plugin-debug-macros": "0.2.0",
"babel-plugin-ember-modules-api-polyfill": "2.6.0",
Expand All @@ -58,8 +58,8 @@
"ember-compatibility-helpers": "1.0.2",
"ember-decorators": "2.5.1",
"ember-qunit": "3.5.1",
"eslint": "5.16.0",
"eslint-loader": "3.0.3",
"eslint": "7.28.0",
"eslint-webpack-plugin": "2.5.4",
"file-loader": "1.1.11",
"grunt": "1.4.0",
"grunt-cli": "1.4.2",
Expand Down
4 changes: 3 additions & 1 deletion src/app/data/models/-mixins/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import fetch from "fetch";
const reURL = /^[a-z]+:\/\/([\w.]+)\/(.+)$/i;
const reURLFragment = /^:(\w+)$/;

const { hasOwnProperty } = {};


/**
* Adapter mixin for using static model names
Expand Down Expand Up @@ -152,7 +154,7 @@ export default Mixin.create( Evented, {
idFound = true;
}

if ( urlFragments.hasOwnProperty( key ) ) {
if ( hasOwnProperty.call( urlFragments, key ) ) {
return urlFragments[ key ].call( this, type, id, data );
}

Expand Down
5 changes: 4 additions & 1 deletion src/app/data/models/search/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import attr from "ember-data/attr";
import Model from "ember-data/model";


const { hasOwnProperty } = {};


export default Model.extend({
query : attr( "string" ),
filter: attr( "string" ),
Expand Down Expand Up @@ -32,7 +35,7 @@ export default Model.extend({

getLabel( filter ) {
const map = get( this, "filtersmap" );
return map.hasOwnProperty( filter )
return hasOwnProperty.call( map, filter )
? map[ filter ].label
: "All";
}
Expand Down
4 changes: 3 additions & 1 deletion src/app/data/models/stream/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import qualities from "./-qualities";

const { "stream-url": twitchStreamUrl } = twitchConfig;

const { hasOwnProperty } = {};


const STATUS_PREPARING = 0;
const STATUS_ABORTED = 1;
Expand Down Expand Up @@ -44,7 +46,7 @@ function cpQualityFromPresetOrCustomValue( key ) {
const { id, [ key ]: defaultValue } = this.streamQualityPreset;
const custom = this.settings.content.streaming.qualities.toJSON();

if ( custom.hasOwnProperty( id ) ) {
if ( hasOwnProperty.call( custom, id ) ) {
const customValue = String( custom[ id ][ key ] || "" ).trim();
if ( customValue.length ) {
return customValue;
Expand Down
6 changes: 4 additions & 2 deletions src/app/services/notification/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { logDebug } from "./logger";
import providers from "./providers";


const { hasOwnProperty } = {};

/** @type {Map<string,NotificationProvider>} */
const instanceMap = new Map();
/** @type {Map<string,Promise>} */
Expand All @@ -14,7 +16,7 @@ const setupMap = new Map();
* @returns {boolean}
*/
export function isSupported( provider ) {
return providers.hasOwnProperty( provider )
return hasOwnProperty.call( providers, provider )
? providers[ provider ].isSupported()
: false;
}
Expand All @@ -29,7 +31,7 @@ export function isSupported( provider ) {
* @returns {Promise}
*/
export async function showNotification( provider, data, newInst ) {
if ( !providers.hasOwnProperty( provider ) ) {
if ( !hasOwnProperty.call( providers, provider ) ) {
throw new Error( "Invalid notification provider" );
}

Expand Down
1 change: 1 addition & 0 deletions src/app/ui/routes/error/route.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global DEBUG */
import { get, set, getProperties } from "@ember/object";
import Route from "@ember/routing/route";
import { inject as service } from "@ember/service";
Expand Down
5 changes: 3 additions & 2 deletions src/app/utils/node/fs/whichFallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { stat, isExecutable } from "utils/node/fs/stat";
import { join } from "path";


const { hasOwnProperty } = {};
const { isArray } = Array;


Expand All @@ -30,7 +31,7 @@ async function whichFallback( exec, fallback, check, fallbackOnly ) {
}

// get executables for current platform
if ( exec.hasOwnProperty( platform ) ) {
if ( hasOwnProperty.call( exec, platform ) ) {
exec = exec[ platform ];
}

Expand Down Expand Up @@ -63,7 +64,7 @@ async function whichFallback( exec, fallback, check, fallbackOnly ) {
}

// get fallbacks for current platform
if ( fallback.hasOwnProperty( platform ) ) {
if ( hasOwnProperty.call( fallback, platform ) ) {
fallback = fallback[ platform ];
}

Expand Down
1 change: 0 additions & 1 deletion src/test/tests/ui/components/button/-follow-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ module( "ui/components/button/-follow-button", function( hooks ) {
},
set( value ) {
testContext.timeout = value;
return value;
}
});
this.owner.register( "component:follow-button", Subject );
Expand Down
1 change: 0 additions & 1 deletion src/test/tests/ui/components/form/drop-down-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ module( "ui/components/form/drop-down-list", function( hooks ) {
},
set( value ) {
testContext.clickListener = value;
return value;
}
});
this.owner.register( "component:drop-down-list", Subject );
Expand Down
14 changes: 6 additions & 8 deletions src/test/tests/ui/components/preview-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ module( "ui/components/preview-image", function( hooks ) {


test( "Valid image source", async function( assert ) {
await new Promise( async ( resolve, reject ) => {
await new Promise( ( resolve, reject ) => {
this.setProperties({
src: transparentImage,
title: "bar",
onLoad: resolve,
onError: reject
});
await render( hbs`
{{preview-image src=src title=title onLoad=onLoad onError=onError}}
` );
render( hbs`{{preview-image src=src title=title onLoad=onLoad onError=onError}}` )
.catch( reject );
});

assert.ok(
Expand All @@ -49,17 +48,16 @@ module( "ui/components/preview-image", function( hooks ) {


test( "Invalid image source", async function( assert ) {
await new Promise( async ( resolve, reject ) => {
await new Promise( ( resolve, reject ) => {
this.setProperties({
// using the page's URL as image src will cause the onerror event to be triggered
src: document.location.href,
title: "bar",
onLoad: reject,
onError: resolve
});
await render( hbs`
{{preview-image src=src title=title onLoad=onLoad onError=onError}}
` );
render( hbs`{{preview-image src=src title=title onLoad=onLoad onError=onError}}` )
.catch( reject );
});

assert.notOk(
Expand Down
Loading

0 comments on commit 90ca211

Please sign in to comment.