Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .eslintignore

This file was deleted.

60 changes: 0 additions & 60 deletions .eslintrc.js

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
cache: yarn
- name: Install Dependencies
run: yarn install --frozen-lockfile
Expand All @@ -40,7 +40,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
cache: yarn
- name: Install Dependencies
run: yarn install --no-lockfile
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
cache: yarn
- name: Install Dependencies
run: yarn install --frozen-lockfile
Expand Down
3 changes: 1 addition & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
/.ember-cli
/.env*
/.eslintcache
/.eslintignore
/.eslintrc.js
/.git/
/.github/
/.gitignore
Expand All @@ -21,6 +19,7 @@
/.watchmanconfig
/CONTRIBUTING.md
/ember-cli-build.js
/eslint.config.mjs
/testem.js
/tests/
/tsconfig.declarations.json
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@

# ember-try
/.node_modules.ember-try/

eslint.config.mjs
10 changes: 9 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
'use strict';

module.exports = {
plugins: ['prettier-plugin-ember-template-tag'],
overrides: [
{
files: '*.{js,ts}',
files: '*.{js,gjs,ts,gts,mjs,mts,cjs,cts}',
options: {
singleQuote: true,
},
},
{
files: '*.{gjs,gts}',
options: {
singleQuote: true,
templateSingleQuote: false,
},
},
],
};
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 18.12.0
nodejs 20.19.3
131 changes: 131 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/**
* Debugging:
* https://eslint.org/docs/latest/use/configure/debug
* ----------------------------------------------------
*
* Print a file's calculated configuration
*
* npx eslint --print-config path/to/file.js
*
* Inspecting the config
*
* npx eslint --inspect-config
*
*/
import globals from 'globals';
import js from '@eslint/js';

import ember from 'eslint-plugin-ember/recommended';
import prettier from 'eslint-plugin-prettier/recommended';
import qunit from 'eslint-plugin-qunit';
import n from 'eslint-plugin-n';

import babelParser from '@babel/eslint-parser';

