Skip to content

Commit

Permalink
Update Build (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
wandyezj authored Oct 19, 2024
1 parent 6a78022 commit 96a826c
Show file tree
Hide file tree
Showing 10 changed files with 2,349 additions and 2,441 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"prettier.configPath": "config/prettier.json",

"eslint.options": {
"configFile": "config/eslint.json",
"configFile": "config/eslint.mjs",
"resolvePluginsRelativeTo": "${workspaceFolder}"
},

Expand Down
100 changes: 0 additions & 100 deletions config/eslint.json

This file was deleted.

136 changes: 136 additions & 0 deletions config/eslint.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"),
{
plugins: {
"@typescript-eslint": typescriptEslint,
},

languageOptions: {
globals: {
...globals.browser,
...globals.node,
},

parser: tsParser,
ecmaVersion: "latest",
sourceType: "module",
},

rules: {
// https://eslint.org/docs/latest/rules/eqeqeq
// poka-yoke
eqeqeq: ["error", "always"],

// Indent is enforced by prettier
indent: "off",
"linebreak-style": ["warn", "unix"],

// https://eslint.org/docs/latest/rules/quotes
// consistency
quotes: [
"warn",
"double",
{
allowTemplateLiterals: true,
avoidEscape: true,
},
],

// https://eslint.org/docs/latest/rules/semi
// poka-yoke
semi: ["warn", "always"],
"no-debugger": "warn",

//
// Es Lint Rules
//

// https://typescript-eslint.io/rules/no-inferrable-types/
// disable - sometimes want to explicitly define types.
"@typescript-eslint/no-inferrable-types": 0,
// https://typescript-eslint.io/rules/no-var-requires/
// disable - require is used in node js scripts
"@typescript-eslint/no-var-requires": 0,

"@typescript-eslint/no-require-imports": 0,
"@typescript-eslint/no-unused-vars": [
"error",
{
caughtErrors: "none",
},
],

// https://typescript-eslint.io/rules/naming-convention/
// consistency
"@typescript-eslint/naming-convention": [
"warn",
{
selector: ["default"],
format: ["strictCamelCase"],
leadingUnderscore: "forbid",
trailingUnderscore: "forbid",
},
{
selector: ["parameter"],
modifiers: ["unused"],
format: ["strictCamelCase"],
leadingUnderscore: "allow",
trailingUnderscore: "forbid",
},
// Allow import of React
{
selector: "import",
format: ["camelCase", "PascalCase"],
},
{
selector: "function",
modifiers: ["exported"],
format: ["strictCamelCase", "StrictPascalCase"],
},
{
selector: ["variable"],
modifiers: ["const"],
format: ["strictCamelCase"],
leadingUnderscore: "forbid",
trailingUnderscore: "forbid",
},
{
selector: ["enumMember"],
format: ["PascalCase"],
leadingUnderscore: "forbid",
trailingUnderscore: "forbid",
},
{
selector: ["typeLike"],
format: ["StrictPascalCase"],
},
{
selector: ["interface"],
format: ["StrictPascalCase"],

custom: {
// Interface names must NOT be prefixed with I
regex: "^I[A-Z]",
match: false,
},
},
],
},
},
];
6 changes: 6 additions & 0 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ module.exports = async (env, options) => {
filename: isDevelopment ? "[name].bundle.js" : "[name].bundle-[contenthash].js",
path: path.resolve(__dirname, "..", "dist"),
},
optimization: {
runtimeChunk: "single",
splitChunks: {
chunks: "all",
},
},
resolve: {
extensions: [".ts", ".json", ".js", ".tsx"],
},
Expand Down
Loading

0 comments on commit 96a826c

Please sign in to comment.