From ed6aefbe9cae8ec95840091fcd47f86344121ac9 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Wed, 18 Nov 2020 12:12:30 -0500 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20setup=20linting=20and?= =?UTF-8?q?=20testing=20in=20core=20addon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/core/config/ember-try.js | 86 +++++++++---------- addons/core/config/environment.js | 6 +- addons/core/ember-cli-build.js | 6 +- addons/core/index.js | 4 +- addons/core/package.json | 6 +- addons/core/testem.js | 32 +++---- addons/core/tests/dummy/app/app.js | 8 +- addons/core/tests/dummy/app/formats.js | 22 ++--- addons/core/tests/dummy/app/router.js | 7 +- addons/core/tests/dummy/config/ember-intl.js | 6 +- addons/core/tests/dummy/config/environment.js | 26 +++--- addons/core/tests/dummy/config/targets.js | 14 +-- addons/core/tests/test-helper.js | 8 +- package.json | 2 + 14 files changed, 116 insertions(+), 117 deletions(-) diff --git a/addons/core/config/ember-try.js b/addons/core/config/ember-try.js index bf87e0bd7..bbdb66252 100644 --- a/addons/core/config/ember-try.js +++ b/addons/core/config/ember-try.js @@ -1,87 +1,87 @@ -'use strict'; +"use strict"; -const getChannelURL = require('ember-source-channel-url'); +const getChannelURL = require("ember-source-channel-url"); -module.exports = async function() { +module.exports = async function () { return { useYarn: true, scenarios: [ { - name: 'ember-lts-3.12', + name: "ember-lts-3.12", npm: { devDependencies: { - 'ember-source': '~3.12.0' - } - } + "ember-source": "~3.12.0", + }, + }, }, { - name: 'ember-lts-3.16', + name: "ember-lts-3.16", npm: { devDependencies: { - 'ember-source': '~3.16.0' - } - } + "ember-source": "~3.16.0", + }, + }, }, { - name: 'ember-lts-3.20', + name: "ember-lts-3.20", npm: { devDependencies: { - 'ember-source': '~3.20.5' - } - } + "ember-source": "~3.20.5", + }, + }, }, { - name: 'ember-release', + name: "ember-release", npm: { devDependencies: { - 'ember-source': await getChannelURL('release') - } - } + "ember-source": await getChannelURL("release"), + }, + }, }, { - name: 'ember-beta', + name: "ember-beta", npm: { devDependencies: { - 'ember-source': await getChannelURL('beta') - } - } + "ember-source": await getChannelURL("beta"), + }, + }, }, { - name: 'ember-canary', + name: "ember-canary", npm: { devDependencies: { - 'ember-source': await getChannelURL('canary') - } - } + "ember-source": await getChannelURL("canary"), + }, + }, }, { - name: 'ember-default-with-jquery', + name: "ember-default-with-jquery", env: { EMBER_OPTIONAL_FEATURES: JSON.stringify({ - 'jquery-integration': true - }) + "jquery-integration": true, + }), }, npm: { devDependencies: { - '@ember/jquery': '^1.1.0' - } - } + "@ember/jquery": "^1.1.0", + }, + }, }, { - name: 'ember-classic', + name: "ember-classic", env: { EMBER_OPTIONAL_FEATURES: JSON.stringify({ - 'application-template-wrapper': true, - 'default-async-observers': false, - 'template-only-glimmer-components': false - }) + "application-template-wrapper": true, + "default-async-observers": false, + "template-only-glimmer-components": false, + }), }, npm: { ember: { - edition: 'classic' - } - } - } - ] + edition: "classic", + }, + }, + }, + ], }; }; diff --git a/addons/core/config/environment.js b/addons/core/config/environment.js index 0dfaed472..b7238585e 100644 --- a/addons/core/config/environment.js +++ b/addons/core/config/environment.js @@ -1,5 +1,5 @@ -'use strict'; +"use strict"; -module.exports = function(/* environment, appConfig */) { - return { }; +module.exports = function (/* environment, appConfig */) { + return {}; }; diff --git a/addons/core/ember-cli-build.js b/addons/core/ember-cli-build.js index dc5a39e1b..b6a8f26a0 100644 --- a/addons/core/ember-cli-build.js +++ b/addons/core/ember-cli-build.js @@ -1,8 +1,8 @@ -'use strict'; +"use strict"; -const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); +const EmberAddon = require("ember-cli/lib/broccoli/ember-addon"); -module.exports = function(defaults) { +module.exports = function (defaults) { let app = new EmberAddon(defaults, { // Add options here }); diff --git a/addons/core/index.js b/addons/core/index.js index 202492d5e..245249bda 100644 --- a/addons/core/index.js +++ b/addons/core/index.js @@ -1,4 +1,4 @@ -'use strict'; +"use strict"; module.exports = { - name: require('./package').name + name: require("./package").name, }; diff --git a/addons/core/package.json b/addons/core/package.json index b0a14af02..3523bc223 100644 --- a/addons/core/package.json +++ b/addons/core/package.json @@ -17,9 +17,10 @@ "lint": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*", "lint:hbs": "ember-template-lint .", "lint:js": "eslint .", + "format": "npm run format:js", + "format:js": "prettier --write '{addon,app,config,stories,tests}/**/*.js' *.js", "start": "ember serve", - "test": "npm-run-all lint:* test:*", - "test:ember": "ember test", + "test": "ember test", "test:ember-compatibility": "ember try:each" }, "dependencies": { @@ -54,6 +55,7 @@ "eslint-plugin-node": "^11.1.0", "loader.js": "^4.7.0", "npm-run-all": "^4.1.5", + "prettier": "^2.1.2", "qunit-dom": "^1.2.0" }, "engines": { diff --git a/addons/core/testem.js b/addons/core/testem.js index 49f53feed..e3e8564ff 100644 --- a/addons/core/testem.js +++ b/addons/core/testem.js @@ -1,27 +1,23 @@ -'use strict'; +"use strict"; module.exports = { - test_page: 'tests/index.html?hidepassed', + test_page: "tests/index.html?hidepassed", disable_watching: true, - launch_in_ci: [ - 'Chrome' - ], - launch_in_dev: [ - 'Chrome' - ], + launch_in_ci: ["Chrome"], + launch_in_dev: ["Chrome"], browser_start_timeout: 120, browser_args: { Chrome: { ci: [ // --no-sandbox is needed when running Chrome inside a container - process.env.CI ? '--no-sandbox' : null, - '--headless', - '--disable-dev-shm-usage', - '--disable-software-rasterizer', - '--mute-audio', - '--remote-debugging-port=0', - '--window-size=1440,900' - ].filter(Boolean) - } - } + process.env.CI ? "--no-sandbox" : null, + "--headless", + "--disable-dev-shm-usage", + "--disable-software-rasterizer", + "--mute-audio", + "--remote-debugging-port=0", + "--window-size=1440,900", + ].filter(Boolean), + }, + }, }; diff --git a/addons/core/tests/dummy/app/app.js b/addons/core/tests/dummy/app/app.js index 523bad60c..2ae212dbd 100644 --- a/addons/core/tests/dummy/app/app.js +++ b/addons/core/tests/dummy/app/app.js @@ -1,7 +1,7 @@ -import Application from '@ember/application'; -import Resolver from 'ember-resolver'; -import loadInitializers from 'ember-load-initializers'; -import config from 'dummy/config/environment'; +import Application from "@ember/application"; +import Resolver from "ember-resolver"; +import loadInitializers from "ember-load-initializers"; +import config from "dummy/config/environment"; export default class App extends Application { modulePrefix = config.modulePrefix; diff --git a/addons/core/tests/dummy/app/formats.js b/addons/core/tests/dummy/app/formats.js index f5d1f1502..4a4add42f 100644 --- a/addons/core/tests/dummy/app/formats.js +++ b/addons/core/tests/dummy/app/formats.js @@ -1,29 +1,29 @@ export default { time: { hhmmss: { - hour: 'numeric', - minute: 'numeric', - second: 'numeric', + hour: "numeric", + minute: "numeric", + second: "numeric", }, }, date: { hhmmss: { - hour: 'numeric', - minute: 'numeric', - second: 'numeric', + hour: "numeric", + minute: "numeric", + second: "numeric", }, }, number: { - compact: { notation: 'compact' }, + compact: { notation: "compact" }, EUR: { - style: 'currency', - currency: 'EUR', + style: "currency", + currency: "EUR", minimumFractionDigits: 2, maximumFractionDigits: 2, }, USD: { - style: 'currency', - currency: 'USD', + style: "currency", + currency: "USD", minimumFractionDigits: 2, maximumFractionDigits: 2, }, diff --git a/addons/core/tests/dummy/app/router.js b/addons/core/tests/dummy/app/router.js index bdf0187b9..018b4b1ca 100644 --- a/addons/core/tests/dummy/app/router.js +++ b/addons/core/tests/dummy/app/router.js @@ -1,10 +1,9 @@ -import EmberRouter from '@ember/routing/router'; -import config from 'dummy/config/environment'; +import EmberRouter from "@ember/routing/router"; +import config from "dummy/config/environment"; export default class Router extends EmberRouter { location = config.locationType; rootURL = config.rootURL; } -Router.map(function() { -}); +Router.map(function () {}); diff --git a/addons/core/tests/dummy/config/ember-intl.js b/addons/core/tests/dummy/config/ember-intl.js index 2e1bc33b6..2cb1c38c1 100644 --- a/addons/core/tests/dummy/config/ember-intl.js +++ b/addons/core/tests/dummy/config/ember-intl.js @@ -1,6 +1,6 @@ /* jshint node:true */ -module.exports = function(/* environment */) { +module.exports = function (/* environment */) { return { /** * Merges the fallback locale's translations into all other locales as a @@ -25,7 +25,7 @@ module.exports = function(/* environment */) { * @type {String} * @default "'translations'" */ - inputPath: 'translations', + inputPath: "translations", /** * Prevents the translations from being bundled with the application code. @@ -90,6 +90,6 @@ module.exports = function(/* environment */) { */ requiresTranslation(/* key, locale */) { return true; - } + }, }; }; diff --git a/addons/core/tests/dummy/config/environment.js b/addons/core/tests/dummy/config/environment.js index 9f2393692..f0a6c3b29 100644 --- a/addons/core/tests/dummy/config/environment.js +++ b/addons/core/tests/dummy/config/environment.js @@ -1,11 +1,11 @@ -'use strict'; +"use strict"; -module.exports = function(environment) { +module.exports = function (environment) { let ENV = { - modulePrefix: 'dummy', + modulePrefix: "dummy", environment, - rootURL: '/', - locationType: 'auto', + rootURL: "/", + locationType: "auto", EmberENV: { FEATURES: { // Here you can enable experimental features on an ember canary build @@ -13,17 +13,17 @@ module.exports = function(environment) { }, EXTEND_PROTOTYPES: { // Prevent Ember Data from overriding Date.parse. - Date: false - } + Date: false, + }, }, APP: { // Here you can pass flags/options to your application instance // when it is created - } + }, }; - if (environment === 'development') { + if (environment === "development") { // ENV.APP.LOG_RESOLVER = true; // ENV.APP.LOG_ACTIVE_GENERATION = true; // ENV.APP.LOG_TRANSITIONS = true; @@ -31,19 +31,19 @@ module.exports = function(environment) { // ENV.APP.LOG_VIEW_LOOKUPS = true; } - if (environment === 'test') { + if (environment === "test") { // Testem prefers this... - ENV.locationType = 'none'; + ENV.locationType = "none"; // keep test console output quieter ENV.APP.LOG_ACTIVE_GENERATION = false; ENV.APP.LOG_VIEW_LOOKUPS = false; - ENV.APP.rootElement = '#ember-testing'; + ENV.APP.rootElement = "#ember-testing"; ENV.APP.autoboot = false; } - if (environment === 'production') { + if (environment === "production") { // here you can enable a production-specific feature } diff --git a/addons/core/tests/dummy/config/targets.js b/addons/core/tests/dummy/config/targets.js index 228a07898..9a022efa9 100644 --- a/addons/core/tests/dummy/config/targets.js +++ b/addons/core/tests/dummy/config/targets.js @@ -1,18 +1,18 @@ -'use strict'; +"use strict"; const browsers = [ - 'last 1 Chrome versions', - 'last 1 Firefox versions', - 'last 1 Safari versions' + "last 1 Chrome versions", + "last 1 Firefox versions", + "last 1 Safari versions", ]; const isCI = Boolean(process.env.CI); -const isProduction = process.env.EMBER_ENV === 'production'; +const isProduction = process.env.EMBER_ENV === "production"; if (isCI || isProduction) { - browsers.push('ie 11'); + browsers.push("ie 11"); } module.exports = { - browsers + browsers, }; diff --git a/addons/core/tests/test-helper.js b/addons/core/tests/test-helper.js index 4eae06f81..d71607e7e 100644 --- a/addons/core/tests/test-helper.js +++ b/addons/core/tests/test-helper.js @@ -1,7 +1,7 @@ -import Application from 'dummy/app'; -import config from 'dummy/config/environment'; -import { setApplication } from '@ember/test-helpers'; -import { start } from 'ember-qunit'; +import Application from "dummy/app"; +import config from "dummy/config/environment"; +import { setApplication } from "@ember/test-helpers"; +import { start } from "ember-qunit"; setApplication(Application.create(config.APP)); diff --git a/package.json b/package.json index 571c7f40e..7bbdf203a 100644 --- a/package.json +++ b/package.json @@ -22,12 +22,14 @@ "lint": "npm-run-all lint:*", "lint:addons-api": "cd addons/api && yarn lint", "lint:addons-auth": "cd addons/auth && yarn lint", + "lint:addons-core": "cd addons/core && yarn lint", "lint:addons-rose": "cd addons/rose && yarn lint", "lint:ui-admin": "cd ui/admin && yarn lint", "lint:ui-desktop": "cd ui/desktop && yarn lint", "test": "npm-run-all test:*", "test:addons-api": "cd addons/api && yarn test", "test:addons-auth": "cd addons/auth && yarn test", + "test:addons-core": "cd addons/core && yarn test", "test:addons-rose": "cd addons/rose && yarn test", "test:ui-admin": "cd ui/admin && yarn test", "test:ui-desktop": "cd ui/desktop && yarn test",