const esmParserOptions = {
ecmaFeatures: { modules: true },
ecmaVersion: 'latest',
requireConfigFile: false,
babelOptions: {
plugins: [
['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }],
],
},
};

export default [
js.configs.recommended,
prettier,
ember.configs.base,
ember.configs.gjs,
/**
* Ignores must be in their own object
* https://eslint.org/docs/latest/use/configure/ignore
*/
{
ignores: [
'dist/',
'node_modules/',
'coverage/',
'! **/.*',
'eslint.config.mjs',
'.node_modules.ember-try/'
],
},
/**
* https://eslint.org/docs/latest/use/configure/configuration-files#configuring-linter-options
*/
{
linterOptions: {
reportUnusedDisableDirectives: 'error',
},
},
{
files: ['**/*.js'],
languageOptions: {
parser: babelParser,
},
},
{
files: ['**/*.{js,gjs}'],
languageOptions: {
parserOptions: esmParserOptions,
globals: {
...globals.browser,
},
},
},
{
files: ['tests/**/*-test.{js,gjs}'],
plugins: {
qunit,
},
},
/**
* CJS node files
*/
{
files: [
'**/*.cjs',
'config/**/*.js',
'tests/dummy/config/**/*.js',
'testem.js',
'testem*.js',
'index.js',
'.prettierrc.js',
'.stylelintrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'./lib/**/*.js',
],
plugins: {
n,
},

languageOptions: {
sourceType: 'script',
ecmaVersion: 'latest',
globals: {
...globals.node,
},
},
},
/**
* ESM node files
*/
{
files: ['**/*.mjs'],
plugins: {
n,
},

languageOptions: {
sourceType: 'module',
ecmaVersion: 'latest',
parserOptions: esmParserOptions,
globals: {
...globals.node,
},
},
},
];
9 changes: 9 additions & 0 deletions lib/front-end-builds-notifier.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
const CoreObject = require('core-object');
const fs = require('fs');

// crypto is globally available in Node.js 20, so at some stage we should consider
// accessing directly rather than the require syntax below.
// eslint-disable-next-line no-redeclare
const crypto = require('crypto');

const { execSync } = require('child_process');

// fetch is built into Node.js 20, so at some stage we should consider
// removing this dependency.
// eslint-disable-next-line no-redeclare
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antonivanopoulos @andybluntish I'm a little stuck on making a decision on these two imports. They are slightly different in nature.

For crypto, I believe what eslint is trying to tell me is that I can just call crypto without importing it on the version of node that I'm on, however I can't find supporting docs for that, most examples online continue to import like this.

For fetch, I believe eslint is aware that node ships with a fetch module, however this is using the installed node-fetch package, hence the namespace clash.

The thing that is really stopping me from making decisions is that there is no way to test this out, apart from pointing one of our apps at it and seeing if it works. While that would be effective, I kinda want to be more certain, especially as we are using private keys to sign things.

I'd like to write some tests but exporting a file from the lib dir into a test for an addon isn't straightforward. (lol at the supporting documentation for testing addons https://cli.emberjs.com/release/writing-addons/intro-tutorial/#testinganaddon).

Any thoughts would be valued.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue here is going to be the eslint setup. We're setting up the globals config to include globals.browser in all js files (**/*.{js,gjs}).

Later on we're including lib/**/*.js in the "node files" config, which adds the node globals, but this isn't overriding the previous config—is additive.

So eslint thinks that this file has access to both the browser and nodejs globals, and in this case is complaining that we're importing crypto because that exists in globals.browser.

For this plugin, we can probably just remove all the browser-specific eslint config, since there isn't any code that will run there.

const fetch = require('node-fetch');

module.exports = CoreObject.extend({
Expand Down
64 changes: 34 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,65 +15,69 @@
},
"scripts": {
"build": "ember build --environment=production",
"lint": "concurrently \"yarn:lint:*(!fix)\" --names \"lint:\"",
"lint": "concurrently \"yarn:lint:*(!fix)\" --names \"lint:\" --prefixColors auto",
"lint:css": "stylelint \"**/*.css\"",
"lint:css:fix": "concurrently \"yarn:lint:css -- --fix\"",
"lint:fix": "concurrently \"yarn:lint:*:fix\" --names \"fix:\"",
"lint:fix": "concurrently \"yarn:lint:*:fix\" --names \"fix:\" --prefixColors auto",
"lint:hbs": "ember-template-lint .",
"lint:hbs:fix": "ember-template-lint . --fix",
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"start": "ember serve",
"test": "concurrently \"yarn:lint\" \"yarn:test:*\" --names \"lint,test:\"",
"test": "concurrently \"yarn:lint\" \"yarn:test:*\" --names \"lint,test:\" --prefixColors auto",
"test:ember": "ember test",
"test:ember-compatibility": "ember try:each"
},
"dependencies": {
"@babel/core": "^7.24.7",
"@babel/core": "^7.26.0",
"core-object": "^3.1.5",
"ember-cli-babel": "^8.2.0",
"ember-cli-htmlbars": "^6.3.0",
"ember-template-imports": "^4.2.0",
"node-fetch": "^2"
},
"devDependencies": {
"@babel/eslint-parser": "^7.24.7",
"@babel/plugin-proposal-decorators": "^7.24.7",
"@ember/optional-features": "^2.1.0",
"@ember/test-helpers": "^3.3.0",
"@embroider/test-setup": "^3.0.3",
"@babel/eslint-parser": "^7.25.9",
"@babel/plugin-proposal-decorators": "^7.25.9",
"@ember/optional-features": "^2.2.0",
"@ember/test-helpers": "^4.0.4",
"@embroider/test-setup": "^4.0.0",
"@eslint/js": "^9.17.0",
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2",
"broccoli-asset-rev": "^3.0.0",
"concurrently": "^8.2.2",
"ember-auto-import": "^2.7.4",
"ember-cli": "~5.10.0",
"concurrently": "^9.1.0",
"ember-auto-import": "^2.10.0",
"ember-cli": "~6.1.0",
"ember-cli-clean-css": "^3.0.0",
"ember-cli-dependency-checker": "^3.3.2",
"ember-cli-dependency-checker": "^3.3.3",
"ember-cli-deploy-plugin": "^0.2.9",
"ember-cli-inject-live-reload": "^2.1.0",
"ember-cli-sri": "^2.1.1",
"ember-cli-terser": "^4.0.2",
"ember-load-initializers": "^2.1.2",
"ember-qunit": "^8.1.0",
"ember-resolver": "^11.0.1",
"ember-source": "~5.10.0",
"ember-load-initializers": "^3.0.1",
"ember-qunit": "^8.1.1",
"ember-resolver": "^13.1.0",
"ember-source": "~6.1.0",
"ember-source-channel-url": "^3.0.0",
"ember-template-lint": "^5.13.0",
"ember-template-lint": "^6.0.0",
"ember-try": "^3.0.0",
"eslint": "^8.57.0",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-ember": "^11.12.0",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-qunit": "^8.1.1",
"eslint-plugin-ember": "^12.3.3",
"eslint-plugin-n": "^17.15.1",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-qunit": "^8.1.2",
"globals": "^15.14.0",
"loader.js": "^4.7.0",
"prettier": "^3.3.2",
"qunit": "^2.21.0",
"qunit-dom": "^2.0.0",
"stylelint": "^15.11.0",
"stylelint-config-standard": "^34.0.0",
"stylelint-prettier": "^4.1.0",
"webpack": "^5.92.1"
"prettier": "^3.4.2",
"prettier-plugin-ember-template-tag": "^2.0.4",
"qunit": "^2.23.1",
"qunit-dom": "^3.4.0",
"stylelint": "^16.12.0",
"stylelint-config-standard": "^36.0.1",
"stylelint-prettier": "^5.0.2",
"webpack": "^5.97.1"
},
"peerDependencies": {
"ember-source": ">= 4.0.0"
Expand Down
Loading