Skip to content

Commit 3d3d2fe

Browse files
committed
Use EsLint and Prettier in Mercury package
1 parent 72c6159 commit 3d3d2fe

File tree

6 files changed

+110
-11
lines changed

6 files changed

+110
-11
lines changed

packages/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"pixelmatch": "~7.1.0",
4242
"playwright": "*",
4343
"ts-lit-plugin": "~2.0.2",
44-
"typescript": "~5.5.3",
44+
"typescript": "~5.9.2",
4545
"typescript-eslint": "~8.32.0",
4646
"vite-plugin-static-copy": "~3.0.0",
4747
"vitest": "~3.1.1",

packages/mercury/eslint.config.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import { FlatCompat } from "@eslint/eslintrc";
2+
import js from "@eslint/js";
3+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
4+
import tsParser from "@typescript-eslint/parser";
5+
import { defineConfig } from "eslint/config";
6+
import globals from "globals";
7+
import path from "node:path";
8+
import { fileURLToPath } from "node:url";
9+
10+
const __filename = fileURLToPath(import.meta.url);
11+
const __dirname = path.dirname(__filename);
12+
const compat = new FlatCompat({
13+
baseDirectory: __dirname,
14+
recommendedConfig: js.configs.recommended,
15+
allConfig: js.configs.all
16+
});
17+
18+
export default defineConfig([
19+
{
20+
ignores: ["**/node_modules/*", "**/dist/*"],
21+
22+
files: ["**/*.ts", "**/*.js", "**.*.js"],
23+
24+
extends: compat.extends(
25+
"eslint:recommended",
26+
"plugin:@typescript-eslint/eslint-recommended",
27+
"plugin:@typescript-eslint/recommended"
28+
),
29+
30+
plugins: {
31+
"@typescript-eslint": typescriptEslint
32+
},
33+
34+
languageOptions: {
35+
globals: {
36+
...globals.browser
37+
},
38+
39+
parser: tsParser,
40+
ecmaVersion: "latest",
41+
sourceType: "module"
42+
},
43+
44+
rules: {
45+
// - - - - - - - - - - - -
46+
// ESLint
47+
// - - - - - - - - - - - -
48+
camelcase: "warn", // Enforce camelcase naming convention
49+
curly: "error", // Enforce consistent brace style for all control statements
50+
eqeqeq: ["warn", "always", { null: "ignore" }], // Require the use of === and !== "ignore" -------> Do not apply this rule to null
51+
"logical-assignment-operators": [
52+
"warn",
53+
"always",
54+
{ enforceForIfStatements: true }
55+
], // This rule checks for expressions that can be shortened using logical assignment operator
56+
"dot-notation": "warn", // This rule is aimed at maintaining code consistency and improving code readability by encouraging use of the dot notation style whenever possible. As such, it will warn when it encounters an unnecessary use of square-bracket notation.
57+
"max-depth": ["warn", 3], // Enforce a maximum depth that blocks can be nested. Many developers consider code difficult to read if blocks are nested beyond a certain depth
58+
"no-alert": "error", // Disallow the use of alert, confirm, and prompt
59+
"no-console": "warn", // Warning when using console.log, console.warn or console.error
60+
"no-else-return": ["warn", { allowElseIf: false }], // Disallow else blocks after return statements in if statements
61+
"no-extra-boolean-cast": "error", // Disallow unnecessary boolean casts
62+
"no-debugger": "error", // Error when using debugger;
63+
"no-duplicate-case": "error", // This rule disallows duplicate test expressions in case clauses of switch statements
64+
"no-empty": "error", // Disallow empty block statements
65+
"no-lonely-if": "error", // Disallow if statements as the only statement in else blocks
66+
"no-multi-assign": "error", // Disallow use of chained assignment expressions
67+
"no-nested-ternary": "error", // Errors when using nested ternary expressions
68+
"no-sequences": "error", // Disallow comma operators
69+
"no-undef": "off", // Allows defining undefined variables
70+
"no-unneeded-ternary": "error", // Disallow ternary operators when simpler alternatives exist
71+
"no-useless-return": "error", // Disallow redundant return statements
72+
"prefer-const": "error",
73+
"spaced-comment": ["error", "always", { exceptions: ["-", "+", "/"] }], // Enforce consistent spacing after the // or /* in a comment
74+
75+
"no-prototype-builtins": "off",
76+
77+
// - - - - - - - - - - - -
78+
// TypeScript
79+
// - - - - - - - - - - - -
80+
"@typescript-eslint/ban-types": "off",
81+
"@typescript-eslint/explicit-function-return-type": "off",
82+
"@typescript-eslint/explicit-module-boundary-types": "off",
83+
"@typescript-eslint/no-explicit-any": "error",
84+
"@typescript-eslint/no-empty-function": "off",
85+
"@typescript-eslint/no-non-null-assertion": "off"
86+
87+
// "@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }]
88+
}
89+
}
90+
]);
91+

