Skip to content

Commit

Permalink
Update linting and prettier setups, drop node 16 support (#1624)
Browse files Browse the repository at this point in the history
* Update linting and prettier setups

* Update package.json
  • Loading branch information
RobbieTheWagner authored Dec 24, 2023
1 parent 3025f8c commit a6a499a
Show file tree
Hide file tree
Showing 23 changed files with 313 additions and 363 deletions.
3 changes: 3 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@

module.exports = {
extends: ['stylelint-config-standard-scss', 'stylelint-prettier/recommended'],
rules: {
'no-descending-specificity': null,
},
};
2 changes: 1 addition & 1 deletion blueprints/ember-electron-postinstall/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = class EmberElectronBlueprint extends Blueprint {

async afterInstall() {
this.ui.writeLine(
`\nRun 'ember g ember-electron' to complete ember-electron setup\n`
`\nRun 'ember g ember-electron' to complete ember-electron setup\n`,
);
}
};
26 changes: 13 additions & 13 deletions blueprints/ember-electron/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ module.exports = class EmberElectronBlueprint extends Blueprint {
`\n'ember-electron' directory detected -- this looks like an ember-electron`,
`v2 project. Setting up an updated project will not be destructive, but you`,
`should read the upgrading documentation at ${upgradingUrl}.\n`,
].join(' ')
)
].join(' '),
),
);
}

Expand All @@ -51,8 +51,8 @@ module.exports = class EmberElectronBlueprint extends Blueprint {
`If you're running the blueprint manually as part of an ember-electron`,
`upgrade, make sure to check for upgrade instructions relevant to your`,
`version upgrade at ${upgradingUrl}.\n`,
].join(' ')
)
].join(' '),
),
);
}

Expand All @@ -68,7 +68,7 @@ module.exports = class EmberElectronBlueprint extends Blueprint {
if (rootURLRegex.test(contents)) {
contents = contents.replace(
rootURLRegex,
`$1 process.env.EMBER_CLI_ELECTRON ? '' :`
`$1 process.env.EMBER_CLI_ELECTRON ? '' :`,
);
} else {
this.ui.writeLine(
Expand All @@ -78,16 +78,16 @@ module.exports = class EmberElectronBlueprint extends Blueprint {
`\`process.env.EMBER_CLI_ELECTRON ? '' : <previous value>\`,`,
`which is needed for your Ember app to load assets under Electron.`,
`See ${routingAndAssetLoadingUrl} for more information.`,
].join(' ')
)
].join(' '),
),
);
}

const locationTypeRegex = /(\slocationType\s*:)/;
if (locationTypeRegex.test(contents)) {
contents = contents.replace(
locationTypeRegex,
`$1 process.env.EMBER_CLI_ELECTRON ? 'hash' :`
`$1 process.env.EMBER_CLI_ELECTRON ? 'hash' :`,
);
} else {
this.ui.writeLine(
Expand All @@ -97,8 +97,8 @@ module.exports = class EmberElectronBlueprint extends Blueprint {
`\`process.env.EMBER_CLI_ELECTRON ? 'hash' : <previous value>\`,`,
`which is needed for your Ember app's routing to work under Electron.`,
`See ${routingAndAssetLoadingUrl} for more information.`,
].join(' ')
)
].join(' '),
),
);
}

