@workleap/eslint-configs 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +201 -0
  3. package/README.md +16 -0
  4. package/dist/by-project-type/defineMonorepoWorkspaceConfig.d.ts +15 -0
  5. package/dist/by-project-type/defineMonorepoWorkspaceConfig.js +51 -0
  6. package/dist/by-project-type/defineMonorepoWorkspaceConfig.js.map +1 -0
  7. package/dist/by-project-type/defineReactLibraryConfig.d.ts +27 -0
  8. package/dist/by-project-type/defineReactLibraryConfig.js +96 -0
  9. package/dist/by-project-type/defineReactLibraryConfig.js.map +1 -0
  10. package/dist/by-project-type/defineTypescriptLibraryConfig.d.ts +19 -0
  11. package/dist/by-project-type/defineTypescriptLibraryConfig.js +72 -0
  12. package/dist/by-project-type/defineTypescriptLibraryConfig.js.map +1 -0
  13. package/dist/by-project-type/defineWebApplicationConfig.d.ts +27 -0
  14. package/dist/by-project-type/defineWebApplicationConfig.js +96 -0
  15. package/dist/by-project-type/defineWebApplicationConfig.js.map +1 -0
  16. package/dist/core.d.ts +7 -0
  17. package/dist/core.js +184 -0
  18. package/dist/core.js.map +1 -0
  19. package/dist/index.d.ts +15 -0
  20. package/dist/index.js +22 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/jest.d.ts +7 -0
  23. package/dist/jest.js +55 -0
  24. package/dist/jest.js.map +1 -0
  25. package/dist/jsxAlly.d.ts +7 -0
  26. package/dist/jsxAlly.js +51 -0
  27. package/dist/jsxAlly.js.map +1 -0
  28. package/dist/packageJson.d.ts +7 -0
  29. package/dist/packageJson.js +47 -0
  30. package/dist/packageJson.js.map +1 -0
  31. package/dist/plugins/strictCssModulesNames.d.ts +7 -0
  32. package/dist/plugins/strictCssModulesNames.js +70 -0
  33. package/dist/plugins/strictCssModulesNames.js.map +1 -0
  34. package/dist/plugins/workleapPlugin.d.ts +5 -0
  35. package/dist/plugins/workleapPlugin.js +15 -0
  36. package/dist/plugins/workleapPlugin.js.map +1 -0
  37. package/dist/react.d.ts +7 -0
  38. package/dist/react.js +189 -0
  39. package/dist/react.js.map +1 -0
  40. package/dist/storybook.d.ts +8 -0
  41. package/dist/storybook.js +46 -0
  42. package/dist/storybook.js.map +1 -0
  43. package/dist/testingLibrary.d.ts +8 -0
  44. package/dist/testingLibrary.js +43 -0
  45. package/dist/testingLibrary.js.map +1 -0
  46. package/dist/types.d.ts +19 -0
  47. package/dist/types.js +9 -0
  48. package/dist/types.js.map +1 -0
  49. package/dist/typescript.d.ts +7 -0
  50. package/dist/typescript.js +139 -0
  51. package/dist/typescript.js.map +1 -0
  52. package/dist/vitest.d.ts +7 -0
  53. package/dist/vitest.js +40 -0
  54. package/dist/vitest.js.map +1 -0
  55. package/dist/yaml.d.ts +7 -0
  56. package/dist/yaml.js +31 -0
  57. package/dist/yaml.js.map +1 -0
  58. package/package.json +82 -0
  59. package/src/by-project-type/defineMonorepoWorkspaceConfig.ts +45 -0
  60. package/src/by-project-type/defineReactLibraryConfig.ts +81 -0
  61. package/src/by-project-type/defineTypescriptLibraryConfig.ts +61 -0
  62. package/src/by-project-type/defineWebApplicationConfig.ts +114 -0
  63. package/src/core.ts +138 -0
  64. package/src/index.ts +16 -0
  65. package/src/jest.ts +53 -0
  66. package/src/jsxAlly.ts +52 -0
  67. package/src/packageJson.ts +48 -0
  68. package/src/plugins/strictCssModulesNames.ts +75 -0
  69. package/src/plugins/workleapPlugin.ts +7 -0
  70. package/src/react.ts +175 -0
  71. package/src/storybook.ts +53 -0
  72. package/src/testingLibrary.ts +48 -0
  73. package/src/types.ts +27 -0
  74. package/src/typescript.ts +133 -0
  75. package/src/vitest.ts +41 -0
  76. package/src/yaml.ts +32 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescript.js","sources":["webpack://@workleap/eslint-configs/./src/typescript.ts"],"sourcesContent":["import js from \"@eslint/js\";\nimport stylisticPlugin from \"@stylistic/eslint-plugin\";\nimport type { Linter } from \"eslint\";\nimport tseslint from \"typescript-eslint\";\nimport type { ConfigWithExtends } from \"./types.ts\";\n\nexport interface TypescriptConfigOptions {\n rules?: Partial<Linter.RulesRecord>;\n}\n\nexport const typescriptGlobalIgnores = [];\n\nexport function typescriptConfig(tsconfigRootDir: string, options: TypescriptConfigOptions = {}) {\n const {\n rules = {}\n } = options;\n\n const config: ConfigWithExtends[] = [{\n name: \"@workleap/eslint-configs/typescript\",\n files: [\n \"**/*.{ts,tsx}\"\n ],\n plugins: {\n \"@stylistic\": stylisticPlugin\n },\n extends: [\n js.configs.recommended,\n tseslint.configs.recommendedTypeChecked,\n tseslint.configs.stylisticTypeCheckedOnly,\n stylisticPlugin.configs.customize({\n braceStyle: \"1tbs\",\n commaDangle: \"never\",\n jsx: false,\n quotes: \"double\",\n semi: true,\n severity: \"warn\"\n })\n ],\n languageOptions: {\n parser: tseslint.parser,\n parserOptions: {\n // Rely on TypeScript's project service to automatically discover the \"tsconfig.json\" file\n // within the boundaries of \"tsconfigRootDir\".\n projectService: true,\n tsconfigRootDir\n }\n },\n rules: {\n // ESLint core rules overrides\n \"dot-notation\": \"off\",\n \"indent\": \"off\",\n \"no-dupe-class-members\": \"off\",\n \"no-empty-function\": \"off\",\n \"no-loop-func\": \"off\",\n \"no-shadow\": \"off\",\n \"no-unused-expressions\": \"off\",\n \"no-use-before-define\": \"off\",\n \"no-useless-constructor\": \"off\",\n \"object-curly-spacing\": \"off\",\n \"quotes\": \"off\",\n \"semi\": \"off\",\n\n // ESlint deprecated core rules\n \"arrow-parens\": \"off\",\n \"comma-dangle\": \"off\",\n\n // @typescript-eslint recommended rules overrides\n \"@typescript-eslint/dot-notation\": \"off\",\n \"@typescript-eslint/no-base-to-string\": \"off\",\n \"@typescript-eslint/no-empty-function\": \"off\",\n \"@typescript-eslint/no-empty-object-type\": [\n \"error\",\n {\n allowInterfaces: \"with-single-extends\",\n allowObjectTypes: \"never\"\n }\n ],\n \"@typescript-eslint/no-floating-promises\": \"off\",\n \"@typescript-eslint/no-non-null-assertion\": \"off\",\n \"@typescript-eslint/no-unsafe-argument\": \"off\",\n \"@typescript-eslint/no-unsafe-assignment\": \"off\",\n \"@typescript-eslint/no-unsafe-member-access\": \"off\",\n \"@typescript-eslint/only-throw-error\": \"off\",\n \"@typescript-eslint/prefer-nullish-coalescing\": \"off\",\n \"@typescript-eslint/restrict-template-expressions\": \"off\",\n\n // @stylistic recommend rules overrides\n \"@stylistic/arrow-parens\": [\n \"warn\",\n \"as-needed\",\n {\n requireForBlockBody: false\n }\n ],\n \"@stylistic/indent\": [\n \"warn\",\n 4,\n {\n SwitchCase: 1,\n CallExpression: { arguments: \"first\" }\n }\n ],\n \"@stylistic/indent-binary-ops\": [\"warn\", 4],\n \"@stylistic/member-delimiter-style\": [\n \"warn\",\n {\n multiline: {\n delimiter: \"semi\"\n },\n singleline: {\n delimiter: \"semi\"\n }\n }\n ],\n \"@stylistic/multiline-ternary\": \"off\",\n \"@stylistic/no-multiple-empty-lines\": [\n \"warn\",\n {\n // View https://eslint.style/rules/eol-last.\n max: 1\n }\n ],\n \"@stylistic/operator-linebreak\": \"off\",\n // Should be the default but somehow it's not enforced if it's not explicitly specified.\n \"@stylistic/quote-props\": \"off\",\n\n // Positioned last to allow the consumer to override any rules.\n ...rules\n }\n }];\n\n return config;\n};\n"],"names":["js","stylisticPlugin","tseslint","typescriptGlobalIgnores","typescriptConfig","tsconfigRootDir","options","rules","config"],"mappings":";;;;;;;;;;;AAA4B;AAC2B;AAEd;AAOlC,MAAMG,0BAA0B,EAAE,CAAC;AAEnC,SAASC,iBAAiBC,eAAuB,EAAEC,UAAmC,CAAC,CAAC;IAC3F,MAAM,EACFC,QAAQ,CAAC,CAAC,EACb,GAAGD;IAEJ,MAAME,SAA8B;QAAC;YACjC,MAAM;YACN,OAAO;gBACH;aACH;YACD,SAAS;gBACL,cAAcP,aAAeA;YACjC;YACA,SAAS;gBACLD,sBAAsB;gBACtBE,gDAAuC;gBACvCA,kDAAyC;gBACzCD,+BAAiC,CAAC;oBAC9B,YAAY;oBACZ,aAAa;oBACb,KAAK;oBACL,QAAQ;oBACR,MAAM;oBACN,UAAU;gBACd;aACH;YACD,iBAAiB;gBACb,QAAQC,wBAAe;gBACvB,eAAe;oBACX,0FAA0F;oBAC1F,8CAA8C;oBAC9C,gBAAgB;oBAChBG;gBACJ;YACJ;YACA,OAAO;gBACH,8BAA8B;gBAC9B,gBAAgB;gBAChB,UAAU;gBACV,yBAAyB;gBACzB,qBAAqB;gBACrB,gBAAgB;gBAChB,aAAa;gBACb,yBAAyB;gBACzB,wBAAwB;gBACxB,0BAA0B;gBAC1B,wBAAwB;gBACxB,UAAU;gBACV,QAAQ;gBAER,+BAA+B;gBAC/B,gBAAgB;gBAChB,gBAAgB;gBAEhB,iDAAiD;gBACjD,mCAAmC;gBACnC,wCAAwC;gBACxC,wCAAwC;gBACxC,2CAA2C;oBACvC;oBACA;wBACI,iBAAiB;wBACjB,kBAAkB;oBACtB;iBACH;gBACD,2CAA2C;gBAC3C,4CAA4C;gBAC5C,yCAAyC;gBACzC,2CAA2C;gBAC3C,8CAA8C;gBAC9C,uCAAuC;gBACvC,gDAAgD;gBAChD,oDAAoD;gBAEpD,uCAAuC;gBACvC,2BAA2B;oBACvB;oBACA;oBACA;wBACI,qBAAqB;oBACzB;iBACH;gBACD,qBAAqB;oBACjB;oBACA;oBACA;wBACI,YAAY;wBACZ,gBAAgB;4BAAE,WAAW;wBAAQ;oBACzC;iBACH;gBACD,gCAAgC;oBAAC;oBAAQ;iBAAE;gBAC3C,qCAAqC;oBACjC;oBACA;wBACI,WAAW;4BACP,WAAW;wBACf;wBACA,YAAY;4BACR,WAAW;wBACf;oBACJ;iBACH;gBACD,gCAAgC;gBAChC,sCAAsC;oBAClC;oBACA;wBACI,4CAA4C;wBAC5C,KAAK;oBACT;iBACH;gBACD,iCAAiC;gBACjC,wFAAwF;gBACxF,0BAA0B;gBAE1B,+DAA+D;gBAC/D,GAAGE,KAAK;YACZ;QACJ;KAAE;IAEF,OAAOC;AACX"}