packages/mercury/package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,33 @@
6464
"copy-tasks": "node copy-tasks.js",
6565
"coverage": "yarn playwright install && vitest watch run --coverage",
6666
"validate.ci": "yarn build-no-svg && yarn test",
67+
"lint": "eslint src/**/*.ts --fix",
6768
"test": "yarn playwright install && vitest",
6869
"test.watch": "yarn playwright install && vitest watch"
6970
},
7071
"license": "Apache-2.0",
7172
"devDependencies": {
73+
"@eslint/js": "~9.26.0",
7274
"@genexus/chameleon-controls-library": "~6.7.0",
7375
"@genexus/svg-sass-generator": "1.1.24",
7476
"@jackolope/ts-lit-plugin": "^3.1.4",
77+
"@types/node": "~22.10.5",
78+
"@typescript-eslint/eslint-plugin": "~8.32.0",
79+
"@typescript-eslint/parser": "~8.32.0",
7580
"@vitest/browser": "~3.1.1",
7681
"@vitest/coverage-v8": "~3.1.1",
7782
"@vitest/ui": "~3.1.1",
78-
"@types/node": "~22.10.5",
7983
"chokidar": "^3.6.0",
8084
"chokidar-cli": "^3.0.0",
8185
"esbuild": "0.25.0",
86+
"eslint": "~9.26.0",
87+
"globals": "~16.1.0",
8288
"playwright": "*",
89+
"prettier": "~3.5.3",
8390
"sass": "~1.86.3",
8491
"scss-bundle": "~3.1.2",
85-
"typescript": "~5.5.3",
92+
"typescript": "~5.9.2",
93+
"typescript-eslint": "~8.32.0",
8694
"vite": "~5.4.18",
8795
"vitest": "~3.1.1"
8896
}

packages/showcase/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@types/jasmine": "~5.1.5",
4141
"@types/node": "~22.10.5",
4242
"jasmine-core": "~5.2.0",
43-
"prettier": "~3.4.2",
43+
"prettier": "~3.5.3",
4444
"typescript": "~5.6.0"
4545
}
4646
}

packages/svg-sass-generator/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"devDependencies": {
3333
"@atao60/fse-cli": "^0.1.9",
3434
"esbuild": "^0.25.2",
35-
"prettier": "^3.5.3",
35+
"prettier": "~3.5.3",
3636
"tsx": "^4.19.3"
3737
}
3838
}

yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10682,16 +10682,11 @@ prepend-http@^2.0.0:
1068210682
resolved "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz"
1068310683
integrity sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA==
1068410684

10685-
prettier@^3.0.0, prettier@^3.5.3:
10685+
prettier@^3.0.0, prettier@~3.5.3:
1068610686
version "3.5.3"
1068710687
resolved "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz"
1068810688
integrity sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==
1068910689

10690-
prettier@~3.4.2:
10691-
version "3.4.2"
10692-
resolved "https://registry.npmjs.org/prettier/-/prettier-3.4.2.tgz"
10693-
integrity sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==
10694-
1069510690
pretty-bytes@^5.3.0:
1069610691
version "5.6.0"
1069710692
resolved "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz"
@@ -12663,6 +12658,11 @@ typescript@~5.6.0:
1266312658
resolved "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz"
1266412659
integrity sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==
1266512660

12661+
typescript@~5.9.2:
12662+
version "5.9.2"
12663+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.2.tgz#d93450cddec5154a2d5cabe3b8102b83316fb2a6"
12664+
integrity sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==
12665+
1266612666
uglify-js@3.4.x:
1266712667
version "3.4.10"
1266812668
resolved "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.10.tgz"

0 commit comments

Comments
 (0)