Expand All @@ -114,7 +114,7 @@ module.exports = class EmberElectronBlueprint extends Blueprint {
//
async updateEslintIgnore() {
const toAppend = ['', '# ember-electron', `/${electronProjectPath}/`].join(
'\n'
'\n',
);

await this.insertIntoFile('.eslintignore', toAppend);
Expand All @@ -133,8 +133,8 @@ module.exports = class EmberElectronBlueprint extends Blueprint {
async createElectronProject() {
this.ui.writeLine(
chalk.green(
`Creating electron-forge project at './${electronProjectPath}'`
)
`Creating electron-forge project at './${electronProjectPath}'`,
),
);

await api.init({
Expand Down
8 changes: 4 additions & 4 deletions forge/files/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const handleFileUrls = require('./handle-file-urls');

const emberAppDir = path.resolve(__dirname, '..', 'ember-dist');
const emberAppURL = pathToFileURL(
path.join(emberAppDir, 'index.html')
path.join(emberAppDir, 'index.html'),
).toString();

let mainWindow = null;
Expand Down Expand Up @@ -71,14 +71,14 @@ app.on('ready', async () => {
return;
}
console.log(
'Your main window process has exited unexpectedly -- see https://www.electronjs.org/docs/api/web-contents#event-render-process-gone'
'Your main window process has exited unexpectedly -- see https://www.electronjs.org/docs/api/web-contents#event-render-process-gone',
);
console.log('Reason: ' + details.reason);
});

mainWindow.on('unresponsive', () => {
console.log(
'Your Ember app (or other code) has made the window unresponsive.'
'Your Ember app (or other code) has made the window unresponsive.',
);
});

Expand Down Expand Up @@ -109,7 +109,7 @@ app.on('ready', async () => {
process.on('uncaughtException', (err) => {
console.log('An exception in the main thread was not handled.');
console.log(
'This is a serious issue that needs to be handled and/or debugged.'
'This is a serious issue that needs to be handled and/or debugged.',
);
console.log(`Exception: ${err}`);
});
4 changes: 2 additions & 2 deletions forge/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function updateGitIgnore(dir) {
'# package/make output directory',
`${packageOutDir}/`,
'',
].join('\n')
].join('\n'),
);
}

Expand All @@ -41,7 +41,7 @@ async function updatePackageJson(dir) {

// copy some fields from the Ember project's package.json
let parentPackageJson = JSON.parse(
await readFile(path.join(dir, '../package.json'))
await readFile(path.join(dir, '../package.json')),
);
const keysToCopy = ['name', 'version', 'description', 'author', 'license'];
for (let key of keysToCopy) {
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = {
// loaded from `index.html`, and the assets will load correctly (see
// https://ember-electron.js.org/versions/v3.0.0-beta.5/docs/faq/routing-and-asset-loading)
return [injectScript('shim-test-head.js'), '<base href="..">'].join(
'\n'
'\n',
);
case 'test-body':
// testem.js needs to load over HTTP because of how testem works. We
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function buildAvailableOptions() {

// Pick just the ones we support
let availableOptions = baseOptions.filter((option) =>
supportedNames.includes(option.name)
supportedNames.includes(option.name),
);
// Make our customizations
availableOptions = availableOptions.map((option) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ElectronTask extends Task {
async _runElectron(builder, { electronArgs = [] }) {
if (electronArgs.length > 0) {
this.ui.writeLine(
chalk(`Starting Electron with args '${electronArgs.join(' ')}'...`)
chalk(`Starting Electron with args '${electronArgs.join(' ')}'...`),
);
} else {
this.ui.writeLine(chalk('Starting Electron...'));
Expand Down
8 changes: 4 additions & 4 deletions lib/utils/check-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Reporter extends BaseReporter {
report() {
if (this.messages.length) {
let message = this.chalk.red(
`This should be done in ${electronProjectPath}/ -- see ${structureUrl} for more info.`
`This should be done in ${electronProjectPath}/ -- see ${structureUrl} for more info.`,
);
this.messages.push(`${message}${this.EOL}`);
}
Expand All @@ -34,19 +34,19 @@ module.exports = async function checkDependencies(project) {
electronProjectRoot,
packageJson,
project.ui,
project.cli
project.cli,
);
let dependencyChecker = new DependencyChecker(
electronProject,
new Reporter()
new Reporter(),
);

// The dependency checker is set up to only run once, and it has already been
// run in the Ember project by ember-cli, so we need to clear the
// alreadyChecked status so it will run for us here.
DependencyChecker.setAlreadyChecked(false);
project.ui.writeLine(
chalk.green(`Checking dependencies in ${electronProjectPath}...`)
chalk.green(`Checking dependencies in ${electronProjectPath}...`),
);
dependencyChecker.checkDependencies();
};
10 changes: 6 additions & 4 deletions lib/utils/forge-core.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
const { electronProjectPath } = require('./build-paths');

try {
module.exports = require(require.resolve('@electron-forge/core', {
paths: [electronProjectPath],
}));
module.exports = require(
require.resolve('@electron-forge/core', {
paths: [electronProjectPath],
}),
);
} catch (e) {
throw new Error(
[
`Unable to import '@electron-forge' from '${electronProjectPath}'`,
`-- make sure it's present in '${electronProjectPath}/package.json'`,
`and you've run 'yarn' or 'npm install' from '${electronProjectPath}'.`,
`Error:\n\n${e.stack}`,
].join(' ')
].join(' '),
);
}
4 changes: 2 additions & 2 deletions lib/utils/prepare-run-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ module.exports = async function prepareRun(project) {
`ember-electron's blueprint when you first ran 'ember install`,
`ember-electron'. If you are upgrading from ember-electron v2, you`,
`should read the upgrading documentation at ${upgradingUrl}.`,
].join(' ')
)
].join(' '),
),
);
}

Expand Down
18 changes: 9 additions & 9 deletions node-tests/acceptance/end-to-end-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('end-to-end', function () {
return listenForPrompts(
run(emberPath, args, {
stdio: ['pipe', 'pipe', process.stderr],
})
}),
);
}

Expand Down Expand Up @@ -100,14 +100,14 @@ describe('end-to-end', function () {
'ee-test-app',
'--yarn',
'--skip-git',
'--no-welcome'
'--no-welcome',
)
.then(() => {
process.chdir('ee-test-app');

return ember(
'install',
`ember-electron@${path.join(packageTmpDir, 'package')}`
`ember-electron@${path.join(packageTmpDir, 'package')}`,
);
})
.then(() => {
Expand Down Expand Up @@ -135,7 +135,7 @@ describe('end-to-end', function () {
'--yarn',
'false',
'--skip-git',
'--no-welcome'
'--no-welcome',
)
.then(() => {
process.chdir('ee-test-app');
Expand All @@ -154,9 +154,9 @@ describe('end-to-end', function () {
'install',
`ember-electron@${path.join(
packageTmpDir,
'ember-electron-cachebust.tar'
'ember-electron-cachebust.tar',
)}`,
'--no-yarn'
'--no-yarn',
);
})
.then(() => {
Expand Down Expand Up @@ -210,7 +210,7 @@ describe('end-to-end', function () {

let packageDir = path.join(
packageOutPath,
`ee-test-app-${process.platform}-${process.arch}`
`ee-test-app-${process.platform}-${process.arch}`,
);
expect(existsSync(packageDir)).to.be.ok;

Expand All @@ -235,15 +235,15 @@ describe('end-to-end', function () {
let configStr = readFileSync(configPath).toString();
writeFileSync(
configPath,
configStr.replace(`platforms: ['darwin'],`, '')
configStr.replace(`platforms: ['darwin'],`, ''),
);

// Only build zip target so we don't fail from missing platform dependencies
// (e.g. rpmbuild).
return ember(
'electron:make',
'--targets',
'@electron-forge/maker-zip'
'@electron-forge/maker-zip',
).then(() => {
expect(existsSync(path.join(packageOutPath, 'make'))).to.be.ok;
});
Expand Down
4 changes: 2 additions & 2 deletions node-tests/integration/commands/build-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('electron:build command', function () {
await expect(command.validateAndRun([])).to.be.fulfilled;
expect(baseRunStub).to.be.calledOnce;
expect(baseRunStub.firstCall.args[0].outputPath).to.equal(
path.join('electron-app', 'ember-dist')
path.join('electron-app', 'ember-dist'),
);
});

Expand All @@ -66,7 +66,7 @@ describe('electron:build command', function () {
'--watcher',
'polling',
'--suppress-sizes',
])
]),
).to.be.fulfilled;
expect(baseRunStub).to.be.calledOnce;
expect(baseRunStub.firstCall.args[0]).to.deep.equal({
Expand Down
6 changes: 3 additions & 3 deletions node-tests/integration/commands/electron-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('electron command', function () {
expect(startServerStub).to.be.calledOnce;
expect(api.start).to.be.calledOnce;
expect(api.start.firstCall).be.calledAfter(
mockBrocWatcher.currentBuild.then.firstCall
mockBrocWatcher.currentBuild.then.firstCall,
);
expect(api.start.firstCall).be.calledAfter(startServerStub.firstCall);
expect(cleanupBuilderStub).be.calledOnce;
Expand All @@ -125,7 +125,7 @@ describe('electron command', function () {
await expect(command.validateAndRun([])).to.be.fulfilled;
expect(api.start).to.be.calledOnce;
expect(api.start.firstCall.args[0].dir).to.equal(
path.resolve('electron-app')
path.resolve('electron-app'),
);
});

Expand Down Expand Up @@ -171,7 +171,7 @@ describe('electron command', function () {
'12345',
'--live-reload-prefix',
'lrlrlr',
])
]),
).to.be.fulfilled;
expect(startServerStub).to.be.calledOnce;
expect(startServerStub.firstCall.args[0]).to.deep.equal({
Expand Down
Loading

0 comments on commit a6a499a

Please sign in to comment.