From 620d44044ee2a0c4f710504222b9a361f7bb43ac Mon Sep 17 00:00:00 2001 From: NullVoxPopuli Date: Fri, 13 Jan 2023 18:05:43 -0500 Subject: [PATCH 1/9] Upgrade lint configs Add the prettier plugin Add scripts Lints work, but simple-import-sort's autofix does not work on gts -- might be worth disabling for the time being --- .prettierrc.js | 1 + docs-app/.eslintignore | 4 -- docs-app/.eslintrc.js | 19 +--------- docs-app/README.md | 42 ++++++++++----------- docs-app/app/components/theme-switcher.gts | 3 +- docs-app/app/helpers/service.ts | 4 +- docs-app/app/router.ts | 2 +- docs-app/app/templates/application.hbs | 8 ++-- docs-app/app/templates/docs.hbs | 2 +- docs-app/app/templates/index.hbs | 44 ++++++++++++++-------- docs-app/config/ember-cli-update.json | 6 +-- docs-app/config/targets.js | 6 ++- docs-app/ember-cli-build.js | 4 +- docs-app/package.json | 9 +++-- docs-app/tests/index.html | 24 +++++------- docs-app/tsconfig.json | 23 +++-------- docs-app/types/glint-registry.d.ts | 21 +++++------ package.json | 4 +- 18 files changed, 104 insertions(+), 122 deletions(-) diff --git a/.prettierrc.js b/.prettierrc.js index 534e6d35a..60255b880 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -2,4 +2,5 @@ module.exports = { singleQuote: true, + plugins: ['prettier-plugin-ember-template-tag'], }; diff --git a/docs-app/.eslintignore b/docs-app/.eslintignore index 4c20c318b..d474a40bd 100644 --- a/docs-app/.eslintignore +++ b/docs-app/.eslintignore @@ -23,7 +23,3 @@ /package.json.ember-try /package-lock.json.ember-try /yarn.lock.ember-try - -# until we have linting for gts set up -**/*.gts -**/*.gjs diff --git a/docs-app/.eslintrc.js b/docs-app/.eslintrc.js index 1467b45a2..80b9caf93 100644 --- a/docs-app/.eslintrc.js +++ b/docs-app/.eslintrc.js @@ -2,20 +2,5 @@ const { configs } = require('@nullvoxpopuli/eslint-configs'); -// accommodates: JS, TS, App, and Addon -const config = configs.ember(); - -module.exports = { - ...config, - overrides: [ - ...config.overrides, - { - files: ['tailwind.config.js'], - rules: { - // This ESLint plugin does not understand - // package.json#exports - 'node/no-missing-require': 'off', - }, - }, - ], -}; +// accommodates: JS, TS, App, Addon, and V2 Addon +module.exports = configs.ember(); diff --git a/docs-app/README.md b/docs-app/README.md index 84e3c6655..64011bb95 100644 --- a/docs-app/README.md +++ b/docs-app/README.md @@ -7,22 +7,22 @@ A short introduction of this app could easily go here. You will need the following things properly installed on your computer. -* [Git](https://git-scm.com/) -* [Node.js](https://nodejs.org/) (with npm) -* [Ember CLI](https://cli.emberjs.com/release/) -* [Google Chrome](https://google.com/chrome/) +- [Git](https://git-scm.com/) +- [Node.js](https://nodejs.org/) (with npm) +- [Ember CLI](https://cli.emberjs.com/release/) +- [Google Chrome](https://google.com/chrome/) ## Installation -* `git clone ` this repository -* `cd docs-app` -* `npm install` +- `git clone ` this repository +- `cd docs-app` +- `npm install` ## Running / Development -* `ember serve` -* Visit your app at [http://localhost:4200](http://localhost:4200). -* Visit your tests at [http://localhost:4200/tests](http://localhost:4200/tests). +- `ember serve` +- Visit your app at [http://localhost:4200](http://localhost:4200). +- Visit your tests at [http://localhost:4200/tests](http://localhost:4200/tests). ### Code Generators @@ -30,18 +30,18 @@ Make use of the many generators for code, try `ember help generate` for more det ### Running Tests -* `ember test` -* `ember test --server` +- `ember test` +- `ember test --server` ### Linting -* `npm run lint` -* `npm run lint:fix` +- `npm run lint` +- `npm run lint:fix` ### Building -* `ember build` (development) -* `ember build --environment production` (production) +- `ember build` (development) +- `ember build --environment production` (production) ### Deploying @@ -49,8 +49,8 @@ Specify what it takes to deploy your app. ## Further Reading / Useful Links -* [ember.js](https://emberjs.com/) -* [ember-cli](https://cli.emberjs.com/release/) -* Development Browser Extensions - * [ember inspector for chrome](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi) - * [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/) +- [ember.js](https://emberjs.com/) +- [ember-cli](https://cli.emberjs.com/release/) +- Development Browser Extensions + - [ember inspector for chrome](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi) + - [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/) diff --git a/docs-app/app/components/theme-switcher.gts b/docs-app/app/components/theme-switcher.gts index 164fc9ad2..17e56e9e3 100644 --- a/docs-app/app/components/theme-switcher.gts +++ b/docs-app/app/components/theme-switcher.gts @@ -1,6 +1,7 @@ import { on } from '@ember/modifier'; -import service from 'docs-app/helpers/service'; + import { DARK } from '@crowdstrike/ember-toucan-styles'; +import service from 'docs-app/helpers/service'; import type { TOC } from '@ember/component/template-only'; diff --git a/docs-app/app/helpers/service.ts b/docs-app/app/helpers/service.ts index 8edc58002..aef48375d 100644 --- a/docs-app/app/helpers/service.ts +++ b/docs-app/app/helpers/service.ts @@ -10,7 +10,9 @@ interface Signature { }; } -export default class GetService extends Helper> { +export default class GetService extends Helper< + Signature +> { compute([name]: [Key]): Registry[Key] { let owner = getOwner(this); diff --git a/docs-app/app/router.ts b/docs-app/app/router.ts index dc2be8aad..7a085eacf 100644 --- a/docs-app/app/router.ts +++ b/docs-app/app/router.ts @@ -1,7 +1,7 @@ import { registerDestructor } from '@ember/destroyable'; +import EmberRouter from '@embroider/router'; import { addDocfyRoutes } from '@docfy/ember'; -import EmberRouter from '@embroider/router'; import config from 'docs-app/config/environment'; export default class Router extends EmberRouter { diff --git a/docs-app/app/templates/application.hbs b/docs-app/app/templates/application.hbs index 847a787bc..713460341 100644 --- a/docs-app/app/templates/application.hbs +++ b/docs-app/app/templates/application.hbs @@ -1,11 +1,11 @@ -{{page-title "ember-toucan-core"}} +{{page-title 'ember-toucan-core'}} <:topBar> <:title> - - to + + to @@ -19,4 +19,4 @@ <:content> {{outlet}} - + \ No newline at end of file diff --git a/docs-app/app/templates/docs.hbs b/docs-app/app/templates/docs.hbs index f4d81d4fe..d25deb1d3 100644 --- a/docs-app/app/templates/docs.hbs +++ b/docs-app/app/templates/docs.hbs @@ -1,3 +1,3 @@ {{outlet}} - + \ No newline at end of file diff --git a/docs-app/app/templates/index.hbs b/docs-app/app/templates/index.hbs index 4b57ecc9f..03ebb8d36 100644 --- a/docs-app/app/templates/index.hbs +++ b/docs-app/app/templates/index.hbs @@ -1,25 +1,35 @@ -{{!-- template-lint-disable no-inline-styles --}} +{{! template-lint-disable no-inline-styles }} -
-

