@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,70 @@
1
+ import { basename, parse, sep } from "path";
2
+
3
+ ;// CONCATENATED MODULE: external "path"
4
+
5
+ ;// CONCATENATED MODULE: ./src/plugins/strictCssModulesNames.ts
6
+
7
+ const sanitizePath = (filePath)=>{
8
+ return filePath.replace(/\//g, sep).trim();
9
+ };
10
+ const splitPath = (filePath)=>{
11
+ return sanitizePath(filePath).split(sep);
12
+ };
13
+ function getFilePath(context) {
14
+ return sanitizePath(context.getFilename());
15
+ }
16
+ function getFileName(context) {
17
+ return basename(getFilePath(context));
18
+ }
19
+ const rule = {
20
+ meta: {
21
+ type: "suggestion",
22
+ docs: {
23
+ description: "CSS Modules should have the same name as a component and located in the same folder",
24
+ category: "Strict",
25
+ recommended: false,
26
+ url: "https://github.com/workleap/wl-web-configs/blob/main/packages/eslint-plugin/docs/rules/strict-css-modules-names.md"
27
+ }
28
+ },
29
+ create: function(context) {
30
+ const parsedPath = parse(getFileName(context));
31
+ const getNodeSource = (node)=>{
32
+ return sanitizePath(node.source != null ? node.source.value : "");
33
+ };
34
+ const isCssModule = (source)=>{
35
+ return source.endsWith(".module.css");
36
+ };
37
+ const isStylesheetInSameFolder = (source)=>{
38
+ return splitPath(source).length <= 2; // ./myImage.svg
39
+ };
40
+ return {
41
+ ImportDeclaration: function(node) {
42
+ const importSource = getNodeSource(node);
43
+ if (isCssModule(importSource)) {
44
+ const validCssFilename = `${parsedPath.name}.module.css`;
45
+ if (!isStylesheetInSameFolder(importSource)) {
46
+ // ./myImage.svg
47
+ context.report({
48
+ node,
49
+ message: `CSS Modules should be associated to one component and located in the same folder ./${validCssFilename}. If the module is already used by another component, create a new one.`
50
+ });
51
+ } else {
52
+ const validCssPath = `.${sep}${validCssFilename}`;
53
+ const isNamingValid = importSource === validCssPath;
54
+ if (!isNamingValid) {
55
+ context.report({
56
+ node,
57
+ message: `CSS Modules should be associated to one component and should be named ./${validCssFilename}. If the module is already used by another component, create a new one.`
58
+ });
59
+ }
60
+ }
61
+ }
62
+ }
63
+ };
64
+ }
65
+ };
66
+
67
+
68
+ export { getFileName, getFilePath, sanitizePath, splitPath, rule as strictCssModulesNamesRule };
69
+
70
+ //# sourceMappingURL=strictCssModulesNames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins/strictCssModulesNames.js","sources":["webpack://@workleap/eslint-configs/./src/plugins/strictCssModulesNames.ts"],"sourcesContent":["import type { Rule } from \"eslint\";\nimport type ESTree from \"estree\";\nimport { basename, parse, sep } from \"path\";\n\nexport const sanitizePath = (filePath: string) => {\n return filePath.replace(/\\//g, sep).trim();\n};\n\nexport const splitPath = (filePath: string) => {\n return sanitizePath(filePath).split(sep);\n};\n\nexport function getFilePath(context: Rule.RuleContext) {\n return sanitizePath(context.getFilename());\n}\n\nexport function getFileName(context: Rule.RuleContext) {\n return basename(getFilePath(context));\n}\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: \"suggestion\",\n docs: {\n description: \"CSS Modules should have the same name as a component and located in the same folder\",\n category: \"Strict\",\n recommended: false,\n url: \"https://github.com/workleap/wl-web-configs/blob/main/packages/eslint-plugin/docs/rules/strict-css-modules-names.md\"\n }\n },\n create: function (context) {\n const parsedPath = parse(getFileName(context));\n\n const getNodeSource = (node: ESTree.ImportDeclaration) => {\n return sanitizePath(node.source != null ? node.source.value as string : \"\");\n };\n\n const isCssModule = (source: string) => {\n return source.endsWith(\".module.css\");\n };\n\n const isStylesheetInSameFolder = (source: string) => {\n return splitPath(source).length <= 2; // ./myImage.svg\n };\n\n return {\n ImportDeclaration: function (node) {\n const importSource = getNodeSource(node);\n\n if (isCssModule(importSource)) {\n const validCssFilename = `${parsedPath.name}.module.css`;\n\n if (!isStylesheetInSameFolder(importSource)) {\n // ./myImage.svg\n context.report({\n node,\n message: `CSS Modules should be associated to one component and located in the same folder ./${validCssFilename}. If the module is already used by another component, create a new one.`\n });\n } else {\n const validCssPath = `.${sep}${validCssFilename}`;\n const isNamingValid = importSource === validCssPath;\n if (!isNamingValid) {\n context.report({\n node,\n message: `CSS Modules should be associated to one component and should be named ./${validCssFilename}. If the module is already used by another component, create a new one.`\n });\n }\n }\n }\n }\n };\n }\n};\n\nexport { rule as strictCssModulesNamesRule };\n"],"names":["basename","parse","sep","sanitizePath","filePath","splitPath","getFilePath","context","getFileName","rule","parsedPath","getNodeSource","node","isCssModule","source","isStylesheetInSameFolder","importSource","validCssFilename","validCssPath","isNamingValid","strictCssModulesNamesRule"],"mappings":";;;;;AAE4C;AAErC,MAAMG,eAAe,CAACC;IACzB,OAAOA,SAAS,OAAO,CAAC,OAAOF,GAAGA,EAAE,IAAI;AAC5C,EAAE;AAEK,MAAMG,YAAY,CAACD;IACtB,OAAOD,aAAaC,UAAU,KAAK,CAACF,GAAGA;AAC3C,EAAE;AAEK,SAASI,YAAYC,OAAyB;IACjD,OAAOJ,aAAaI,QAAQ,WAAW;AAC3C;AAEO,SAASC,YAAYD,OAAyB;IACjD,OAAOP,QAAQA,CAACM,YAAYC;AAChC;AAEA,MAAME,OAAwB;IAC1B,MAAM;QACF,MAAM;QACN,MAAM;YACF,aAAa;YACb,UAAU;YACV,aAAa;YACb,KAAK;QACT;IACJ;IACA,QAAQ,SAAUF,OAAO;QACrB,MAAMG,aAAaT,KAAKA,CAACO,YAAYD;QAErC,MAAMI,gBAAgB,CAACC;YACnB,OAAOT,aAAaS,KAAK,MAAM,IAAI,OAAOA,KAAK,MAAM,CAAC,KAAK,GAAa;QAC5E;QAEA,MAAMC,cAAc,CAACC;YACjB,OAAOA,OAAO,QAAQ,CAAC;QAC3B;QAEA,MAAMC,2BAA2B,CAACD;YAC9B,OAAOT,UAAUS,QAAQ,MAAM,IAAI,GAAG,gBAAgB;QAC1D;QAEA,OAAO;YACH,mBAAmB,SAAUF,IAAI;gBAC7B,MAAMI,eAAeL,cAAcC;gBAEnC,IAAIC,YAAYG,eAAe;oBAC3B,MAAMC,mBAAmB,GAAGP,WAAW,IAAI,CAAC,WAAW,CAAC;oBAExD,IAAI,CAACK,yBAAyBC,eAAe;wBACzC,gBAAgB;wBAChBT,QAAQ,MAAM,CAAC;4BACXK;4BACA,SAAS,CAAC,mFAAmF,EAAEK,iBAAiB,uEAAuE,CAAC;wBAC5L;oBACJ,OAAO;wBACH,MAAMC,eAAe,CAAC,CAAC,EAAEhB,GAAGA,GAAGe,kBAAkB;wBACjD,MAAME,gBAAgBH,iBAAiBE;wBACvC,IAAI,CAACC,eAAe;4BAChBZ,QAAQ,MAAM,CAAC;gCACXK;gCACA,SAAS,CAAC,wEAAwE,EAAEK,iBAAiB,uEAAuE,CAAC;4BACjL;wBACJ;oBACJ;gBACJ;YACJ;QACJ;IACJ;AACJ;AAE6C"}
@@ -0,0 +1,5 @@
1
+ export declare const WorkleapPlugin: {
2
+ rules: {
3
+ "strict-css-modules-names": import("eslint").Rule.RuleModule;
4
+ };
5
+ };
@@ -0,0 +1,15 @@
1
+ import { strictCssModulesNamesRule } from "./strictCssModulesNames.js";
2
+
3
+ ;// CONCATENATED MODULE: external "./strictCssModulesNames.js"
4
+
5
+ ;// CONCATENATED MODULE: ./src/plugins/workleapPlugin.ts
6
+
7
+ const WorkleapPlugin = {
8
+ rules: {
9
+ "strict-css-modules-names": strictCssModulesNamesRule
10
+ }
11
+ };
12
+
13
+ export { WorkleapPlugin };
14
+
15
+ //# sourceMappingURL=workleapPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins/workleapPlugin.js","sources":["webpack://@workleap/eslint-configs/./src/plugins/workleapPlugin.ts"],"sourcesContent":["import { strictCssModulesNamesRule } from \"./strictCssModulesNames.ts\";\n\nexport const WorkleapPlugin = {\n rules: {\n \"strict-css-modules-names\": strictCssModulesNamesRule\n }\n};\n"],"names":["strictCssModulesNamesRule","WorkleapPlugin"],"mappings":";;;;;AAAuE;AAEhE,MAAMC,iBAAiB;IAC1B,OAAO;QACH,4BAA4BD,yBAAyBA;IACzD;AACJ,EAAE"}
@@ -0,0 +1,7 @@
1
+ import type { Linter } from "eslint";
2
+ import type { ConfigWithExtends } from "./types.ts";
3
+ export interface ReactConfigOptions {
4
+ rules?: Partial<Linter.RulesRecord>;
5
+ }
6
+ export declare const reactGlobalIgnores: never[];
7
+ export declare function reactConfig(options?: ReactConfigOptions): ConfigWithExtends[];
package/dist/react.js ADDED
@@ -0,0 +1,189 @@
1
+ import eslint_plugin from "@stylistic/eslint-plugin";
2
+ import eslint_plugin_react from "eslint-plugin-react";
3
+ import eslint_plugin_react_hooks from "eslint-plugin-react-hooks";
4
+
5
+ ;// CONCATENATED MODULE: external "@stylistic/eslint-plugin"
6
+
7
+ ;// CONCATENATED MODULE: external "eslint-plugin-react"
8
+
9
+ ;// CONCATENATED MODULE: external "eslint-plugin-react-hooks"
10
+
11
+ ;// CONCATENATED MODULE: ./src/react.ts
12
+
13
+
14
+
15
+ const reactGlobalIgnores = [];
16
+ function reactConfig(options = {}) {
17
+ const { rules = {} } = options;
18
+ const config = [
19
+ {
20
+ name: "@workleap/eslint-configs/react",
21
+ files: [
22
+ "**/*.[jt]sx"
23
+ ],
24
+ plugins: {
25
+ "@stylistic": eslint_plugin
26
+ },
27
+ extends: [
28
+ eslint_plugin_react.configs.flat.recommended,
29
+ // @ts-expect-error the typings are broken and think there's a ".default" to add.
30
+ eslint_plugin_react_hooks.configs.flat.recommended
31
+ ],
32
+ languageOptions: {
33
+ parserOptions: {
34
+ ecmaFeatures: {
35
+ jsx: true
36
+ }
37
+ }
38
+ },
39
+ settings: {
40
+ react: {
41
+ version: "detect"
42
+ }
43
+ },
44
+ rules: {
45
+ // React Recommend rules overrides
46
+ "react/display-name": "off",
47
+ "react/jsx-key": "off",
48
+ "react/jsx-no-duplicate-props": [
49
+ "warn",
50
+ {
51
+ ignoreCase: true
52
+ }
53
+ ],
54
+ "react/jsx-no-undef": [
55
+ "warn",
56
+ {
57
+ allowGlobals: true
58
+ }
59
+ ],
60
+ "react/no-unescaped-entities": "off",
61
+ "react/prop-types": "off",
62
+ "react/react-in-jsx-scope": "off",
63
+ // React extra rules
64
+ "react/button-has-type": "warn",
65
+ "react/default-props-match-prop-types": "warn",
66
+ "react/destructuring-assignment": [
67
+ "warn",
68
+ "always",
69
+ {
70
+ ignoreClassFields: true
71
+ }
72
+ ],
73
+ "react/forbid-foreign-prop-types": [
74
+ "warn",
75
+ {
76
+ allowInPropTypes: true
77
+ }
78
+ ],
79
+ "react/jsx-boolean-value": [
80
+ "warn",
81
+ "never"
82
+ ],
83
+ "react/jsx-filename-extension": [
84
+ "warn",
85
+ {
86
+ extensions: [
87
+ ".jsx",
88
+ ".tsx"
89
+ ]
90
+ }
91
+ ],
92
+ "react/jsx-pascal-case": [
93
+ "warn",
94
+ {
95
+ allowAllCaps: true,
96
+ ignore: []
97
+ }
98
+ ],
99
+ "react/no-access-state-in-setstate": "warn",
100
+ "react/no-array-index-key": "warn",
101
+ "react/no-typos": "error",
102
+ "react/no-unused-prop-types": [
103
+ "warn",
104
+ {
105
+ customValidators: [],
106
+ skipShapeProps: true
107
+ }
108
+ ],
109
+ "react/no-unused-state": "warn",
110
+ "react/style-prop-object": "warn",
111
+ // React rules turned off in favor of @stylistic
112
+ "react/jsx-closing-bracket-location": "off",
113
+ "react/jsx-closing-tag-location": "off",
114
+ "react/jsx-curly-brace-presence": "off",
115
+ "react/jsx-curly-newline": "off",
116
+ "react/jsx-curly-spacing": "off",
117
+ "react/jsx-equals-spacing": "off",
118
+ "react/jsx-first-prop-new-line": "off",
119
+ "react/jsx-indent-props": "off",
120
+ "react/jsx-max-props-per-line": "off",
121
+ "react/jsx-one-expression-per-line": "off",
122
+ "react/jsx-tag-spacing": "off",
123
+ "react/jsx-wrap-multilines": "off",
124
+ // @stylistic rules (cannot use the recommended config" because it would conflict with the "typescript" config rules)
125
+ "@stylistic/jsx-closing-bracket-location": "warn",
126
+ "@stylistic/jsx-closing-tag-location": "warn",
127
+ "@stylistic/jsx-curly-brace-presence": [
128
+ "warn",
129
+ {
130
+ propElementValues: "always"
131
+ }
132
+ ],
133
+ "@stylistic/jsx-curly-newline": "warn",
134
+ "@stylistic/jsx-curly-spacing": [
135
+ "warn",
136
+ {
137
+ children: true,
138
+ when: "never"
139
+ }
140
+ ],
141
+ "@stylistic/jsx-equals-spacing": "warn",
142
+ "@stylistic/jsx-first-prop-new-line": "warn",
143
+ "@stylistic/jsx-function-call-newline": [
144
+ "warn",
145
+ "multiline"
146
+ ],
147
+ "@stylistic/jsx-max-props-per-line": [
148
+ "warn",
149
+ {
150
+ maximum: 1,
151
+ when: "multiline"
152
+ }
153
+ ],
154
+ "@stylistic/jsx-quotes": [
155
+ "warn",
156
+ "prefer-double"
157
+ ],
158
+ "@stylistic/jsx-tag-spacing": [
159
+ "warn",
160
+ {
161
+ // afterOpening: "never",
162
+ // beforeClosing: "never",
163
+ beforeSelfClosing: "always"
164
+ }
165
+ ],
166
+ "@stylistic/jsx-wrap-multilines": [
167
+ "warn",
168
+ {
169
+ arrow: "parens-new-line",
170
+ assignment: "parens-new-line",
171
+ condition: "parens-new-line",
172
+ declaration: "parens-new-line",
173
+ logical: "parens-new-line",
174
+ prop: "parens-new-line",
175
+ propertyValue: "parens-new-line",
176
+ return: "parens-new-line"
177
+ }
178
+ ],
179
+ // Positioned last to allow the consumer to override any rules.
180
+ ...rules
181
+ }
182
+ }
183
+ ];
184
+ return config;
185
+ }
186
+
187
+ export { reactConfig, reactGlobalIgnores };
188
+
189
+ //# sourceMappingURL=react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.js","sources":["webpack://@workleap/eslint-configs/./src/react.ts"],"sourcesContent":["import stylisticPlugin from \"@stylistic/eslint-plugin\";\nimport type { Linter } from \"eslint\";\nimport reactPlugin from \"eslint-plugin-react\";\nimport reactHooksPlugin from \"eslint-plugin-react-hooks\";\nimport type { ConfigWithExtends } from \"./types.ts\";\n\nexport interface ReactConfigOptions {\n rules?: Partial<Linter.RulesRecord>;\n}\n\nexport const reactGlobalIgnores = [];\n\nexport function reactConfig(options: ReactConfigOptions = {}) {\n const {\n rules = {}\n } = options;\n\n const config: ConfigWithExtends[] = [{\n name: \"@workleap/eslint-configs/react\",\n files: [\n \"**/*.[jt]sx\"\n ],\n plugins: {\n \"@stylistic\": stylisticPlugin\n },\n extends: [\n reactPlugin.configs.flat.recommended,\n // @ts-expect-error the typings are broken and think there's a \".default\" to add.\n reactHooksPlugin.configs.flat.recommended\n ],\n languageOptions: {\n parserOptions: {\n ecmaFeatures: {\n jsx: true\n }\n }\n },\n settings: {\n react: {\n version: \"detect\"\n }\n },\n rules: {\n // React Recommend rules overrides\n \"react/display-name\": \"off\",\n \"react/jsx-key\": \"off\",\n \"react/jsx-no-duplicate-props\": [\n \"warn\",\n {\n ignoreCase: true\n }\n ],\n \"react/jsx-no-undef\": [\n \"warn\",\n {\n allowGlobals: true\n }\n ],\n \"react/no-unescaped-entities\": \"off\",\n \"react/prop-types\": \"off\",\n \"react/react-in-jsx-scope\": \"off\",\n\n // React extra rules\n \"react/button-has-type\": \"warn\",\n \"react/default-props-match-prop-types\": \"warn\",\n \"react/destructuring-assignment\": [\n \"warn\",\n \"always\",\n { ignoreClassFields: true }\n ],\n \"react/forbid-foreign-prop-types\": [\n \"warn\",\n {\n allowInPropTypes: true\n }\n ],\n \"react/jsx-boolean-value\": [\"warn\", \"never\"],\n \"react/jsx-filename-extension\": [\n \"warn\",\n {\n extensions: [\".jsx\", \".tsx\"]\n }\n ],\n \"react/jsx-pascal-case\": [\n \"warn\",\n {\n allowAllCaps: true,\n ignore: []\n }\n ],\n \"react/no-access-state-in-setstate\": \"warn\",\n \"react/no-array-index-key\": \"warn\",\n \"react/no-typos\": \"error\",\n \"react/no-unused-prop-types\": [\n \"warn\",\n {\n customValidators: [],\n skipShapeProps: true\n }\n ],\n \"react/no-unused-state\": \"warn\",\n \"react/style-prop-object\": \"warn\",\n\n // React rules turned off in favor of @stylistic\n \"react/jsx-closing-bracket-location\": \"off\",\n \"react/jsx-closing-tag-location\": \"off\",\n \"react/jsx-curly-brace-presence\": \"off\",\n \"react/jsx-curly-newline\": \"off\",\n \"react/jsx-curly-spacing\": \"off\",\n \"react/jsx-equals-spacing\": \"off\",\n \"react/jsx-first-prop-new-line\": \"off\",\n \"react/jsx-indent-props\": \"off\",\n \"react/jsx-max-props-per-line\": \"off\",\n \"react/jsx-one-expression-per-line\": \"off\",\n \"react/jsx-tag-spacing\": \"off\",\n \"react/jsx-wrap-multilines\": \"off\",\n\n // @stylistic rules (cannot use the recommended config\" because it would conflict with the \"typescript\" config rules)\n \"@stylistic/jsx-closing-bracket-location\": \"warn\",\n \"@stylistic/jsx-closing-tag-location\": \"warn\",\n \"@stylistic/jsx-curly-brace-presence\": [\n \"warn\",\n {\n propElementValues: \"always\"\n }\n ],\n \"@stylistic/jsx-curly-newline\": \"warn\",\n \"@stylistic/jsx-curly-spacing\": [\n \"warn\",\n {\n children: true,\n when: \"never\"\n }\n ],\n \"@stylistic/jsx-equals-spacing\": \"warn\",\n \"@stylistic/jsx-first-prop-new-line\": \"warn\",\n \"@stylistic/jsx-function-call-newline\": [\"warn\", \"multiline\"],\n \"@stylistic/jsx-max-props-per-line\": [\n \"warn\",\n {\n maximum: 1,\n when: \"multiline\"\n }\n ],\n \"@stylistic/jsx-quotes\": [\"warn\", \"prefer-double\"],\n \"@stylistic/jsx-tag-spacing\": [\n \"warn\",\n {\n // afterOpening: \"never\",\n // beforeClosing: \"never\",\n beforeSelfClosing: \"always\"\n // closingSlash: \"never\"\n }\n ],\n \"@stylistic/jsx-wrap-multilines\": [\n \"warn\",\n {\n arrow: \"parens-new-line\",\n assignment: \"parens-new-line\",\n condition: \"parens-new-line\",\n declaration: \"parens-new-line\",\n logical: \"parens-new-line\",\n prop: \"parens-new-line\",\n propertyValue: \"parens-new-line\",\n return: \"parens-new-line\"\n }\n ],\n\n // Positioned last to allow the consumer to override any rules.\n ...rules\n }\n }];\n\n return config;\n};\n"],"names":["stylisticPlugin","reactPlugin","reactHooksPlugin","reactGlobalIgnores","reactConfig","options","rules","config"],"mappings":";;;;;;;;;;;AAAuD;AAET;AACW;AAOlD,MAAMG,qBAAqB,EAAE,CAAC;AAE9B,SAASC,YAAYC,UAA8B,CAAC,CAAC;IACxD,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;gBACLC,4CAAoC;gBACpC,iFAAiF;gBACjFC,kDAAyC;aAC5C;YACD,iBAAiB;gBACb,eAAe;oBACX,cAAc;wBACV,KAAK;oBACT;gBACJ;YACJ;YACA,UAAU;gBACN,OAAO;oBACH,SAAS;gBACb;YACJ;YACA,OAAO;gBACH,kCAAkC;gBAClC,sBAAsB;gBACtB,iBAAiB;gBACjB,gCAAgC;oBAC5B;oBACA;wBACI,YAAY;oBAChB;iBACH;gBACD,sBAAsB;oBAClB;oBACA;wBACI,cAAc;oBAClB;iBACH;gBACD,+BAA+B;gBAC/B,oBAAoB;gBACpB,4BAA4B;gBAE5B,oBAAoB;gBACpB,yBAAyB;gBACzB,wCAAwC;gBACxC,kCAAkC;oBAC9B;oBACA;oBACA;wBAAE,mBAAmB;oBAAK;iBAC7B;gBACD,mCAAmC;oBAC/B;oBACA;wBACI,kBAAkB;oBACtB;iBACH;gBACD,2BAA2B;oBAAC;oBAAQ;iBAAQ;gBAC5C,gCAAgC;oBAC5B;oBACA;wBACI,YAAY;4BAAC;4BAAQ;yBAAO;oBAChC;iBACH;gBACD,yBAAyB;oBACrB;oBACA;wBACI,cAAc;wBACd,QAAQ,EAAE;oBACd;iBACH;gBACD,qCAAqC;gBACrC,4BAA4B;gBAC5B,kBAAkB;gBAClB,8BAA8B;oBAC1B;oBACA;wBACI,kBAAkB,EAAE;wBACpB,gBAAgB;oBACpB;iBACH;gBACD,yBAAyB;gBACzB,2BAA2B;gBAE3B,gDAAgD;gBAChD,sCAAsC;gBACtC,kCAAkC;gBAClC,kCAAkC;gBAClC,2BAA2B;gBAC3B,2BAA2B;gBAC3B,4BAA4B;gBAC5B,iCAAiC;gBACjC,0BAA0B;gBAC1B,gCAAgC;gBAChC,qCAAqC;gBACrC,yBAAyB;gBACzB,6BAA6B;gBAE7B,qHAAqH;gBACrH,2CAA2C;gBAC3C,uCAAuC;gBACvC,uCAAuC;oBACnC;oBACA;wBACI,mBAAmB;oBACvB;iBACH;gBACD,gCAAgC;gBAChC,gCAAgC;oBAC5B;oBACA;wBACI,UAAU;wBACV,MAAM;oBACV;iBACH;gBACD,iCAAiC;gBACjC,sCAAsC;gBACtC,wCAAwC;oBAAC;oBAAQ;iBAAY;gBAC7D,qCAAqC;oBACjC;oBACA;wBACI,SAAS;wBACT,MAAM;oBACV;iBACH;gBACD,yBAAyB;oBAAC;oBAAQ;iBAAgB;gBAClD,8BAA8B;oBAC1B;oBACA;wBACI,yBAAyB;wBACzB,0BAA0B;wBAC1B,mBAAmB;oBAEvB;iBACH;gBACD,kCAAkC;oBAC9B;oBACA;wBACI,OAAO;wBACP,YAAY;wBACZ,WAAW;wBACX,aAAa;wBACb,SAAS;wBACT,MAAM;wBACN,eAAe;wBACf,QAAQ;oBACZ;iBACH;gBAED,+DAA+D;gBAC/D,GAAGI,KAAK;YACZ;QACJ;KAAE;IAEF,OAAOC;AACX"}
@@ -0,0 +1,8 @@
1
+ import type { Linter } from "eslint";
2
+ import type { ConfigWithExtends } from "./types.ts";
3
+ export interface StorybookConfigOptions {
4
+ storiesRules?: Partial<Linter.RulesRecord>;
5
+ mainFileRules?: Partial<Linter.RulesRecord>;
6
+ }
7
+ export declare const storybookGlobalIgnores: string[];
8
+ export declare function storybookConfig(options?: StorybookConfigOptions): ConfigWithExtends[];
@@ -0,0 +1,46 @@
1
+ import eslint_plugin_storybook from "eslint-plugin-storybook";
2
+
3
+ ;// CONCATENATED MODULE: external "eslint-plugin-storybook"
4
+
5
+ ;// CONCATENATED MODULE: ./src/storybook.ts
6
+
7
+ const storybookGlobalIgnores = [
8
+ "!.storybook",
9
+ "storybook-static"
10
+ ];
11
+ function storybookConfig(options = {}) {
12
+ const { storiesRules = {}, mainFileRules = {} } = options;
13
+ const config = [
14
+ {
15
+ name: "@workleap/eslint-configs/storybook-stories",
16
+ files: [
17
+ "**/*.{stories,storybook,story,chroma}.{js,ts,jsx,tsx}"
18
+ ],
19
+ extends: [
20
+ // @ts-expect-error the typings are broken and think there's a ".default" to add.
21
+ eslint_plugin_storybook.configs["flat/recommended"]
22
+ ],
23
+ rules: storiesRules
24
+ },
25
+ {
26
+ name: "@workleap/eslint-configs/storybook-main",
27
+ files: [
28
+ "**/{.storybook,storybook}/main.@(js|cjs|mjs|ts)"
29
+ ],
30
+ plugins: {
31
+ // @ts-expect-error the typings are broken.
32
+ storybook: eslint_plugin_storybook
33
+ },
34
+ rules: {
35
+ "storybook/no-uninstalled-addons": "warn",
36
+ // Positioned last to allow the consumer to override any rules.
37
+ ...mainFileRules
38
+ }
39
+ }
40
+ ];
41
+ return config;
42
+ }
43
+
44
+ export { storybookConfig, storybookGlobalIgnores };
45
+
46
+ //# sourceMappingURL=storybook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storybook.js","sources":["webpack://@workleap/eslint-configs/./src/storybook.ts"],"sourcesContent":["import type { Linter } from \"eslint\";\nimport storybookPlugin from \"eslint-plugin-storybook\";\nimport type { ConfigWithExtends } from \"./types.ts\";\n\nexport interface StorybookConfigOptions {\n storiesRules?: Partial<Linter.RulesRecord>;\n mainFileRules?: Partial<Linter.RulesRecord>;\n}\n\nexport const storybookGlobalIgnores = [\n \"!.storybook\",\n \"storybook-static\"\n];\n\nexport function storybookConfig(options: StorybookConfigOptions = {}) {\n const {\n storiesRules = {},\n mainFileRules = {}\n } = options;\n\n const config: ConfigWithExtends[] = [\n {\n name: \"@workleap/eslint-configs/storybook-stories\",\n files: [\n \"**/*.{stories,storybook,story,chroma}.{js,ts,jsx,tsx}\"\n ],\n extends: [\n // @ts-expect-error the typings are broken and think there's a \".default\" to add.\n storybookPlugin.configs[\"flat/recommended\"]\n // // @ts-expect-error the types are broken and think there's a \".default\" to add.\n // storybookPlugin.configs[\"flat/csf\"],\n // // @ts-expect-error the types are broken and think there's a \".default\" to add.\n // storybookPlugin.configs[\"flat/csf-strict\"]\n ],\n rules: storiesRules\n },\n {\n name: \"@workleap/eslint-configs/storybook-main\",\n files: [\"**/{.storybook,storybook}/main.@(js|cjs|mjs|ts)\"],\n plugins: {\n // @ts-expect-error the typings are broken.\n storybook: storybookPlugin\n },\n rules: {\n \"storybook/no-uninstalled-addons\": \"warn\",\n // Positioned last to allow the consumer to override any rules.\n ...mainFileRules\n }\n }\n ];\n\n return config;\n};\n"],"names":["storybookPlugin","storybookGlobalIgnores","storybookConfig","options","storiesRules","mainFileRules","config"],"mappings":";;;;;AACsD;AAQ/C,MAAMC,yBAAyB;IAClC;IACA;CACH,CAAC;AAEK,SAASC,gBAAgBC,UAAkC,CAAC,CAAC;IAChE,MAAM,EACFC,eAAe,CAAC,CAAC,EACjBC,gBAAgB,CAAC,CAAC,EACrB,GAAGF;IAEJ,MAAMG,SAA8B;QAChC;YACI,MAAM;YACN,OAAO;gBACH;aACH;YACD,SAAS;gBACL,iFAAiF;gBACjFN,mDAA2C;aAK9C;YACD,OAAOI;QACX;QACA;YACI,MAAM;YACN,OAAO;gBAAC;aAAkD;YAC1D,SAAS;gBACL,2CAA2C;gBAC3C,WAAWJ,uBAAeA;YAC9B;YACA,OAAO;gBACH,mCAAmC;gBACnC,+DAA+D;gBAC/D,GAAGK,aAAa;YACpB;QACJ;KACH;IAED,OAAOC;AACX"}
@@ -0,0 +1,8 @@
1
+ import type { Linter } from "eslint";
2
+ import type { ConfigWithExtends } from "./types.ts";
3
+ export interface TestingLibraryConfigOptions {
4
+ reactRules?: Partial<Linter.RulesRecord>;
5
+ jsRules?: Partial<Linter.RulesRecord>;
6
+ }
7
+ export declare const testingLibraryGlobalIgnores: never[];
8
+ export declare function testingLibraryConfig(options?: TestingLibraryConfigOptions): ConfigWithExtends[];
@@ -0,0 +1,43 @@
1
+ import eslint_plugin_testing_library from "eslint-plugin-testing-library";
2
+
3
+ ;// CONCATENATED MODULE: external "eslint-plugin-testing-library"
4
+
5
+ ;// CONCATENATED MODULE: ./src/testingLibrary.ts
6
+
7
+ const testingLibraryGlobalIgnores = [];
8
+ function testingLibraryConfig(options = {}) {
9
+ const { reactRules = {}, jsRules = {} } = options;
10
+ const config = [
11
+ {
12
+ name: "@workleap/eslint-configs/testing-library-react",
13
+ files: [
14
+ "**/*.test.[jt]sx",
15
+ "**/*-test.[jt]sx",
16
+ "**/__tests__/*.[jt]sx",
17
+ "**/test.[jt]sx"
18
+ ],
19
+ extends: [
20
+ eslint_plugin_testing_library.configs["flat/react"]
21
+ ],
22
+ rules: reactRules
23
+ },
24
+ {
25
+ name: "@workleap/eslint-configs/testing-library-js",
26
+ files: [
27
+ "**/*.test.[jt]s",
28
+ "**/*-test.[jt]s",
29
+ "**/__tests__/*.[jt]s",
30
+ "**/test.[jt]s"
31
+ ],
32
+ extends: [
33
+ eslint_plugin_testing_library.configs["flat/dom"]
34
+ ],
35
+ rules: jsRules
36
+ }
37
+ ];
38
+ return config;
39
+ }
40
+
41
+ export { testingLibraryConfig, testingLibraryGlobalIgnores };
42
+
43
+ //# sourceMappingURL=testingLibrary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testingLibrary.js","sources":["webpack://@workleap/eslint-configs/./src/testingLibrary.ts"],"sourcesContent":["import type { Linter } from \"eslint\";\nimport testingLibraryPlugin from \"eslint-plugin-testing-library\";\nimport type { ConfigWithExtends } from \"./types.ts\";\n\nexport interface TestingLibraryConfigOptions {\n reactRules?: Partial<Linter.RulesRecord>;\n jsRules?: Partial<Linter.RulesRecord>;\n}\n\nexport const testingLibraryGlobalIgnores = [];\n\nexport function testingLibraryConfig(options: TestingLibraryConfigOptions = {}) {\n const {\n reactRules = {},\n jsRules = {}\n } = options;\n\n const config: ConfigWithExtends[] = [\n {\n name: \"@workleap/eslint-configs/testing-library-react\",\n files: [\n \"**/*.test.[jt]sx\",\n \"**/*-test.[jt]sx\",\n \"**/__tests__/*.[jt]sx\",\n \"**/test.[jt]sx\"\n ],\n extends: [\n testingLibraryPlugin.configs[\"flat/react\"]\n ],\n rules: reactRules\n },\n {\n name: \"@workleap/eslint-configs/testing-library-js\",\n files: [\n \"**/*.test.[jt]s\",\n \"**/*-test.[jt]s\",\n \"**/__tests__/*.[jt]s\",\n \"**/test.[jt]s\"\n ],\n extends: [\n testingLibraryPlugin.configs[\"flat/dom\"]\n ],\n rules: jsRules\n }\n ];\n\n return config;\n};\n"],"names":["testingLibraryPlugin","testingLibraryGlobalIgnores","testingLibraryConfig","options","reactRules","jsRules","config"],"mappings":";;;;;AACiE;AAQ1D,MAAMC,8BAA8B,EAAE,CAAC;AAEvC,SAASC,qBAAqBC,UAAuC,CAAC,CAAC;IAC1E,MAAM,EACFC,aAAa,CAAC,CAAC,EACfC,UAAU,CAAC,CAAC,EACf,GAAGF;IAEJ,MAAMG,SAA8B;QAChC;YACI,MAAM;YACN,OAAO;gBACH;gBACA;gBACA;gBACA;aACH;YACD,SAAS;gBACLN,mDAA0C;aAC7C;YACD,OAAOI;QACX;QACA;YACI,MAAM;YACN,OAAO;gBACH;gBACA;gBACA;gBACA;aACH;YACD,SAAS;gBACLJ,iDAAwC;aAC3C;YACD,OAAOK;QACX;KACH;IAED,OAAOC;AACX"}
@@ -0,0 +1,19 @@
1
+ import type { Linter } from "eslint";
2
+ /**
3
+ * Infinite array type.
4
+ */
5
+ export type InfiniteArray<T> = T | InfiniteArray<T>[];
6
+ /**
7
+ * The type of array element in the `extends` property after flattening.
8
+ */
9
+ export type SimpleExtendsElement = string | Linter.Config;
10
+ /**
11
+ * The type of array element in the `extends` property before flattening.
12
+ */
13
+ export type ExtendsElement = SimpleExtendsElement | InfiniteArray<Linter.Config>;
14
+ /**
15
+ * Config with extends. Valid only inside of `defineConfig()`.
16
+ */
17
+ export interface ConfigWithExtends extends Linter.Config {
18
+ extends?: ExtendsElement[];
19
+ }
package/dist/types.js ADDED
@@ -0,0 +1,9 @@
1
+
2
+ ;// CONCATENATED MODULE: ./src/types.ts
3
+ // Copied from: https://github.com/eslint/rewrite/blob/main/packages/config-helpers/src/types.ts
4
+ /**
5
+ * Config with extends. Valid only inside of `defineConfig()`.
6
+ */
7
+
8
+
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["webpack://@workleap/eslint-configs/./src/types.ts"],"sourcesContent":["import type { Linter } from \"eslint\";\n\n// Copied from: https://github.com/eslint/rewrite/blob/main/packages/config-helpers/src/types.ts\n/**\n * Infinite array type.\n */\nexport type InfiniteArray<T> = T | InfiniteArray<T>[];\n\n// Copied from: https://github.com/eslint/rewrite/blob/main/packages/config-helpers/src/types.ts\n/**\n * The type of array element in the `extends` property after flattening.\n */\nexport type SimpleExtendsElement = string | Linter.Config;\n\n// Copied from: https://github.com/eslint/rewrite/blob/main/packages/config-helpers/src/types.ts\n/**\n * The type of array element in the `extends` property before flattening.\n */\nexport type ExtendsElement = SimpleExtendsElement | InfiniteArray<Linter.Config>;\n\n// Copied from: https://github.com/eslint/rewrite/blob/main/packages/config-helpers/src/types.ts\n/**\n * Config with extends. Valid only inside of `defineConfig()`.\n */\nexport interface ConfigWithExtends extends Linter.Config {\n extends?: ExtendsElement[];\n}\n"],"names":[],"mappings":";;AAoBA,gGAAgG;AAChG;;CAEC,GAGA"}
@@ -0,0 +1,7 @@
1
+ import type { Linter } from "eslint";
2
+ import type { ConfigWithExtends } from "./types.ts";
3
+ export interface TypescriptConfigOptions {
4
+ rules?: Partial<Linter.RulesRecord>;
5
+ }
6
+ export declare const typescriptGlobalIgnores: never[];
7
+ export declare function typescriptConfig(tsconfigRootDir: string, options?: TypescriptConfigOptions): ConfigWithExtends[];
@@ -0,0 +1,139 @@
1
+ import js from "@eslint/js";
2
+ import eslint_plugin from "@stylistic/eslint-plugin";
3
+ import typescript_eslint from "typescript-eslint";
4
+
5
+ ;// CONCATENATED MODULE: external "@eslint/js"
6
+
7
+ ;// CONCATENATED MODULE: external "@stylistic/eslint-plugin"
8
+
9
+ ;// CONCATENATED MODULE: external "typescript-eslint"
10
+
11
+ ;// CONCATENATED MODULE: ./src/typescript.ts
12
+
13
+
14
+
15
+ const typescriptGlobalIgnores = [];
16
+ function typescriptConfig(tsconfigRootDir, options = {}) {
17
+ const { rules = {} } = options;
18
+ const config = [
19
+ {
20
+ name: "@workleap/eslint-configs/typescript",
21
+ files: [
22
+ "**/*.{ts,tsx}"
23
+ ],
24
+ plugins: {
25
+ "@stylistic": eslint_plugin
26
+ },
27
+ extends: [
28
+ js.configs.recommended,
29
+ typescript_eslint.configs.recommendedTypeChecked,
30
+ typescript_eslint.configs.stylisticTypeCheckedOnly,
31
+ eslint_plugin.configs.customize({
32
+ braceStyle: "1tbs",
33
+ commaDangle: "never",
34
+ jsx: false,
35
+ quotes: "double",
36
+ semi: true,
37
+ severity: "warn"
38
+ })
39
+ ],
40
+ languageOptions: {
41
+ parser: typescript_eslint.parser,
42
+ parserOptions: {
43
+ // Rely on TypeScript's project service to automatically discover the "tsconfig.json" file
44
+ // within the boundaries of "tsconfigRootDir".
45
+ projectService: true,
46
+ tsconfigRootDir
47
+ }
48
+ },
49
+ rules: {
50
+ // ESLint core rules overrides
51
+ "dot-notation": "off",
52
+ "indent": "off",
53
+ "no-dupe-class-members": "off",
54
+ "no-empty-function": "off",
55
+ "no-loop-func": "off",
56
+ "no-shadow": "off",
57
+ "no-unused-expressions": "off",
58
+ "no-use-before-define": "off",
59
+ "no-useless-constructor": "off",
60
+ "object-curly-spacing": "off",
61
+ "quotes": "off",
62
+ "semi": "off",
63
+ // ESlint deprecated core rules
64
+ "arrow-parens": "off",
65
+ "comma-dangle": "off",
66
+ // @typescript-eslint recommended rules overrides
67
+ "@typescript-eslint/dot-notation": "off",
68
+ "@typescript-eslint/no-base-to-string": "off",
69
+ "@typescript-eslint/no-empty-function": "off",
70
+ "@typescript-eslint/no-empty-object-type": [
71
+ "error",
72
+ {
73
+ allowInterfaces: "with-single-extends",
74
+ allowObjectTypes: "never"
75
+ }
76
+ ],
77
+ "@typescript-eslint/no-floating-promises": "off",
78
+ "@typescript-eslint/no-non-null-assertion": "off",
79
+ "@typescript-eslint/no-unsafe-argument": "off",
80
+ "@typescript-eslint/no-unsafe-assignment": "off",
81
+ "@typescript-eslint/no-unsafe-member-access": "off",
82
+ "@typescript-eslint/only-throw-error": "off",
83
+ "@typescript-eslint/prefer-nullish-coalescing": "off",
84
+ "@typescript-eslint/restrict-template-expressions": "off",
85
+ // @stylistic recommend rules overrides
86
+ "@stylistic/arrow-parens": [
87
+ "warn",
88
+ "as-needed",
89
+ {
90
+ requireForBlockBody: false
91
+ }
92
+ ],
93
+ "@stylistic/indent": [
94
+ "warn",
95
+ 4,
96
+ {
97
+ SwitchCase: 1,
98
+ CallExpression: {
99
+ arguments: "first"
100
+ }
101
+ }
102
+ ],
103
+ "@stylistic/indent-binary-ops": [
104
+ "warn",
105
+ 4
106
+ ],
107
+ "@stylistic/member-delimiter-style": [
108
+ "warn",
109
+ {
110
+ multiline: {
111
+ delimiter: "semi"
112
+ },
113
+ singleline: {
114
+ delimiter: "semi"
115
+ }
116
+ }
117
+ ],
118
+ "@stylistic/multiline-ternary": "off",
119
+ "@stylistic/no-multiple-empty-lines": [
120
+ "warn",
121
+ {
122
+ // View https://eslint.style/rules/eol-last.
123
+ max: 1
124
+ }
125
+ ],
126
+ "@stylistic/operator-linebreak": "off",
127
+ // Should be the default but somehow it's not enforced if it's not explicitly specified.
128
+ "@stylistic/quote-props": "off",
129
+ // Positioned last to allow the consumer to override any rules.
130
+ ...rules
131
+ }
132
+ }
133
+ ];
134
+ return config;
135
+ }
136
+
137
+ export { typescriptConfig, typescriptGlobalIgnores };
138
+
139
+ //# sourceMappingURL=typescript.js.map