@open-xchange/linter-presets 0.0.1 → 0.0.3

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 (50) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +21 -8
  3. package/lib/eslint/README.md +83 -0
  4. package/lib/eslint/config/base.js +0 -1
  5. package/lib/eslint/config/imports.js +68 -0
  6. package/lib/eslint/config/js.js +1 -1
  7. package/lib/eslint/config/ts.js +1 -1
  8. package/lib/eslint/env/browser.d.ts +10 -2
  9. package/lib/eslint/env/browser.js +44 -30
  10. package/lib/eslint/env/browser.md +33 -0
  11. package/lib/eslint/env/codecept.d.ts +2 -1
  12. package/lib/eslint/env/codecept.md +35 -0
  13. package/lib/eslint/env/eslint.d.ts +14 -0
  14. package/lib/eslint/env/eslint.js +41 -0
  15. package/lib/eslint/env/eslint.md +32 -0
  16. package/lib/eslint/env/jest.d.ts +2 -1
  17. package/lib/eslint/env/jest.md +32 -0
  18. package/lib/eslint/env/node.d.ts +8 -1
  19. package/lib/eslint/env/node.js +10 -6
  20. package/lib/eslint/env/node.md +34 -0
  21. package/lib/eslint/env/project.d.ts +21 -0
  22. package/lib/eslint/env/{plugin.js → project.js} +23 -22
  23. package/lib/eslint/env/project.md +129 -0
  24. package/lib/eslint/env/react.d.ts +2 -1
  25. package/lib/eslint/env/react.md +39 -0
  26. package/lib/eslint/env/tsconfig.d.ts +2 -1
  27. package/lib/eslint/env/tsconfig.js +0 -2
  28. package/lib/eslint/env/tsconfig.md +35 -0
  29. package/lib/eslint/env/vitest.d.ts +2 -1
  30. package/lib/eslint/env/vitest.md +36 -0
  31. package/lib/eslint/index.d.ts +8 -55
  32. package/lib/eslint/index.js +16 -10
  33. package/lib/eslint/rules/no-amd-module-directive.js +57 -0
  34. package/lib/eslint/rules/no-invalid-modules.js +206 -0
  35. package/lib/eslint/shared/env-utils.d.ts +97 -0
  36. package/lib/eslint/shared/env-utils.js +105 -0
  37. package/lib/eslint/shared/rule-utils.js +143 -0
  38. package/lib/eslint/shared/types.d.ts +25 -8
  39. package/lib/index.d.ts +1 -0
  40. package/lib/index.js +1 -0
  41. package/lib/stylelint/README.md +46 -0
  42. package/lib/stylelint/index.d.ts +18 -0
  43. package/lib/stylelint/index.js +106 -0
  44. package/lib/stylelint/types.d.ts +44 -0
  45. package/package.json +89 -60
  46. package/doc/eslint.md +0 -343
  47. package/doc/stylelint.md +0 -3
  48. package/lib/eslint/env/plugin.d.ts +0 -13
  49. package/lib/eslint/shared/constants.js +0 -33
  50. /package/{doc/utils.md → lib/utils/README.md} +0 -0