@@ -0,0 +1,7 @@
1
+ import type { Linter } from "eslint";
2
+ import type { ConfigWithExtends } from "./types.ts";
3
+ export interface VitestConfigOptions {
4
+ rules?: Partial<Linter.RulesRecord>;
5
+ }
6
+ export declare const vitestGlobalIgnores: never[];
7
+ export declare function vitestConfig(options?: VitestConfigOptions): ConfigWithExtends[];
package/dist/vitest.js ADDED
@@ -0,0 +1,40 @@
1
+ import eslint_plugin from "@vitest/eslint-plugin";
2
+
3
+ ;// CONCATENATED MODULE: external "@vitest/eslint-plugin"
4
+
5
+ ;// CONCATENATED MODULE: ./src/vitest.ts
6
+
7
+ const vitestGlobalIgnores = [];
8
+ function vitestConfig(options = {}) {
9
+ const { rules = {} } = options;
10
+ const config = [
11
+ {
12
+ name: "@workleap/eslint-configs/vitest",
13
+ files: [
14
+ "**/*.test.{js,jsx,ts,tsx}",
15
+ "**/*-test.{js,jsx,ts,tsx}",
16
+ "**/__tests__/*.{js,jsx,ts,tsx}",
17
+ "**/test.{js,jsx,ts,tsx}"
18
+ ],
19
+ plugins: {
20
+ // @ts-expect-error temporary code until defineConfig is supported.
21
+ vitest: eslint_plugin
22
+ },
23
+ // Waiting for defineConfig support: https://github.com/vitest-dev/eslint-plugin-vitest/issues/771
24
+ // extends: [
25
+ // vitestPlugin.configs.recommended
26
+ // ],
27
+ rules: {
28
+ ...eslint_plugin.configs.recommended.rules,
29
+ "vitest/no-commented-out-tests": "off",
30
+ // Positioned last to allow the consumer to override any rules.
31
+ ...rules
32
+ }
33
+ }
34
+ ];
35
+ return config;
36
+ }
37
+
38
+ export { vitestConfig, vitestGlobalIgnores };
39
+
40
+ //# sourceMappingURL=vitest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.js","sources":["webpack://@workleap/eslint-configs/./src/vitest.ts"],"sourcesContent":["import vitestPlugin from \"@vitest/eslint-plugin\";\nimport type { Linter } from \"eslint\";\nimport type { ConfigWithExtends } from \"./types.ts\";\n\nexport interface VitestConfigOptions {\n rules?: Partial<Linter.RulesRecord>;\n}\n\nexport const vitestGlobalIgnores = [];\n\nexport function vitestConfig(options: VitestConfigOptions = {}) {\n const {\n rules = {}\n } = options;\n\n const config: ConfigWithExtends[] = [{\n name: \"@workleap/eslint-configs/vitest\",\n files: [\n \"**/*.test.{js,jsx,ts,tsx}\",\n \"**/*-test.{js,jsx,ts,tsx}\",\n \"**/__tests__/*.{js,jsx,ts,tsx}\",\n \"**/test.{js,jsx,ts,tsx}\"\n ],\n plugins: {\n // @ts-expect-error temporary code until defineConfig is supported.\n vitest: vitestPlugin\n },\n // Waiting for defineConfig support: https://github.com/vitest-dev/eslint-plugin-vitest/issues/771\n // extends: [\n // vitestPlugin.configs.recommended\n // ],\n rules: {\n ...vitestPlugin.configs.recommended.rules,\n \"vitest/no-commented-out-tests\": \"off\",\n // Positioned last to allow the consumer to override any rules.\n ...rules\n }\n }];\n\n return config;\n};\n"],"names":["vitestPlugin","vitestGlobalIgnores","vitestConfig","options","rules","config"],"mappings":";;;;;AAAiD;AAQ1C,MAAMC,sBAAsB,EAAE,CAAC;AAE/B,SAASC,aAAaC,UAA+B,CAAC,CAAC;IAC1D,MAAM,EACFC,QAAQ,CAAC,CAAC,EACb,GAAGD;IAEJ,MAAME,SAA8B;QAAC;YACjC,MAAM;YACN,OAAO;gBACH;gBACA;gBACA;gBACA;aACH;YACD,SAAS;gBACL,mEAAmE;gBACnE,QAAQL,aAAYA;YACxB;YACA,kGAAkG;YAClG,aAAa;YACb,uCAAuC;YACvC,KAAK;YACL,OAAO;gBACH,GAAGA,uCAAsC;gBACzC,iCAAiC;gBACjC,+DAA+D;gBAC/D,GAAGI,KAAK;YACZ;QACJ;KAAE;IAEF,OAAOC;AACX"}
package/dist/yaml.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import type { Linter } from "eslint";
2
+ import type { ConfigWithExtends } from "./types.ts";
3
+ export interface YamlConfigOptions {
4
+ rules?: Partial<Linter.RulesRecord>;
5
+ }
6
+ export declare const yamlGlobalIgnores: string[];
7
+ export declare function yamlConfig(options?: YamlConfigOptions): ConfigWithExtends[];
package/dist/yaml.js ADDED
@@ -0,0 +1,31 @@
1
+ import eslint_plugin_yaml from "eslint-plugin-yaml";
2
+
3
+ ;// CONCATENATED MODULE: external "eslint-plugin-yaml"
4
+
5
+ ;// CONCATENATED MODULE: ./src/yaml.ts
6
+
7
+ const yamlGlobalIgnores = [
8
+ "pnpm-lock.yaml"
9
+ ];
10
+ function yamlConfig(options = {}) {
11
+ const { rules = {} } = options;
12
+ const config = [
13
+ {
14
+ name: "@workleap/eslint-configs/yaml",
15
+ files: [
16
+ "**/*.yaml",
17
+ "**/*.yml"
18
+ ],
19
+ extends: [
20
+ // @ts-expect-error the typings are broken.
21
+ eslint_plugin_yaml.configs.recommended
22
+ ],
23
+ rules
24
+ }
25
+ ];
26
+ return config;
27
+ }
28
+
29
+ export { yamlConfig, yamlGlobalIgnores };
30
+
31
+ //# sourceMappingURL=yaml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml.js","sources":["webpack://@workleap/eslint-configs/./src/yaml.ts"],"sourcesContent":["import type { Linter } from \"eslint\";\nimport yamlPlugin from \"eslint-plugin-yaml\";\nimport type { ConfigWithExtends } from \"./types.ts\";\n\nexport interface YamlConfigOptions {\n rules?: Partial<Linter.RulesRecord>;\n}\n\nexport const yamlGlobalIgnores = [\n \"pnpm-lock.yaml\"\n];\n\nexport function yamlConfig(options: YamlConfigOptions = {}) {\n const {\n rules = {}\n } = options;\n\n const config: ConfigWithExtends[] = [{\n name: \"@workleap/eslint-configs/yaml\",\n files: [\n \"**/*.yaml\",\n \"**/*.yml\"\n ],\n extends: [\n // @ts-expect-error the typings are broken.\n yamlPlugin.configs.recommended\n ],\n rules\n }];\n\n return config;\n};\n"],"names":["yamlPlugin","yamlGlobalIgnores","yamlConfig","options","rules","config"],"mappings":";;;;;AAC4C;AAOrC,MAAMC,oBAAoB;IAC7B;CACH,CAAC;AAEK,SAASC,WAAWC,UAA6B,CAAC,CAAC;IACtD,MAAM,EACFC,QAAQ,CAAC,CAAC,EACb,GAAGD;IAEJ,MAAME,SAA8B;QAAC;YACjC,MAAM;YACN,OAAO;gBACH;gBACA;aACH;YACD,SAAS;gBACL,2CAA2C;gBAC3CL,sCAA8B;aACjC;YACDI;QACJ;KAAE;IAEF,OAAOC;AACX"}
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "@workleap/eslint-configs",
3
+ "author": "Workleap",
4
+ "description": "Workleap recommended ESLint configurations.",
5
+ "version": "0.0.2",
6
+ "license": "Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/workleap/wl-web-configs.git",
10
+ "directory": "packages/eslint-configs"
11
+ },
12
+ "type": "module",
13
+ "publishConfig": {
14
+ "access": "public",
15
+ "provenance": true
16
+ },
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js",
21
+ "default": "./dist/index.js"
22
+ }
23
+ },
24
+ "files": [
25
+ "src",
26
+ "dist",
27
+ "CHANGELOG.md"
28
+ ],
29
+ "peerDependencies": {
30
+ "@eslint/js": "^9.38.0",
31
+ "@typescript-eslint/parser": "^8.46.2",
32
+ "eslint": "^9.38.0",
33
+ "storybook": "^9.1.13",
34
+ "typescript": "^5.9.3",
35
+ "typescript-eslint": "^8.46.2"
36
+ },
37
+ "peerDependenciesMeta": {
38
+ "@typescript-eslint/parser": {
39
+ "optional": true
40
+ },
41
+ "storybook": {
42
+ "optional": true
43
+ },
44
+ "typescript-eslint": {
45
+ "optional": true
46
+ },
47
+ "typescript": {
48
+ "optional": true
49
+ }
50
+ },
51
+ "dependencies": {
52
+ "@stylistic/eslint-plugin": "^5.5.0",
53
+ "@vitest/eslint-plugin": "^1.3.23",
54
+ "eslint-plugin-import": "^2.32.0",
55
+ "eslint-plugin-jest": "^29.0.1",
56
+ "eslint-plugin-jsx-a11y": "^6.10.2",
57
+ "eslint-plugin-package-json": "^0.58.0",
58
+ "eslint-plugin-react": "^7.37.5",
59
+ "eslint-plugin-react-hooks": "^7.0.0",
60
+ "eslint-plugin-storybook": "^9.1.13",
61
+ "eslint-plugin-testing-library": "^7.13.3",
62
+ "eslint-plugin-yaml": "^1.1.3",
63
+ "globals": "^16.4.0"
64
+ },
65
+ "devDependencies": {
66
+ "@eslint/js": "9.38.0",
67
+ "@rsbuild/core": "1.5.17",
68
+ "@rslib/core": "0.16.0",
69
+ "@types/eslint-plugin-jsx-a11y": "6.10.1",
70
+ "@types/estree": "1.0.8",
71
+ "@types/node": "24.9.1",
72
+ "eslint": "9.38.0",
73
+ "typescript": "5.9.3",
74
+ "typescript-eslint": "8.46.2",
75
+ "@workleap/typescript-configs": "3.0.6"
76
+ },
77
+ "scripts": {
78
+ "build": "rslib build -c rslib.config.ts",
79
+ "eslint": "eslint . --max-warnings=-0 --cache --cache-location node_modules/.cache/eslint",
80
+ "typecheck": "tsc"
81
+ }
82
+ }
@@ -0,0 +1,45 @@
1
+ import { defineConfig, globalIgnores } from "eslint/config";
2
+ import { coreConfig, type CoreConfigOptions, coreGlobalIgnores } from "../core.ts";
3
+ import { packageJsonConfig, type PackageJsonConfigOptions, packageJsonGlobalIgnores } from "../packageJson.ts";
4
+ import { typescriptConfig, type TypescriptConfigOptions, typescriptGlobalIgnores } from "../typescript.ts";
5
+ import { yamlConfig, type YamlConfigOptions, yamlGlobalIgnores } from "../yaml.ts";
6
+
7
+ export interface DefineMonorepoWorkspaceConfigOptions {
8
+ core?: CoreConfigOptions;
9
+ packageJson?: PackageJsonConfigOptions;
10
+ typescript?: TypescriptConfigOptions;
11
+ yaml?: YamlConfigOptions;
12
+ }
13
+
14
+ /**
15
+ * @param tsconfigRootDir The directory of the tsconfig file to use for rules that needs a TypeScript type check: https://typescript-eslint.io/packages/parser/#tsconfigrootdir.
16
+ * @param options An optional object of options for the ESlint core and plugins rules.
17
+ */
18
+ export function defineMonorepoWorkspaceConfig(tsconfigRootDir: string, options: DefineMonorepoWorkspaceConfigOptions = {}) {
19
+ const {
20
+ core,
21
+ packageJson,
22
+ typescript,
23
+ yaml
24
+ } = options;
25
+
26
+ return defineConfig([
27
+ // node_modules folder is ignored by default.
28
+ globalIgnores([
29
+ "dist",
30
+ ...coreGlobalIgnores,
31
+ ...packageJsonGlobalIgnores,
32
+ ...typescriptGlobalIgnores,
33
+ ...yamlGlobalIgnores
34
+ ]),
35
+ ...coreConfig(core),
36
+ ...packageJsonConfig(packageJson),
37
+ ...typescriptConfig(tsconfigRootDir, typescript),
38
+ ...yamlConfig(yaml),
39
+ {
40
+ rules: {
41
+ "package-json/valid-version": "off"
42
+ }
43
+ }
44
+ ]);
45
+ }
@@ -0,0 +1,81 @@
1
+ import { defineConfig, globalIgnores } from "eslint/config";
2
+ import { coreConfig, type CoreConfigOptions, coreGlobalIgnores } from "../core.ts";
3
+ import { jestConfig, type JestConfigOptions, jestGlobalIgnores } from "../jest.ts";
4
+ import { jsxAllyConfig, type JsxAllyConfigOptions, jsxAllyGlobalIgnores } from "../jsxAlly.ts";
5
+ import { packageJsonConfig, type PackageJsonConfigOptions, packageJsonGlobalIgnores } from "../packageJson.ts";
6
+ import { WorkleapPlugin } from "../plugins/workleapPlugin.ts";
7
+ import { reactConfig, type ReactConfigOptions, reactGlobalIgnores } from "../react.ts";
8
+ import { storybookConfig, type StorybookConfigOptions, storybookGlobalIgnores } from "../storybook.ts";
9
+ import { testingLibraryConfig, type TestingLibraryConfigOptions, testingLibraryGlobalIgnores } from "../testingLibrary.ts";
10
+ import { typescriptConfig, type TypescriptConfigOptions, typescriptGlobalIgnores } from "../typescript.ts";
11
+ import { vitestConfig, type VitestConfigOptions, vitestGlobalIgnores } from "../vitest.ts";
12
+ import { yamlConfig, type YamlConfigOptions, yamlGlobalIgnores } from "../yaml.ts";
13
+
14
+ export interface DefineReactLibraryConfigOptions {
15
+ core?: CoreConfigOptions;
16
+ jest?: JestConfigOptions;
17
+ jsxAlly?: JsxAllyConfigOptions;
18
+ packageJson?: PackageJsonConfigOptions;
19
+ react?: ReactConfigOptions;
20
+ storybook?: StorybookConfigOptions;
21
+ testingLibrary?: TestingLibraryConfigOptions;
22
+ typescript?: TypescriptConfigOptions;
23
+ vitest?: VitestConfigOptions;
24
+ yaml?: YamlConfigOptions;
25
+ }
26
+
27
+ /**
28
+ * @param tsconfigRootDir The directory of the tsconfig file to use for rules that needs a TypeScript type check: https://typescript-eslint.io/packages/parser/#tsconfigrootdir.
29
+ * @param options An optional object of options for the ESlint core and plugins rules.
30
+ */
31
+ export function defineReactLibraryConfig(tsconfigRootDir: string, options: DefineReactLibraryConfigOptions = {}) {
32
+ const {
33
+ core,
34
+ jest,
35
+ jsxAlly,
36
+ packageJson,
37
+ react,
38
+ storybook,
39
+ testingLibrary,
40
+ typescript,
41
+ vitest,
42
+ yaml
43
+ } = options;
44
+
45
+ return defineConfig([
46
+ // node_modules folder is ignored by default.
47
+ globalIgnores([
48
+ "dist",
49
+ ...coreGlobalIgnores,
50
+ ...jestGlobalIgnores,
51
+ ...jsxAllyGlobalIgnores,
52
+ ...packageJsonGlobalIgnores,
53
+ ...reactGlobalIgnores,
54
+ ...storybookGlobalIgnores,
55
+ ...testingLibraryGlobalIgnores,
56
+ ...typescriptGlobalIgnores,
57
+ ...vitestGlobalIgnores,
58
+ ...yamlGlobalIgnores
59
+ ]),
60
+ ...coreConfig(core),
61
+ ...jestConfig(jest),
62
+ ...jsxAllyConfig(jsxAlly),
63
+ ...packageJsonConfig(packageJson),
64
+ ...reactConfig(react),
65
+ ...storybookConfig(storybook),
66
+ ...testingLibraryConfig(testingLibrary),
67
+ ...typescriptConfig(tsconfigRootDir, typescript),
68
+ // Temporary fix until the vitest plugin support defineConfig and the types are fixed.
69
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
+ ...(vitestConfig(vitest) as any),
71
+ ...yamlConfig(yaml),
72
+ {
73
+ plugins: {
74
+ "@workleap": WorkleapPlugin
75
+ },
76
+ rules: {
77
+ "@workleap/strict-css-modules-names": "warn"
78
+ }
79
+ }
80
+ ]);
81
+ }
@@ -0,0 +1,61 @@
1
+ import { defineConfig, globalIgnores } from "eslint/config";
2
+ import { coreConfig, type CoreConfigOptions, coreGlobalIgnores } from "../core.ts";
3
+ import { jestConfig, type JestConfigOptions, jestGlobalIgnores } from "../jest.ts";
4
+ import { packageJsonConfig, type PackageJsonConfigOptions, packageJsonGlobalIgnores } from "../packageJson.ts";
5
+ import { WorkleapPlugin } from "../plugins/workleapPlugin.ts";
6
+ import { typescriptConfig, type TypescriptConfigOptions, typescriptGlobalIgnores } from "../typescript.ts";
7
+ import { vitestConfig, type VitestConfigOptions, vitestGlobalIgnores } from "../vitest.ts";
8
+ import { yamlConfig, type YamlConfigOptions, yamlGlobalIgnores } from "../yaml.ts";
9
+
10
+ export interface DefineTypeScriptLibraryConfigOptions {
11
+ core?: CoreConfigOptions;
12
+ typescript?: TypescriptConfigOptions;
13
+ jest?: JestConfigOptions;
14
+ vitest?: VitestConfigOptions;
15
+ packageJson?: PackageJsonConfigOptions;
16
+ yaml?: YamlConfigOptions;
17
+ }
18
+
19
+ /**
20
+ * @param tsconfigRootDir The directory of the tsconfig file to use for rules that needs a TypeScript type check: https://typescript-eslint.io/packages/parser/#tsconfigrootdir.
21
+ * @param options An optional object of options for the ESlint core and plugins rules.
22
+ */
23
+ export function defineTypeScriptLibraryConfig(tsconfigRootDir: string, options: DefineTypeScriptLibraryConfigOptions = {}) {
24
+ const {
25
+ core,
26
+ jest,
27
+ packageJson,
28
+ typescript,
29
+ vitest,
30
+ yaml
31
+ } = options;
32
+
33
+ return defineConfig([
34
+ // node_modules folder is ignored by default.
35
+ globalIgnores([
36
+ "dist",
37
+ ...coreGlobalIgnores,
38
+ ...jestGlobalIgnores,
39
+ ...packageJsonGlobalIgnores,
40
+ ...typescriptGlobalIgnores,
41
+ ...vitestGlobalIgnores,
42
+ ...yamlGlobalIgnores
43
+ ]),
44
+ ...coreConfig(core),
45
+ ...jestConfig(jest),
46
+ ...packageJsonConfig(packageJson),
47
+ ...typescriptConfig(tsconfigRootDir, typescript),
48
+ // Temporary fix until the vitest plugin support defineConfig and the types are fixed.
49
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
+ ...(vitestConfig(vitest) as any),
51
+ ...yamlConfig(yaml),
52
+ {
53
+ plugins: {
54
+ "@workleap": WorkleapPlugin
55
+ },
56
+ rules: {
57
+ "@workleap/strict-css-modules-names": "warn"
58
+ }
59
+ }
60
+ ]);
61
+ }
@@ -0,0 +1,114 @@
1
+ import { defineConfig, globalIgnores } from "eslint/config";
2
+ import { coreConfig, type CoreConfigOptions, coreGlobalIgnores } from "../core.ts";
3
+ import { jestConfig, type JestConfigOptions, jestGlobalIgnores } from "../jest.ts";
4
+ import { jsxAllyConfig, type JsxAllyConfigOptions, jsxAllyGlobalIgnores } from "../jsxAlly.ts";
5
+ import { packageJsonConfig, type PackageJsonConfigOptions, packageJsonGlobalIgnores } from "../packageJson.ts";
6
+ import { WorkleapPlugin } from "../plugins/workleapPlugin.ts";
7
+ import { reactConfig, type ReactConfigOptions, reactGlobalIgnores } from "../react.ts";
8
+ import { storybookConfig, type StorybookConfigOptions, storybookGlobalIgnores } from "../storybook.ts";
9
+ import { testingLibraryConfig, type TestingLibraryConfigOptions, testingLibraryGlobalIgnores } from "../testingLibrary.ts";
10
+ import { typescriptConfig, type TypescriptConfigOptions, typescriptGlobalIgnores } from "../typescript.ts";
11
+ import { vitestConfig, type VitestConfigOptions, vitestGlobalIgnores } from "../vitest.ts";
12
+ import { yamlConfig, type YamlConfigOptions, yamlGlobalIgnores } from "../yaml.ts";
13
+
14
+ /*
15
+
16
+ The WHY for the interface instead of using nested "extends".
17
+
18
+ 1- ESlint flat config doesn't support nested "extends":
19
+
20
+ Each configuration object may have an extends key, but only at the top level — not inside another config that already came from an extends.
21
+
22
+ Flat config was designed to be explicitly ordered and fully expanded:
23
+
24
+ - "extends" in flat config is syntactic sugar for concatenating multiple config objects.
25
+ - Allowing recursion would make config evaluation order ambiguous and slow.
26
+
27
+ So ESLint enforces a one-level-deep rule:
28
+
29
+ - only a top-level config object can have extends.
30
+
31
+ 2- Each object in the array is evaluated independently. "plugins" declared in one object are not inherited by the next object.
32
+ So when a second object sets the rule using a plugin "xyz", it doesn’t "see" the plugin "xyz" that’s defined inside a predefine config, and ESLint throws.
33
+
34
+ 3- Trying to redefine a plugin that as already been define in a configuration object will throw: Cannot redefine plugin "xyz".
35
+
36
+ */
37
+
38
+ /*
39
+
40
+ error Parsing error: C:\Dev\workleap\wl-web-configs\samples\storybook\rsbuild\.storybook\main.ts was not found by the project service. Consider either including it in the tsconfig.json or including it in allowDefaultProject
41
+
42
+ -> It usually means that the project tsconfig.json file cannot find the specified file
43
+ -> Make sure to clear the ESLint cache after such an error because update the tsconfig.json file doesn't invalidate the ESLint cache
44
+
45
+ */
46
+
47
+ export interface DefineWebApplicationConfigOptions {
48
+ core?: CoreConfigOptions;
49
+ typescript?: TypescriptConfigOptions;
50
+ react?: ReactConfigOptions;
51
+ jsxAlly?: JsxAllyConfigOptions;
52
+ jest?: JestConfigOptions;
53
+ vitest?: VitestConfigOptions;
54
+ testingLibrary?: TestingLibraryConfigOptions;
55
+ storybook?: StorybookConfigOptions;
56
+ packageJson?: PackageJsonConfigOptions;
57
+ yaml?: YamlConfigOptions;
58
+ }
59
+
60
+ /**
61
+ * @param tsconfigRootDir The directory of the tsconfig file to use for rules that needs a TypeScript type check: https://typescript-eslint.io/packages/parser/#tsconfigrootdir.
62
+ * @param options An optional object of options for the ESlint core and plugins rules.
63
+ */
64
+ export const defineWebApplicationConfig = (tsconfigRootDir: string, options: DefineWebApplicationConfigOptions = {}) => {
65
+ const {
66
+ core,
67
+ jest,
68
+ jsxAlly,
69
+ packageJson,
70
+ react,
71
+ storybook,
72
+ testingLibrary,
73
+ typescript,
74
+ vitest,
75
+ yaml
76
+ } = options;
77
+
78
+ return defineConfig([
79
+ // node_modules folder is ignored by default.
80
+ globalIgnores([
81
+ "dist",
82
+ ...coreGlobalIgnores,
83
+ ...jestGlobalIgnores,
84
+ ...jsxAllyGlobalIgnores,
85
+ ...packageJsonGlobalIgnores,
86
+ ...reactGlobalIgnores,
87
+ ...storybookGlobalIgnores,
88
+ ...testingLibraryGlobalIgnores,
89
+ ...typescriptGlobalIgnores,
90
+ ...vitestGlobalIgnores,
91
+ ...yamlGlobalIgnores
92
+ ]),
93
+ ...coreConfig(core),
94
+ ...jestConfig(jest),
95
+ ...jsxAllyConfig(jsxAlly),
96
+ ...packageJsonConfig(packageJson),
97
+ ...reactConfig(react),
98
+ ...storybookConfig(storybook),
99
+ ...testingLibraryConfig(testingLibrary),
100
+ ...typescriptConfig(tsconfigRootDir, typescript),
101
+ // Temporary fix until the vitest plugin support defineConfig and the types are fixed.
102
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
103
+ ...(vitestConfig(vitest) as any),
104
+ ...yamlConfig(yaml),
105
+ {
106
+ plugins: {
107
+ "@workleap": WorkleapPlugin
108
+ },
109
+ rules: {
110
+ "@workleap/strict-css-modules-names": "warn"
111
+ }
112
+ }
113
+ ]);
114
+ };
package/src/core.ts ADDED
@@ -0,0 +1,138 @@
1
+ import js from "@eslint/js";
2
+ import type { Linter } from "eslint";
3
+ import importPlugin from "eslint-plugin-import";
4
+ import globals from "globals";
5
+ import type { ConfigWithExtends } from "./types.ts";
6
+
7
+ export interface CoreConfigOptions {
8
+ rules?: Partial<Linter.RulesRecord>;
9
+ }
10
+
11
+ export const coreGlobalIgnores = [];
12
+
13
+ export function coreConfig(options: CoreConfigOptions = {}) {
14
+ const {
15
+ rules
16
+ } = options;
17
+
18
+ const config: ConfigWithExtends[] = [{
19
+ name: "@workleap/eslint-configs/core",
20
+ files: [
21
+ "**/*.{js,jsx,ts,tsx,cjs,mjs}"
22
+ ],
23
+ plugins: {
24
+ js,
25
+ import: importPlugin
26
+ },
27
+ extends: [
28
+ js.configs.recommended
29
+ ],
30
+ languageOptions: {
31
+ ecmaVersion: "latest",
32
+ sourceType: "module",
33
+ globals: {
34
+ ...globals.browser,
35
+ ...globals.es2024,
36
+ ...globals.node,
37
+ ...globals.commonjs
38
+ }
39
+ },
40
+ rules: {
41
+ // Recommended rules overrides
42
+ "no-cond-assign": ["error", "except-parens"],
43
+ "no-labels": ["warn", { allowLoop: true, allowSwitch: false }],
44
+ "no-prototype-builtins": "off",
45
+
46
+ // Possible problems
47
+ "array-callback-return": "error",
48
+ "no-self-compare": "error",
49
+ "no-template-curly-in-string": "error",
50
+ "no-use-before-define": [
51
+ "error",
52
+ {
53
+ functions: false,
54
+ classes: false,
55
+ variables: false
56
+ }
57
+ ],
58
+
59
+ // Suggestions
60
+ curly: "warn",
61
+ eqeqeq: ["warn", "smart"],
62
+ "no-array-constructor": "warn",
63
+ "no-caller": "warn",
64
+ "no-eval": "warn",
65
+ "no-extend-native": "warn",
66
+ "no-extra-bind": "warn",
67
+ "no-extra-label": "warn",
68
+ "no-implied-eval": "warn",
69
+ "no-iterator": "warn",
70
+ "no-label-var": "warn",
71
+ "no-lone-blocks": "warn",
72
+ "no-loop-func": "warn",
73
+ "no-mixed-operators": [
74
+ "warn",
75
+ {
76
+ groups: [
77
+ ["&", "|", "^", "~", "<<", ">>", ">>>"],
78
+ ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
79
+ ["&&", "||"],
80
+ ["in", "instanceof"]
81
+ ],
82
+ allowSamePrecedence: false
83
+ }
84
+ ],
85
+ "no-multi-str": "warn",
86
+ "no-new-func": "warn",
87
+ "no-new-object": "warn",
88
+ "no-new-wrappers": "warn",
89
+ "no-octal-escape": "warn",
90
+ "no-param-reassign": "warn",
91
+ "no-restricted-properties": "warn",
92
+ "no-restricted-globals": ["error"],
93
+ "no-restricted-syntax": ["error", "WithStatement"],
94
+ "no-script-url": "warn",
95
+ "no-sequences": "warn",
96
+ "no-shadow": "warn",
97
+ "no-throw-literal": "warn",
98
+ "no-unneeded-ternary": "warn",
99
+ "no-unused-expressions": [
100
+ "error",
101
+ {
102
+ allowShortCircuit: true,
103
+ allowTernary: true,
104
+ allowTaggedTemplates: true
105
+ }
106
+ ],
107
+ "no-useless-computed-key": "warn",
108
+ "no-useless-concat": "warn",
109
+ "no-useless-constructor": "warn",
110
+ "no-useless-rename": [
111
+ "warn",
112
+ {
113
+ ignoreDestructuring: false,
114
+ ignoreImport: false,
115
+ ignoreExport: false
116
+ }
117
+ ],
118
+ "no-var": "warn",
119
+ "prefer-const": "warn",
120
+ strict: ["warn", "never"],
121
+
122
+ // Layout & Formatting
123
+ "unicode-bom": ["warn", "never"],
124
+
125
+ // https://github.com/import-js/eslint-plugin-import/tree/main/docs/rules
126
+ "import/newline-after-import": "warn",
127
+ "import/no-amd": "error",
128
+ "import/no-duplicates": "warn",
129
+ "import/no-self-import": "error",
130
+ "import/no-webpack-loader-syntax": "error",
131
+
132
+ // Positioned last to allow the consumer to override any rules.
133
+ ...rules
134
+ }
135
+ }];
136
+
137
+ return config;
138
+ };
package/src/index.ts ADDED
@@ -0,0 +1,16 @@
1
+ export { defineMonorepoWorkspaceConfig, type DefineMonorepoWorkspaceConfigOptions } from "./by-project-type/defineMonorepoWorkspaceConfig.ts";
2
+ export { defineReactLibraryConfig, type DefineReactLibraryConfigOptions } from "./by-project-type/defineReactLibraryConfig.ts";
3
+ export { defineTypeScriptLibraryConfig, type DefineTypeScriptLibraryConfigOptions } from "./by-project-type/defineTypescriptLibraryConfig.ts";
4
+ export { defineWebApplicationConfig, type DefineWebApplicationConfigOptions } from "./by-project-type/defineWebApplicationConfig.ts";
5
+ export type { CoreConfigOptions } from "./core.ts";
6
+ export type { JestConfigOptions } from "./jest.ts";
7
+ export type { JsxAllyConfigOptions } from "./jsxAlly.ts";
8
+ export type { PackageJsonConfigOptions } from "./packageJson.ts";
9
+ export type { ReactConfigOptions } from "./react.ts";
10
+ export type { StorybookConfigOptions } from "./storybook.ts";
11
+ export type { TestingLibraryConfigOptions } from "./testingLibrary.ts";
12
+ export type { ConfigWithExtends, ExtendsElement, InfiniteArray, SimpleExtendsElement } from "./types.ts";
13
+ export type { TypescriptConfigOptions } from "./typescript.ts";
14
+ export type { VitestConfigOptions } from "./vitest.ts";
15
+ export type { YamlConfigOptions } from "./yaml.ts";
16
+