ember-toucan-core

+
+

ember-toucan-core

-

+

Coming up!

- + Read the Docs - + GitHub - +
-
+
@@ -34,32 +44,34 @@ <:content> -
- +
+ Features coming up! - + Features coming up! - + Features coming up! - + Features coming up! - + Features coming up! - + Features coming up!
-
+ \ No newline at end of file diff --git a/docs-app/config/ember-cli-update.json b/docs-app/config/ember-cli-update.json index f50c99c45..37227a330 100644 --- a/docs-app/config/ember-cli-update.json +++ b/docs-app/config/ember-cli-update.json @@ -10,11 +10,7 @@ "outputRepo": "https://github.com/ember-cli/ember-new-output", "codemodsSource": "ember-app-codemods-manifest@1", "isBaseBlueprint": true, - "options": [ - "--no-welcome", - "--embroider", - "--ci-provider=github" - ] + "options": ["--no-welcome", "--embroider", "--ci-provider=github"] } ] } diff --git a/docs-app/config/targets.js b/docs-app/config/targets.js index 9f6cc6396..1e48e0599 100644 --- a/docs-app/config/targets.js +++ b/docs-app/config/targets.js @@ -1,6 +1,10 @@ 'use strict'; -const browsers = ['last 1 Chrome versions', 'last 1 Firefox versions', 'last 1 Safari versions']; +const browsers = [ + 'last 1 Chrome versions', + 'last 1 Firefox versions', + 'last 1 Safari versions', +]; module.exports = { browsers, diff --git a/docs-app/ember-cli-build.js b/docs-app/ember-cli-build.js index eeeefc7dc..cf71bdb89 100644 --- a/docs-app/ember-cli-build.js +++ b/docs-app/ember-cli-build.js @@ -57,7 +57,9 @@ module.exports = function (defaults) { // we set to global mode to avoid hashing tailwind classes mode: 'global', // class naming template - localIdentName: isProduction() ? '[sha512:hash:base64:5]' : '[path][name]__[local]', + localIdentName: isProduction() + ? '[sha512:hash:base64:5]' + : '[path][name]__[local]', }, }, webpackConfig: { diff --git a/docs-app/package.json b/docs-app/package.json index f6700fa0a..e4e89058c 100644 --- a/docs-app/package.json +++ b/docs-app/package.json @@ -12,6 +12,8 @@ }, "scripts": { "build": "ember build --environment=production", + "format": "prettier -w .", + "format:check": "prettier -c .", "lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:' --prefix-colors cyan,white,yellow", "lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:' --prefix-colors cyan,white,yellow", "lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern", @@ -23,6 +25,7 @@ }, "devDependencies": { "@babel/core": "^7.19.6", + "@babel/eslint-parser": "^7.19.1", "@crowdstrike/ember-toucan-styles": "^1.0.5", "@crowdstrike/tailwind-toucan-base": "^3.3.1", "@docfy/core": "^0.5.0", @@ -39,7 +42,7 @@ "@glint/environment-ember-template-imports": "^0.9.6", "@glint/template": "^0.9.6", "@html-next/vertical-collection": "^4.0.0", - "@nullvoxpopuli/eslint-configs": "^2.2.59", + "@nullvoxpopuli/eslint-configs": "^3.0.1", "@tailwindcss/typography": "^0.5.7", "@tsconfig/ember": "^1.0.1", "@types/dompurify": "^2.3.4", @@ -90,7 +93,7 @@ "ember-source": "~4.8.0", "ember-template-imports": "^3.1.2", "ember-template-lint": "^4.14.0", - "eslint": "^7.32.0", + "eslint": "^8.31.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-ember": "^11.0.6", "eslint-plugin-node": "^11.1.0", @@ -120,9 +123,9 @@ "dompurify": "^2.4.0", "ember-browser-services": "^4.0.3", "ember-cached-decorator-polyfill": "^1.0.1", - "ember-toucan-core": "workspace:../ember-toucan-core", "ember-modifier": "^3.2.7", "ember-resources": "^5.4.0", + "ember-toucan-core": "workspace:../ember-toucan-core", "highlight.js": "^11.6.0", "highlightjs-glimmer": "^1.4.1", "tracked-built-ins": "^3.1.0" diff --git a/docs-app/tests/index.html b/docs-app/tests/index.html index 41779cf44..73f4c239c 100644 --- a/docs-app/tests/index.html +++ b/docs-app/tests/index.html @@ -1,24 +1,21 @@ - + DocsApp Tests - - + + - {{content-for "head"}} - {{content-for "test-head"}} + {{content-for "head"}} {{content-for "test-head"}} - - - + + + - {{content-for "head-footer"}} - {{content-for "test-head-footer"}} + {{content-for "head-footer"}} {{content-for "test-head-footer"}} - {{content-for "body"}} - {{content-for "test-body"}} + {{content-for "body"}} {{content-for "test-body"}}
@@ -33,7 +30,6 @@ - {{content-for "body-footer"}} - {{content-for "test-body-footer"}} + {{content-for "body-footer"}} {{content-for "test-body-footer"}} diff --git a/docs-app/tsconfig.json b/docs-app/tsconfig.json index 3ab9a5cce..2c8413e41 100644 --- a/docs-app/tsconfig.json +++ b/docs-app/tsconfig.json @@ -1,10 +1,7 @@ { "extends": "@tsconfig/ember/tsconfig.json", "glint": { - "environment": [ - "ember-loose", - "ember-template-imports" - ] + "environment": ["ember-loose", "ember-template-imports"] }, "compilerOptions": { "noEmitOnError": false, @@ -14,20 +11,10 @@ // work with TypeScript. "baseUrl": ".", "paths": { - "docs-app/tests/*": [ - "tests/*" - ], - "docs-app/*": [ - "app/*" - ], - "*": [ - "types/*" - ] + "docs-app/tests/*": ["tests/*"], + "docs-app/*": ["app/*"], + "*": ["types/*"] } }, - "include": [ - "app/**/*", - "tests/**/*", - "types/**/*" - ] + "include": ["app/**/*", "tests/**/*", "types/**/*"] } diff --git a/docs-app/types/glint-registry.d.ts b/docs-app/types/glint-registry.d.ts index 1eb70cfd8..87d4208ee 100644 --- a/docs-app/types/glint-registry.d.ts +++ b/docs-app/types/glint-registry.d.ts @@ -1,24 +1,22 @@ -import "@glint/environment-ember-loose"; -import "@glint/environment-ember-template-imports"; - +import '@glint/environment-ember-loose'; +import '@glint/environment-ember-template-imports'; // Types from libraries -import "@crowdstrike/ember-oss-docs/glint"; +import '@crowdstrike/ember-oss-docs/glint'; +import type { HelperLike, ModifierLike } from '@glint/template'; +import type FeatureCard from 'docs-app/components/feature-card'; // Our own types import type ThemeSwitcher from 'docs-app/components/theme-switcher'; -import type FeatureCard from 'docs-app/components/feature-card'; - -import type { HelperLike, ModifierLike } from "@glint/template"; declare module '@ember/modifier' { export const on: ModifierLike<{ Args: { Positional: [eventName: string, eventHandler: (event: Event) => void]; - } - }> + }; + }>; } -declare module "@glint/environment-ember-loose/registry" { +declare module '@glint/environment-ember-loose/registry' { export default interface Registry { ThemeSwitcher: typeof ThemeSwitcher; FeatureCard: typeof FeatureCard; @@ -29,7 +27,6 @@ declare module "@glint/environment-ember-loose/registry" { Positional: [string]; }; Return: string; - }> + }>; } } - diff --git a/package.json b/package.json index 2159b5cf8..2e64107b7 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,8 @@ "lint:fix": "pnpm --filter '*' lint:fix" }, "devDependencies": { - "concurrently": "^7.2.1", - "prettier": "^2.5.1" + "concurrently": "^7.6.0", + "prettier": "^2.8.2" }, "pnpm": { "overrides": { From 0414a84d7c00c3ae93c132bc116a4dcfcfb3b645 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli Date: Thu, 19 Jan 2023 10:41:06 -0500 Subject: [PATCH 2/9] Migrate lints and achieve successful lint:fix --- docs-app/{.eslintrc.js => .eslintrc.cjs} | 0 docs-app/package.json | 7 +-- ember-toucan-core/.eslintrc.cjs | 6 ++ ember-toucan-core/.eslintrc.js | 56 ----------------- .../{addon-main.js => addon-main.cjs} | 1 + ember-toucan-core/package.json | 32 +++++----- test-app/.eslintrc.cjs | 6 ++ test-app/.eslintrc.js | 60 ------------------- test-app/app/app.ts | 3 +- test-app/app/router.ts | 1 + test-app/ember-cli-build.js | 1 + test-app/package.json | 6 +- test-app/tests/helpers/index.ts | 6 +- test-app/tests/test-helper.ts | 7 ++- test-app/types/test-app/index.d.ts | 2 +- 15 files changed, 50 insertions(+), 144 deletions(-) rename docs-app/{.eslintrc.js => .eslintrc.cjs} (100%) create mode 100644 ember-toucan-core/.eslintrc.cjs delete mode 100644 ember-toucan-core/.eslintrc.js rename ember-toucan-core/{addon-main.js => addon-main.cjs} (99%) create mode 100644 test-app/.eslintrc.cjs delete mode 100644 test-app/.eslintrc.js diff --git a/docs-app/.eslintrc.js b/docs-app/.eslintrc.cjs similarity index 100% rename from docs-app/.eslintrc.js rename to docs-app/.eslintrc.cjs diff --git a/docs-app/package.json b/docs-app/package.json index e4e89058c..b11a8ee06 100644 --- a/docs-app/package.json +++ b/docs-app/package.json @@ -42,7 +42,7 @@ "@glint/environment-ember-template-imports": "^0.9.6", "@glint/template": "^0.9.6", "@html-next/vertical-collection": "^4.0.0", - "@nullvoxpopuli/eslint-configs": "^3.0.1", + "@nullvoxpopuli/eslint-configs": "^3.0.4", "@tailwindcss/typography": "^0.5.7", "@tsconfig/ember": "^1.0.1", "@types/dompurify": "^2.3.4", @@ -71,7 +71,6 @@ "@types/qunit": "^2.19.3", "@types/rsvp": "^4.0.4", "autoprefixer": "^10.4.12", - "babel-eslint": "^10.1.0", "broccoli-asset-rev": "^3.0.0", "concurrently": "^7.4.0", "cssnano": "^5.1.13", @@ -95,7 +94,7 @@ "ember-template-lint": "^4.14.0", "eslint": "^8.31.0", "eslint-config-prettier": "^8.5.0", - "eslint-plugin-ember": "^11.0.6", + "eslint-plugin-ember": "^11.4.3", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-qunit": "^7.3.1", @@ -103,7 +102,7 @@ "postcss": "^8.4.17", "postcss-import": "^15.0.0", "postcss-loader": "^7.0.1", - "prettier": "^2.7.1", + "prettier": "^2.8.3", "qunit": "^2.19.1", "qunit-dom": "^2.0.0", "tailwindcss": "^3.1.8", diff --git a/ember-toucan-core/.eslintrc.cjs b/ember-toucan-core/.eslintrc.cjs new file mode 100644 index 000000000..80b9caf93 --- /dev/null +++ b/ember-toucan-core/.eslintrc.cjs @@ -0,0 +1,6 @@ +'use strict'; + +const { configs } = require('@nullvoxpopuli/eslint-configs'); + +// accommodates: JS, TS, App, Addon, and V2 Addon +module.exports = configs.ember(); diff --git a/ember-toucan-core/.eslintrc.js b/ember-toucan-core/.eslintrc.js deleted file mode 100644 index 641c2987f..000000000 --- a/ember-toucan-core/.eslintrc.js +++ /dev/null @@ -1,56 +0,0 @@ -'use strict'; - -module.exports = { - root: true, - parser: '@typescript-eslint/parser', - parserOptions: { - ecmaVersion: 'latest', - }, - plugins: ['ember'], - extends: [ - 'eslint:recommended', - 'plugin:ember/recommended', - 'plugin:prettier/recommended', - ], - env: { - browser: true, - }, - rules: {}, - overrides: [ - // ts files - { - files: ['**/*.ts'], - extends: [ - 'plugin:@typescript-eslint/eslint-recommended', - 'plugin:@typescript-eslint/recommended', - ], - rules: { - // Add any custom rules here - }, - }, - { - files: ['**/*.d.ts'], - rules: { - '@typescript-eslint/no-empty-interface': 'off', - }, - }, - // node files - { - files: [ - './.eslintrc.js', - './.prettierrc.js', - './.template-lintrc.js', - './addon-main.js', - ], - parserOptions: { - sourceType: 'script', - }, - env: { - browser: false, - node: true, - }, - plugins: ['node'], - extends: ['plugin:node/recommended'], - }, - ], -}; diff --git a/ember-toucan-core/addon-main.js b/ember-toucan-core/addon-main.cjs similarity index 99% rename from ember-toucan-core/addon-main.js rename to ember-toucan-core/addon-main.cjs index f868d6b91..d36b0c86d 100644 --- a/ember-toucan-core/addon-main.js +++ b/ember-toucan-core/addon-main.cjs @@ -1,4 +1,5 @@ 'use strict'; const { addonV1Shim } = require('@embroider/addon-shim'); + module.exports = addonV1Shim(__dirname); diff --git a/ember-toucan-core/package.json b/ember-toucan-core/package.json index a6ba08cac..5ce8f2322 100644 --- a/ember-toucan-core/package.json +++ b/ember-toucan-core/package.json @@ -13,7 +13,7 @@ "license": "MIT", "author": "CrowdStrike UX Team", "files": [ - "addon-main.js", + "addon-main.cjs", "dist" ], "scripts": { @@ -30,12 +30,12 @@ "prepack": "rollup --config" }, "peerDependencies": { - "@crowdstrike/ember-toucan-styles": "^1.0.5", - "@glimmer/tracking": "^1.1.2", - "autoprefixer": "^10.0.2", "ember-source": "^4.8.0", + "tailwindcss": "^2.2.15 || ^3.0.0", "postcss": "^8.2.14", - "tailwindcss": "^2.2.15 || ^3.0.0" + "autoprefixer": "^10.0.2", + "@glimmer/tracking": "^1.1.2", + "@crowdstrike/ember-toucan-styles": "^1.0.5" }, "dependencies": { "@embroider/addon-shim": "^1.0.0" @@ -46,10 +46,8 @@ "@babel/plugin-proposal-decorators": "^7.17.0", "@babel/plugin-syntax-decorators": "^7.17.0", "@babel/preset-typescript": "^7.18.6", - "@crowdstrike/ember-toucan-styles": "^1.0.5", "@embroider/addon-dev": "^2.0.0", "@glimmer/component": "^1.1.2", - "@glimmer/tracking": "^1.1.2", "@glint/core": "^0.9.7", "@glint/environment-ember-loose": "^0.9.7", "@glint/template": "^0.9.7", @@ -73,24 +71,28 @@ "@types/ember__utils": "^4.0.0", "@typescript-eslint/eslint-plugin": "^5.30.5", "@typescript-eslint/parser": "^5.30.5", - "autoprefixer": "^10.0.2", "concurrently": "^7.2.1", "ember-cli-htmlbars": "^6.1.1", "ember-source": "~4.9.2", "ember-template-lint": "^4.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", - "eslint-plugin-ember": "^10.5.8", + "eslint-plugin-ember": "^11.4.3", "eslint-plugin-n": "^15.6.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^4.0.0", - "postcss": "^8.2.14", - "prettier": "^2.5.1", + "prettier": "^2.8.3", "rollup": "^2.67.0", "rollup-plugin-copy": "^3.4.0", "rollup-plugin-ts": "^3.0.2", + "typescript": "^4.7.4", "tailwindcss": "^2.2.15", - "typescript": "^4.7.4" + "postcss": "^8.2.14", + "autoprefixer": "^10.0.2", + "@nullvoxpopuli/eslint-configs": "^3.0.4", + "@glimmer/tracking": "^1.1.2", + "@crowdstrike/ember-toucan-styles": "^1.0.5", + "@babel/eslint-parser": "^7.19.1" }, "publishConfig": { "registry": "https://registry.npmjs.org" @@ -101,7 +103,7 @@ "ember-addon": { "version": 2, "type": "addon", - "main": "addon-main.js", + "main": "addon-main.cjs", "app-js": {} }, "exports": { @@ -110,7 +112,7 @@ "types": "./dist/*.d.ts", "default": "./dist/*.js" }, - "./addon-main.js": "./addon-main.js" + "./addon-main.js": "./addon-main.cjs" }, "typesVersions": { "*": { @@ -119,4 +121,4 @@ ] } } -} +} \ No newline at end of file diff --git a/test-app/.eslintrc.cjs b/test-app/.eslintrc.cjs new file mode 100644 index 000000000..80b9caf93 --- /dev/null +++ b/test-app/.eslintrc.cjs @@ -0,0 +1,6 @@ +'use strict'; + +const { configs } = require('@nullvoxpopuli/eslint-configs'); + +// accommodates: JS, TS, App, Addon, and V2 Addon +module.exports = configs.ember(); diff --git a/test-app/.eslintrc.js b/test-app/.eslintrc.js deleted file mode 100644 index cffa61842..000000000 --- a/test-app/.eslintrc.js +++ /dev/null @@ -1,60 +0,0 @@ -'use strict'; - -module.exports = { - root: true, - parser: '@typescript-eslint/parser', - parserOptions: { - ecmaVersion: 2018, - }, - plugins: ['ember', '@typescript-eslint'], - extends: [ - 'eslint:recommended', - 'plugin:ember/recommended', - 'plugin:prettier/recommended', - ], - env: { - browser: true, - }, - rules: {}, - overrides: [ - // ts files - { - files: ['**/*.ts'], - extends: [ - 'plugin:@typescript-eslint/eslint-recommended', - 'plugin:@typescript-eslint/recommended', - ], - rules: {}, - }, - { - files: ['**/*.d.ts'], - rules: { - '@typescript-eslint/no-empty-interface': 'off', - }, - }, - // node files - { - files: [ - './.eslintrc.js', - './.prettierrc.js', - './.template-lintrc.js', - './ember-cli-build.js', - './testem.js', - './blueprints/*/index.js', - './config/**/*.js', - './lib/*/index.js', - './server/**/*.js', - ], - env: { - browser: false, - node: true, - }, - extends: ['plugin:n/recommended'], - }, - { - // test files - files: ['tests/**/*-test.{js,ts}'], - extends: ['plugin:qunit/recommended'], - }, - ], -}; diff --git a/test-app/app/app.ts b/test-app/app/app.ts index 1ba934244..83bc0d2b3 100644 --- a/test-app/app/app.ts +++ b/test-app/app/app.ts @@ -1,6 +1,7 @@ import Application from '@ember/application'; -import Resolver from 'ember-resolver'; + import loadInitializers from 'ember-load-initializers'; +import Resolver from 'ember-resolver'; import config from 'test-app/config/environment'; export default class App extends Application { diff --git a/test-app/app/router.ts b/test-app/app/router.ts index c4a2c0ce8..826daada9 100644 --- a/test-app/app/router.ts +++ b/test-app/app/router.ts @@ -1,4 +1,5 @@ import EmberRouter from '@ember/routing/router'; + import config from 'test-app/config/environment'; export default class Router extends EmberRouter { diff --git a/test-app/ember-cli-build.js b/test-app/ember-cli-build.js index ea4e116f5..642e58f73 100644 --- a/test-app/ember-cli-build.js +++ b/test-app/ember-cli-build.js @@ -10,5 +10,6 @@ module.exports = function (defaults) { }); const { maybeEmbroider } = require('@embroider/test-setup'); + return maybeEmbroider(app); }; diff --git a/test-app/package.json b/test-app/package.json index 5766ae45e..23187b0f0 100644 --- a/test-app/package.json +++ b/test-app/package.json @@ -26,6 +26,7 @@ }, "devDependencies": { "@babel/core": "^7.0.0", + "@babel/eslint-parser": "^7.19.1", "@crowdstrike/ember-toucan-core": "^0.0.0", "@ember/optional-features": "^2.0.0", "@ember/test-helpers": "^2.8.1", @@ -35,6 +36,7 @@ "@glint/core": "^0.9.7", "@glint/environment-ember-loose": "^0.9.7", "@glint/template": "^0.9.7", + "@nullvoxpopuli/eslint-configs": "^3.0.4", "@tsconfig/ember": "^2.0.0", "@types/ember": "^4.0.3", "@types/ember-data": "^4.4.6", @@ -89,13 +91,13 @@ "ember-try": "^2.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.5.0", - "eslint-plugin-ember": "^11.2.1", + "eslint-plugin-ember": "^11.4.3", "eslint-plugin-n": "^15.6.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-qunit": "^7.3.4", "loader.js": "^4.7.0", - "prettier": "^2.8.1", + "prettier": "^2.8.3", "qunit": "^2.19.3", "qunit-dom": "^2.0.0", "typescript": "^4.9.4", diff --git a/test-app/tests/helpers/index.ts b/test-app/tests/helpers/index.ts index 670bc6435..3b5778bd1 100644 --- a/test-app/tests/helpers/index.ts +++ b/test-app/tests/helpers/index.ts @@ -1,10 +1,12 @@ import { setupApplicationTest as upstreamSetupApplicationTest, setupRenderingTest as upstreamSetupRenderingTest, - setupTest as upstreamSetupTest, - SetupTestOptions, + setupTest as upstreamSetupTest } from 'ember-qunit'; +import type { + SetupTestOptions} from 'ember-qunit'; + // This file exists to provide wrappers around ember-qunit's / ember-mocha's // test setup functions. This way, you can easily extend the setup that is // needed per test type. diff --git a/test-app/tests/test-helper.ts b/test-app/tests/test-helper.ts index 818430448..5990eca2d 100644 --- a/test-app/tests/test-helper.ts +++ b/test-app/tests/test-helper.ts @@ -1,10 +1,11 @@ -import Application from 'test-app/app'; -import config from 'test-app/config/environment'; -import * as QUnit from 'qunit'; import { setApplication } from '@ember/test-helpers'; +import * as QUnit from 'qunit'; import { setup } from 'qunit-dom'; import { start } from 'ember-qunit'; +import Application from 'test-app/app'; +import config from 'test-app/config/environment'; + setApplication(Application.create(config.APP)); setup(QUnit.assert); diff --git a/test-app/types/test-app/index.d.ts b/test-app/types/test-app/index.d.ts index d2f5fc1b0..ea7816ebd 100644 --- a/test-app/types/test-app/index.d.ts +++ b/test-app/types/test-app/index.d.ts @@ -1,4 +1,4 @@ -import Ember from 'ember'; +import type Ember from 'ember'; declare global { // Prevents ESLint from "fixing" this via its auto-fix to turn it into a type From 59f814598cfca08ca2f82cfaabfa1335be6205fb Mon Sep 17 00:00:00 2001 From: NullVoxPopuli Date: Thu, 19 Jan 2023 10:49:12 -0500 Subject: [PATCH 3/9] Add formatting scripts --- .prettierrc.js | 1 - docs-app/.prettierrc.js | 18 ++++++++++++++++++ docs-app/package.json | 1 + ember-toucan-core/.prettierrc.cjs | 23 +++++++++++++++++++++++ ember-toucan-core/package.json | 11 +++++++---- package.json | 4 +++- test-app/.prettierrc.js | 19 ++++++++++++++++++- test-app/package.json | 3 +++ 8 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 ember-toucan-core/.prettierrc.cjs diff --git a/.prettierrc.js b/.prettierrc.js index 60255b880..534e6d35a 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -2,5 +2,4 @@ module.exports = { singleQuote: true, - plugins: ['prettier-plugin-ember-template-tag'], }; diff --git a/docs-app/.prettierrc.js b/docs-app/.prettierrc.js index 534e6d35a..858ea7a39 100644 --- a/docs-app/.prettierrc.js +++ b/docs-app/.prettierrc.js @@ -1,5 +1,23 @@ 'use strict'; module.exports = { + plugins: ['prettier-plugin-ember-template-tag'], singleQuote: true, + templateSingleQuote: false, + // this was required to make the VSCode + Prettier work correctly with