@@ -0,0 +1,106 @@
1
+
2
+ // functions ==================================================================
3
+
4
+ /**
5
+ * Generates standard configuration objects targeting the source files in the
6
+ * entire project.
7
+ *
8
+ * @param {import("./types").ConfigureOptions} [options]
9
+ * Plugin configuration options.
10
+ *
11
+ * @returns {import("stylelint").Config}
12
+ * The configuration object to be exported from `stylelint.config.js`.
13
+ */
14
+ export function configure(options) {
15
+
16
+ // resolve stylistic configuration options
17
+ const stylistic = {
18
+ indent: 2,
19
+ quotes: "single",
20
+ ...options?.stylistic,
21
+ };
22
+
23
+ // group custom rules by language plugins
24
+ const rules = { base: {}, scss: {}, less: {} };
25
+ for (const [rule, value] of Object.entries(options?.rules ?? {})) {
26
+ (rules[rule.split("/")[0]] ?? rules.base)[rule] = value;
27
+ }
28
+
29
+ return {
30
+
31
+ // ignore certain files and folders
32
+ ignoreFiles: options?.ignores ?? [],
33
+
34
+ // add the stylistic plugin
35
+ plugins: [
36
+ "stylelint-plugin-license-header",
37
+ "@stylistic/stylelint-plugin",
38
+ ],
39
+
40
+ // add recommended configurations
41
+ extends: [
42
+ "@stylistic/stylelint-config",
43
+ ],
44
+
45
+ // check inline directives
46
+ reportDescriptionlessDisables: null,
47
+ reportInvalidScopeDisables: true,
48
+ reportNeedlessDisables: true,
49
+
50
+ // reconfigure linter rules
51
+ rules: {
52
+
53
+ // core rules
54
+ "at-rule-empty-line-before": null,
55
+ "color-function-notation": ["modern", { ignore: ["with-var-inside"] }],
56
+ "color-hex-length": null,
57
+ "comment-empty-line-before": null,
58
+ "custom-property-empty-line-before": null,
59
+ "declaration-block-no-redundant-longhand-properties": [true, { ignoreShorthands: ["inset"] }], // Safari does not support "inset"
60
+ "declaration-block-single-line-max-declarations": null,
61
+ "declaration-empty-line-before": null,
62
+ "function-url-no-scheme-relative": true,
63
+ "function-url-scheme-allowed-list": ["data"],
64
+ "media-feature-range-notation": "prefix", // Safari 16.3 does not work with this notation
65
+ "no-descending-specificity": null,
66
+ "no-unknown-animations": true,
67
+ "rule-empty-line-before": null,
68
+
69
+ // license-header plugin
70
+ ...(options?.license ? { "plugin/license-header": [true, { license: options.license }] } : null),
71
+
72
+ // stylistic plugin
73
+ "@stylistic/declaration-colon-newline-after": null,
74
+ "@stylistic/indentation": [stylistic.indent, { ignore: ["inside-parens"] }],
75
+ "@stylistic/max-line-length": null,
76
+ "@stylistic/selector-list-comma-newline-after": null,
77
+ "@stylistic/string-quotes": (stylistic.quotes === "off") ? null : [stylistic.quotes, { avoidEscape: true }],
78
+
79
+ // custom rules
80
+ ...rules.base,
81
+ },
82
+
83
+ // overrides for custom languages
84
+ overrides: [
85
+
86
+ // SCSS files
87
+ {
88
+ files: ["**/*.scss"],
89
+ extends: ["stylelint-config-standard-scss"],
90
+ rules: {
91
+ "scss/double-slash-comment-empty-line-before": null,
92
+ ...rules.scss,
93
+ },
94
+ },
95
+
96
+ // LESS files
97
+ {
98
+ files: ["**/*.less"],
99
+ extends: ["stylelint-config-standard-less"],
100
+ rules: {
101
+ ...rules.less,
102
+ },
103
+ },
104
+ ],
105
+ };
106
+ }
@@ -0,0 +1,44 @@
1
+
2
+ import { Config } from "stylelint";
3
+
4
+ // types ======================================================================
5
+
6
+ /**
7
+ * Configuration options for code style.
8
+ */
9
+ export interface StylisticOptions {
10
+
11
+ /**
12
+ * Default indentation size (number of space characters). Default value is
13
+ * `2`.
14
+ */
15
+ indent?: number;
16
+
17
+ /**
18
+ * The type of the string delimiter character. Default value is "single".
19
+ */
20
+ quotes?: "single" | "double" | "off";
21
+ }
22
+
23
+ // ----------------------------------------------------------------------------
24
+
25
+ /**
26
+ * Configuration options for linting the entire project.
27
+ */
28
+ export interface ConfigureOptions {
29
+
30
+ /**
31
+ * Glob patterns with all files and folders to be ignored by StyleLint.
32
+ */
33
+ ignores?: readonly string[];
34
+
35
+ /**
36
+ * Configuration options for code style.
37
+ */
38
+ stylistic?: StylisticOptions;
39
+
40
+ /**
41
+ * Additional linter rules to be added to the global configuration.
42
+ */
43
+ rules?: Config["rules"];
44
+ }
package/package.json CHANGED
@@ -1,61 +1,90 @@
1
1
  {
2
- "name": "@open-xchange/linter-presets",
3
- "version": "0.0.1",
4
- "description": "Configuration presets for ESLint and StyleLint",
5
- "repository": "https://gitlab.open-xchange.com/fspd/npm-packages/linter-presets",
6
- "license": "MIT",
7
- "engines": {
8
- "node": ">=18"
9
- },
10
- "packageManager": "yarn@4.3.1",
11
- "type": "module",
12
- "exports": "./lib/index.js",
13
- "scripts": {
14
- "prepare": "husky",
15
- "lint": "eslint ."
16
- },
17
- "lint-staged": {
18
- "*.{js,ts,json}": "yarn lint"
19
- },
20
- "dependencies": {
21
- "@eslint-community/eslint-plugin-eslint-comments": "4.3.0",
22
- "@eslint/compat": "1.1.0",
23
- "@eslint/js": "9.6.0",
24
- "@stylistic/eslint-plugin": "2.3.0",
25
- "@stylistic/eslint-plugin-migrate": "2.3.0",
26
- "confusing-browser-globals": "1.0.11",
27
- "eslint-plugin-chai-expect": "3.1.0",
28
- "eslint-plugin-codeceptjs": "1.3.0",
29
- "eslint-plugin-eslint-plugin": "6.2.0",
30
- "eslint-plugin-jest": "28.6.0",
31
- "eslint-plugin-jest-dom": "5.4.0",
32
- "eslint-plugin-jsdoc": "48.5.0",
33
- "eslint-plugin-jsonc": "2.16.0",
34
- "eslint-plugin-jsx-a11y": "6.9.0",
35
- "eslint-plugin-jsx-expressions": "1.3.2",
36
- "eslint-plugin-license-header": "0.6.1",
37
- "eslint-plugin-n": "17.9.0",
38
- "eslint-plugin-promise": "6.4.0",
39
- "eslint-plugin-react": "7.34.3",
40
- "eslint-plugin-react-hooks": "4.6.2",
41
- "eslint-plugin-react-hooks-static-deps": "1.0.7",
42
- "eslint-plugin-react-refresh": "0.4.7",
43
- "eslint-plugin-testing-library": "6.2.2",
44
- "eslint-plugin-vitest": "0.5.4",
45
- "eslint-plugin-yml": "1.14.0",
46
- "globals": "15.8.0",
47
- "typescript-eslint": "7.15.0"
48
- },
49
- "devDependencies": {
50
- "eslint": "9.6.0",
51
- "husky": "9.0.11",
52
- "typescript": "5.5.3"
53
- },
54
- "peerDependencies": {
55
- "eslint": "^9.6.0",
56
- "typescript": "^5.5.3"
57
- },
58
- "resolutions": {
59
- "semver": "^7.6.2"
60
- }
61
- }
2
+ "name": "@open-xchange/linter-presets",
3
+ "version": "0.0.3",
4
+ "description": "Configuration presets for ESLint and StyleLint",
5
+ "repository": "https://gitlab.open-xchange.com/fspd/npm-packages/linter-presets",
6
+ "license": "MIT",
7
+ "engines": {
8
+ "node": ">=18"
9
+ },
10
+ "packageManager": "yarn@4.3.1",
11
+ "type": "module",
12
+ "exports": "./lib/index.js",
13
+ "scripts": {
14
+ "prepare": "husky",
15
+ "lint": "eslint ."
16
+ },
17
+ "lint-staged": {
18
+ "*.{js,ts,json}": "yarn lint"
19
+ },
20
+ "dependencies": {
21
+ "@eslint-community/eslint-plugin-eslint-comments": "4.3.0",
22
+ "@eslint/compat": "1.1.0",
23
+ "@eslint/js": "9.6.0",
24
+ "@stylistic/eslint-plugin": "2.3.0",
25
+ "@stylistic/eslint-plugin-migrate": "2.3.0",
26
+ "@stylistic/stylelint-config": "1.0.1",
27
+ "@stylistic/stylelint-plugin": "2.1.2",
28
+ "confusing-browser-globals": "1.0.11",
29
+ "eslint-plugin-chai-expect": "3.1.0",
30
+ "eslint-plugin-codeceptjs": "1.3.0",
31
+ "eslint-plugin-eslint-plugin": "6.2.0",
32
+ "eslint-plugin-import": "2.29.1",
33
+ "eslint-plugin-jest": "28.6.0",
34
+ "eslint-plugin-jest-dom": "5.4.0",
35
+ "eslint-plugin-jsdoc": "48.5.2",
36
+ "eslint-plugin-jsonc": "2.16.0",
37
+ "eslint-plugin-jsx-a11y": "6.9.0",
38
+ "eslint-plugin-jsx-expressions": "1.3.2",
39
+ "eslint-plugin-license-header": "0.6.1",
40
+ "eslint-plugin-n": "17.9.0",
41
+ "eslint-plugin-promise": "6.4.0",
42
+ "eslint-plugin-react": "7.34.3",
43
+ "eslint-plugin-react-hooks": "4.6.2",
44
+ "eslint-plugin-react-hooks-static-deps": "1.0.7",
45
+ "eslint-plugin-react-refresh": "0.4.7",
46
+ "eslint-plugin-testing-library": "6.2.2",
47
+ "eslint-plugin-vitest": "0.5.4",
48
+ "eslint-plugin-yml": "1.14.0",
49
+ "globals": "15.8.0",
50
+ "package-up": "5.0.0",
51
+ "picomatch": "4.0.2",
52
+ "stylelint-config-standard": "36.0.1",
53
+ "stylelint-config-standard-less": "3.0.1",
54
+ "stylelint-config-standard-scss": "13.1.0",
55
+ "stylelint-plugin-license-header": "1.0.3",
56
+ "typescript-eslint": "7.16.0"
57
+ },
58
+ "devDependencies": {
59
+ "@types/acorn": "6.0.0",
60
+ "eslint": "9.6.0",
61
+ "husky": "9.0.11",
62
+ "jest": "29.7.0",
63
+ "stylelint": "16.6.1",
64
+ "typescript": "5.5.3"
65
+ },
66
+ "peerDependencies": {
67
+ "eslint": "^9.6",
68
+ "jest": "^29.7",
69
+ "stylelint": "^16.6",
70
+ "typescript": "^5.5",
71
+ "vitest": "^2.0"
72
+ },
73
+ "peerDependenciesMeta": {
74
+ "jest": {
75
+ "optional": true
76
+ },
77
+ "stylelint": {
78
+ "optional": true
79
+ },
80
+ "typescript": {
81
+ "optional": true
82
+ },
83
+ "vitest": {
84
+ "optional": true
85
+ }
86
+ },
87
+ "resolutions": {
88
+ "semver": "^7.6.2"
89
+ }
90
+ }
package/doc/eslint.md DELETED
@@ -1,343 +0,0 @@
1
- # ESLint Presets
2
-
3
- The module `eslint` provides a `configure` function for project-wide ESLint configuration (e.g. TypeScript files, JSON files, license headers, etc.), and a set of environment presets that apply more ESLint plugins and rules to a specific subset of the project (e.g. browser code, unit test code, etc.).
4
-
5
- ## Functions
6
-
7
- ### Function `configure`
8
-
9
- Generates standard configuration targeting the source files in the entire project. Internally, various ESLint plugins will be included and configured to use their recommended rule sets.
10
-
11
- | Target | ESLint Plugin |
12
- | - | - |
13
- | JavaScript and TypeScript files (including `.jsx` and `.tsx`) | ESLint core rules |
14
- | JavaScript files only (including `.jsx`) | ESLint core rules |
15
- | TypeScript files with type-aware rules (including `.tsx`) | [typescript-eslint](https://typescript-eslint.io/) |
16
- | JSON files | [eslint-plugin-jsonc](https://ota-meshi.github.io/eslint-plugin-jsonc/) |
17
- | YAML files | [eslint-plugin-yml](https://ota-meshi.github.io/eslint-plugin-yml/) |
18
- | License headers | [eslint-plugin-license-header](https://github.com/nikku/eslint-plugin-license-header) |
19
- | ESLint inline directives | [@eslint-community/eslint-plugin-eslint-comments](https://github.com/eslint-community/eslint-plugin-eslint-comments) |
20
- | Native ES6 promises | [eslint-plugin-promise](https://github.com/eslint-community/eslint-plugin-promise) |
21
- | JSDoc source documentation | [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) |
22
- | Source code formatting | [@stylistic/eslint-plugin](https://eslint.style/packages/default) |
23
-
24
- #### `configure` Signature
25
-
26
- `function configure(options?: ESLintPresetsOptions): Linter.FlatConfig[]`
27
-
28
- #### `configure` Options
29
-
30
- | Name | Type | Default | Description |
31
- | - | - | - | - |
32
- | `ignores` | `string[]` | `[]` | Glob patterns with all files and folders to be ignored by ESlint. |
33
- | `license` | `string` | `""` | Full path to the template file containing the license header to be used in all source files. |
34
- | `language` | `LanguageOptions` | | Configuration options for language and project setup. |
35
- | `language.ecmaVersion` | `number` | `2022` | The ECMAScript version to be used in the project (version or year). |
36
- | `language.sourceType` | `"module"\|"commonjs"` | `"module"` | Specifies how to treat `.js`, `.jsx`, `.ts`, and `.tsx` files. |
37
- | `stylistic` | `StylisticOptions` | | Configuration options for code style. |
38
- | `stylistic.indent` | `number` | `2` | Default indentation size (number of space characters). Will be applied to JavaScript, TypeScript, JSON, and YAML files, as well as JSX markup. |
39
- | `stylistic.semi` | `boolean` | `false` | Specifies whether to require semicolons following all statements (`true`), or to force to omit semicolons if possible according to ASI rules (`false`). |
40
- | `stylistic.quotes` | `"single"\|"double"\|"off"` | `"single"` | The type of the string delimiter character. |
41
- | `stylistic.dangle` | `"always"\|"never"\|"off"` | `"always"` | Specifies how to treat dangling commas in multiline lists. |
42
- | `rules` | `Linter.RulesRecord` | `{}` | Additional linter rules to be added to the global configuration. |
43
-
44
- #### `configure` Example
45
-
46
- ```js
47
- // eslint.config.js
48
- import { utils, eslint } from "@open-xchange/linter-presets"
49
-
50
- const resolve = utils.resolver(import.meta.url)
51
-
52
- export default [
53
- ...eslint.configure({
54
- ignores: ["dist/*", "external/**/*.yaml"],
55
- language: { ecmaVersion: 2024, sourceType: "commonjs" },
56
- license: resolve("./license.txt"),
57
- stylistic: { quotes: "double", semi: true },
58
- }),
59
- ]
60
- ```
61
-
62
- ## Environment Presets
63
-
64
- Environment presets will be applied to specific subsets of the project. Usually, they import one or more external ESLint plugins, apply their recommended rule set, and add or modify a few of their rules to establish the default setup for the project.
65
-
66
- ### Overview
67
-
68
- | Name | Target | ESLint Plugins |
69
- | - | - | - |
70
- | `env.tsconfig` | TypeScript project setup (per `tsconfig.json` file) | |
71
- | `env.node` | NodeJS modules | [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n) |
72
- | `env.browser` | Modules running in browsers | [globals](https://github.com/sindresorhus/globals), [confusing-browser-globals](https://github.com/facebook/create-react-app/tree/main/packages/confusing-browser-globals) |
73
- | `env.react` | Source modules using [React](https://react.dev/) library | [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) (and others) |
74
- | `env.jest` | Unit tests with [Jest](https://jestjs.io/) | [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) |
75
- | `env.vitest` | Unit tests with [Vitest](https://vitest.dev/) | [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest) (and others) |
76
- | `env.codecept` | E2E tests with [CodeceptJS](https://codecept.io/) | [eslint-plugin-codeceptjs](https://github.com/poenneby/eslint-plugin-codeceptjs) (and others) |
77
- | `env.plugin` | Implementation of custom ESLint plugins | [eslint-plugin-eslint-plugin](https://github.com/eslint-community/eslint-plugin-eslint-plugin) |
78
-
79
- ### Environment `env.tsconfig`
80
-
81
- Creates configuration objects for TypeScript projects (registers a `tsconfig.json` file in the project).
82
-
83
- #### `env.tsconfig` Signature
84
-
85
- `function tsconfig(options: EnvTSConfigOptions): Linter.FlatConfig[]`
86
-
87
- #### `env.tsconfig` Options
88
-
89
- | Name | Type | Default | Description |
90
- | - | - | - | - |
91
- | `files` | `string[]` | _required_ | Glob patterns for source files to be included. |
92
- | `ignores` | `string[]` | `[]` | Glob patterns for source files matching `files` to be ignored. |
93
- | `project` | `string` | _required_ | The path to the TypeScript project configuration file (`tsconfig.json`). |
94
- | `rules` | `Linter.RulesRecord` | `{}` | Additional linter rules to be added to the configuration. |
95
-
96
- #### `env.tsconfig` Example
97
-
98
- ```js
99
- // eslint.config.js
100
- import { utils, eslint } from "@open-xchange/linter-presets"
101
-
102
- const resolve = utils.resolver(import.meta.url)
103
-
104
- export default [
105
- ...eslint.configure({ /* ... */ }),
106
- ...eslint.env.tsconfig({
107
- files: ["src/**/*.ts"],
108
- project: resolve("src/tsconfig.json"),
109
- }),
110
- ]
111
- ```
112
-
113
- ### Environment `env.node`
114
-
115
- Creates configuration objects with global symbols and linter rules for NodeJS modules. Adds the plugin [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n) and its recommended rules.
116
-
117
- #### `env.node` Signature
118
-
119
- `function node(options: EnvNodeOptions): Linter.FlatConfig[]`
120
-
121
- #### `env.node` Options
122
-
123
- | Name | Type | Default | Description |
124
- | - | - | - | - |
125
- | `files` | `string[]` | _required_ | Glob patterns for source files to be included. |
126
- | `ignores` | `string[]` | `[]` | Glob patterns for source files matching `files` to be ignored. |
127
- | `sourceType` | `"module"\|"commonjs"` | `"module"` | Specifies how to treat `.js`, `.jsx`, `.ts`, and `.tsx`. |
128
- | `rules` | `Linter.RulesRecord` | `{}` | Additional linter rules to be added to the configuration. |
129
-
130
- #### `env.node` Example
131
-
132
- ```js
133
- // eslint.config.js
134
- import { utils, eslint } from "@open-xchange/linter-presets"
135
-
136
- export default [
137
- ...configure({ /* ... */ }),
138
- ...env.node({
139
- files: ["*.config.{js,ts}", "scripts/**/*.js"],
140
- rules: { /* ... */ },
141
- }),
142
- ]
143
- ```
144
-
145
- ### Environment `env.browser`
146
-
147
- Creates configuration objects with global symbols and linter rules for modules running in the browser. Adds well-known [browser globals](https://github.com/sindresorhus/globals), and forbids [confusing browser globals](https://github.com/facebook/create-react-app/tree/main/packages/confusing-browser-globals).
148
-
149
- #### `env.browser` Signature
150
-
151
- `function browser(options: EnvBrowserOptions): Linter.FlatConfig[]`
152
-
153
- #### `env.browser` Options
154
-
155
- | Name | Type | Default | Description |
156
- | - | - | - | - |
157
- | `files` | `string[]` | _required_ | Glob patterns for source files to be included. |
158
- | `ignores` | `string[]` | `[]` | Glob patterns for source files matching `files` to be ignored. |
159
- | `rules` | `Linter.RulesRecord` | `{}` | Additional linter rules to be added to the configuration. |
160
-
161
- #### `env.browser` Example
162
-
163
- ```js
164
- // eslint.config.js
165
- import { eslint } from "@open-xchange/linter-presets"
166
-
167
- export default [
168
- ...eslint.configure({ /* ... */ }),
169
- ...eslint.env.browser({
170
- files: ["src/**/*.{js,ts}"],
171
- rules: { /* ... */ },
172
- }),
173
- ]
174
- ```
175
-
176
- ### Environment `env.react`
177
-
178
- Creates configuration objects with linter rules for ReactJS. Adds the following plugins and their recommended rules:
179
-
180
- - [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react)
181
- - [eslint-plugin-react-hooks](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks)
182
- - [eslint-plugin-react-hooks-static-deps](https://github.com/stoikio/eslint-plugin-react-hooks-static-deps)
183
- - [eslint-plugin-react-refresh](https://github.com/ArnaudBarre/eslint-plugin-react-refresh)
184
- - [eslint-plugin-jsx-expressions](https://github.com/hluisson/eslint-plugin-jsx-expressions)
185
- - [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y)
186
-
187
- #### `env.react` Signature
188
-
189
- `function react(options: EnvReactOptions): Linter.FlatConfig[]`
190
-
191
- #### `env.react` Options
192
-
193
- | Name | Type | Default | Description |
194
- | - | - | - | - |
195
- | `files` | `string[]` | _required_ | Glob patterns for source files to be included. |
196
- | `ignores` | `string[]` | `[]` | Glob patterns for source files matching `files` to be ignored. |
197
- | `rules` | `Linter.RulesRecord` | `{}` | Additional linter rules to be added to the configuration. |
198
-
199
- #### `env.react` Example
200
-
201
- ```js
202
- // eslint.config.js
203
- import { eslint } from "@open-xchange/linter-presets"
204
-
205
- export default [
206
- ...eslint.configure({ /* ... */ }),
207
- ...eslint.env.react({
208
- files: ["src/**/*.{js,ts}"],
209
- rules: { /* ... */ },
210
- }),
211
- ]
212
- ```
213
-
214
- ### Environment `env.jest`
215
-
216
- Creates configuration objects with global symbols and linter rules for unit tests using Jest. Adds the plugin [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) and its recommended rules.
217
-
218
- #### `env.jest` Signature
219
-
220
- `function jest(options: EnvJestOptions): Linter.FlatConfig[]`
221
-
222
- #### `env.jest` Options
223
-
224
- | Name | Type | Default | Description |
225
- | - | - | - | - |
226
- | `files` | `string[]` | _required_ | Glob patterns for source files to be included. |
227
- | `ignores` | `string[]` | `[]` | Glob patterns for source files matching `files` to be ignored. |
228
- | `rules` | `Linter.RulesRecord` | `{}` | Additional linter rules to be added to the configuration. |
229
-
230
- #### `env.jest` Example
231
-
232
- ```js
233
- // eslint.config.js
234
- import { eslint } from "@open-xchange/linter-presets"
235
-
236
- export default [
237
- ...eslint.configure({ /* ... */ }),
238
- ...eslint.env.jest({
239
- files: ["test/**/*.{js,ts}"],
240
- rules: { /* ... */ },
241
- }),
242
- ]
243
- ```
244
-
245
- ### Environment `env.vitest`
246
-
247
- Creates configuration objects with global symbols and linter rules for unit tests using Vitest. Adds the following plugins and their recommended rules:
248
-
249
- - [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest)
250
- - [eslint-plugin-testing-library](https://github.com/testing-library/eslint-plugin-testing-library)
251
- - [eslint-plugin-jest-dom](https://github.com/testing-library/eslint-plugin-jest-dom)
252
-
253
- #### `env.vitest` Signature
254
-
255
- `function vitest(options: EnvVitestOptions): Linter.FlatConfig[]`
256
-
257
- #### `env.vitest` Options
258
-
259
- | Name | Type | Default | Description |
260
- | - | - | - | - |
261
- | `files` | `string[]` | _required_ | Glob patterns for source files to be included. |
262
- | `ignores` | `string[]` | `[]` | Glob patterns for source files matching `files` to be ignored. |
263
- | `rules` | `Linter.RulesRecord` | `{}` | Additional linter rules to be added to the configuration. |
264
-
265
- #### `env.vitest` Example
266
-
267
- ```js
268
- // eslint.config.js
269
- import { eslint } from "@open-xchange/linter-presets"
270
-
271
- export default [
272
- ...eslint.configure({ /* ... */ }),
273
- ...eslint.env.vitest({
274
- files: ["test/**/*.{js,ts}"],
275
- rules: { /* ... */ },
276
- }),
277
- ]
278
- ```
279
-
280
- ### Environment `env.codecept`
281
-
282
- Creates configuration objects with global symbols and linter rules for E2E tests using CodeceptJS. Adds the following plugins and their recommended rules:
283
-
284
- - [eslint-plugin-codeceptjs](https://github.com/poenneby/eslint-plugin-codeceptjs)
285
- - [eslint-plugin-chai-expect](https://github.com/turbo87/eslint-plugin-chai-expect)
286
-
287
- #### `env.codecept` Signature
288
-
289
- `function codecept(options: EnvCodeceptOptions): Linter.FlatConfig[]`
290
-
291
- #### `env.codecept` Options
292
-
293
- | Name | Type | Default | Description |
294
- | - | - | - | - |
295
- | `files` | `string[]` | _required_ | Glob patterns for source files to be included. |
296
- | `ignores` | `string[]` | `[]` | Glob patterns for source files matching `files` to be ignored. |
297
- | `rules` | `Linter.RulesRecord` | `{}` | Additional linter rules to be added to the configuration. |
298
-
299
- #### `env.codecept` Example
300
-
301
- ```js
302
- // eslint.config.js
303
- import { eslint } from "@open-xchange/linter-presets"
304
-
305
- export default [
306
- ...eslint.configure({ /* ... */ }),
307
- ...eslint.env.codecept({
308
- files: ["e2e/**/*.{js,ts}"],
309
- rules: { /* ... */ },
310
- }),
311
- ]
312
- ```
313
-
314
- ### Environment `env.plugin`
315
-
316
- Creates configuration objects with linter rules for implementing custom ESlint plugins. Adds the plugin [eslint-plugin-eslint-plugin](https://github.com/eslint-community/eslint-plugin-eslint-plugin) and its recommended rules.
317
-
318
- #### `env.plugin` Signature
319
-
320
- `function plugin(options: EnvPluginOptions): Linter.FlatConfig[]`
321
-
322
- #### `env.plugin` Options
323
-
324
- | Name | Type | Default | Description |
325
- | - | - | - | - |
326
- | `files` | `string[]` | _required_ | Glob patterns for source files to be included. |
327
- | `ignores` | `string[]` | `[]` | Glob patterns for source files matching `files` to be ignored. |
328
- | `rules` | `Linter.RulesRecord` | `{}` | Additional linter rules to be added to the configuration. |
329
-
330
- #### `env.plugin` Example
331
-
332
- ```js
333
- // eslint.config.js
334
- import { eslint } from "@open-xchange/linter-presets"
335
-
336
- export default [
337
- ...eslint.configure({ /* ... */ }),
338
- ...eslint.env.plugin({
339
- files: ["rules/**/*.{js,ts}"],
340
- rules: { /* ... */ },
341
- }),
342
- ]
343
- ```
package/doc/stylelint.md DELETED
@@ -1,3 +0,0 @@
1
- # StyleLint Presets
2
-
3
- The module `stylelint` provides a `configure` function for project-wide StyleLint configuration.
@@ -1,13 +0,0 @@
1
-
2
- import { FlatConfigArray, EnvBaseOptions } from "../shared/types.js";
3
-
4
- // types ======================================================================
5
-
6
- /**
7
- * Configuration options for the environment preset "env.plugin".
8
- */
9
- export interface EnvPluginOptions extends EnvBaseOptions { }
10
-
11
- // functions ==================================================================
12
-
13
- export default function plugin(options: EnvPluginOptions): FlatConfigArray;