Skip to content

Commit

Permalink
add prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed May 24, 2024
1 parent 458b770 commit 2f937f9
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
singleQuote: true,
};
13 changes: 7 additions & 6 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import globals from "globals";
import pluginJs from "@eslint/js";

import globals from 'globals';
import pluginJs from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';

export default [
{files: ["**/*.js"], languageOptions: {sourceType: "commonjs"}},
{languageOptions: { globals: globals.node }},
{ files: ['**/*.js'], languageOptions: { sourceType: 'commonjs' } },
{ languageOptions: { globals: globals.node } },
pluginJs.configs.recommended,
];
eslintPluginPrettierRecommended,
];
4 changes: 2 additions & 2 deletions files/babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ let config;
// function that wraps your whole babel config
if (
process.env.EMBROIDER_PREBUILD ||
process.env.EMBROIDER_TEST_SETUP_FORCE === "classic"
process.env.EMBROIDER_TEST_SETUP_FORCE === 'classic'
) {
config = {};
} else {
config = require("./node_modules/.embroider/_babel_config_");
config = require('./node_modules/.embroider/_babel_config_');
}

module.exports = config;
28 changes: 14 additions & 14 deletions files/vite.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from "vite";
import { defineConfig } from 'vite';
import {
resolver,
hbs,
Expand All @@ -8,18 +8,18 @@ import {
compatPrebuild,
assets,
contentFor,
} from "@embroider/vite";
import { resolve } from "path";
import { babel } from "@rollup/plugin-babel";
} from '@embroider/vite';
import { resolve } from 'path';
import { babel } from '@rollup/plugin-babel';

const root = "node_modules/.embroider/rewritten-app";
const root = 'node_modules/.embroider/rewritten-app';

export default defineConfig(({ mode }) => {
return {
root,
// esbuild in vite does not support decorators
esbuild: false,
cacheDir: resolve("node_modules", ".vite"),
cacheDir: resolve('node_modules', '.vite'),
plugins: [
hbs(),
templateTag(),
Expand All @@ -30,30 +30,30 @@ export default defineConfig(({ mode }) => {
contentFor(),

babel({
babelHelpers: "runtime",
babelHelpers: 'runtime',

// this needs .hbs because our hbs() plugin above converts them to
// javascript but the javascript still also needs babel, but we don't want
// to rename them because vite isn't great about knowing how to hot-reload
// them if we resolve them to made-up names.
extensions: [".gjs", ".js", ".hbs", ".ts", ".gts"],
extensions: ['.gjs', '.js', '.hbs', '.ts', '.gts'],
}),
],
optimizeDeps: optimizeDeps(),
publicDir: resolve(process.cwd(), "public"),
publicDir: resolve(process.cwd(), 'public'),
server: {
port: 4200,
watch: {
ignored: ["!**/node_modules/.embroider/rewritten-app/**"],
ignored: ['!**/node_modules/.embroider/rewritten-app/**'],
},
},
build: {
outDir: resolve(process.cwd(), "dist"),
outDir: resolve(process.cwd(), 'dist'),
rollupOptions: {
input: {
main: resolve(root, "index.html"),
main: resolve(root, 'index.html'),
...(shouldBuildTests(mode)
? { tests: resolve(root, "tests/index.html") }
? { tests: resolve(root, 'tests/index.html') }
: undefined),
},
},
Expand All @@ -62,5 +62,5 @@ export default defineConfig(({ mode }) => {
});

function shouldBuildTests(mode) {
return mode !== "production" || process.env.FORCE_BUILD_TESTS;
return mode !== 'production' || process.env.FORCE_BUILD_TESTS;
}
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
},

async afterInstall(options) {
// there doesn't seem to be a way to tell ember-cli to not prompt to override files that were added in the beforeInstall
// there doesn't seem to be a way to tell ember-cli to not prompt to override files that were added in the beforeInstall
// so I'm just copying a few over at this stage
await fs.copy(join(__dirname, 'files-override'), options.target, {
overwrite: true,
Expand All @@ -32,12 +32,12 @@ module.exports = {
'save-dev': true,
verbose: false,
packages: [
'@embroider/core@unstable',
'@embroider/core@unstable',
'@embroider/vite@unstable',
'@embroider/compat@unstable',
'@embroider/test-setup@unstable',
'vite',
'@rollup/plugin-babel'
'@rollup/plugin-babel',
],
packageManager: options.packageManager,
});
Expand All @@ -55,11 +55,11 @@ module.exports = {

json.scripts = {
...json.scripts,
"build": "vite build",
"start": "vite",
"test:ember": "vite build --mode test && ember test --path dist"
build: 'vite build',
start: 'vite',
'test:ember': 'vite build --mode test && ember test --path dist',
};

await fs.writeFile(packageJson, JSON.stringify(json, null, 2));
},
}
};
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
"devDependencies": {
"@eslint/js": "^9.3.0",
"eslint": "9.x",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"globals": "^15.3.0",
"prettier": "^3.2.5",
"release-plan": "^0.9.0"
}
}
70 changes: 69 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2f937f9

Please sign in to comment.