@open-xchange/linter-presets 0.0.1

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 (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +39 -0
  3. package/doc/eslint.md +343 -0
  4. package/doc/stylelint.md +3 -0
  5. package/doc/utils.md +30 -0
  6. package/lib/eslint/config/base.js +136 -0
  7. package/lib/eslint/config/directives.js +21 -0
  8. package/lib/eslint/config/js.js +36 -0
  9. package/lib/eslint/config/jsdoc.js +55 -0
  10. package/lib/eslint/config/json.js +37 -0
  11. package/lib/eslint/config/license.js +33 -0
  12. package/lib/eslint/config/promises.js +33 -0
  13. package/lib/eslint/config/stylistic.js +123 -0
  14. package/lib/eslint/config/ts.js +100 -0
  15. package/lib/eslint/config/yaml.js +34 -0
  16. package/lib/eslint/env/browser.d.ts +13 -0
  17. package/lib/eslint/env/browser.js +127 -0
  18. package/lib/eslint/env/codecept.d.ts +13 -0
  19. package/lib/eslint/env/codecept.js +70 -0
  20. package/lib/eslint/env/jest.d.ts +13 -0
  21. package/lib/eslint/env/jest.js +56 -0
  22. package/lib/eslint/env/node.d.ts +21 -0
  23. package/lib/eslint/env/node.js +59 -0
  24. package/lib/eslint/env/plugin.d.ts +13 -0
  25. package/lib/eslint/env/plugin.js +61 -0
  26. package/lib/eslint/env/react.d.ts +19 -0
  27. package/lib/eslint/env/react.js +103 -0
  28. package/lib/eslint/env/tsconfig.d.ts +19 -0
  29. package/lib/eslint/env/tsconfig.js +37 -0
  30. package/lib/eslint/env/vitest.d.ts +13 -0
  31. package/lib/eslint/env/vitest.js +103 -0
  32. package/lib/eslint/index.d.ts +90 -0
  33. package/lib/eslint/index.js +106 -0
  34. package/lib/eslint/shared/constants.js +33 -0
  35. package/lib/eslint/shared/types.d.ts +90 -0
  36. package/lib/index.d.ts +3 -0
  37. package/lib/index.js +3 -0
  38. package/lib/utils/index.d.ts +4 -0
  39. package/lib/utils/index.js +18 -0
  40. package/package.json +61 -0
@@ -0,0 +1,55 @@
1
+
2
+ import jsdocPlugin from "eslint-plugin-jsdoc";
3
+
4
+ // functions ==================================================================
5
+
6
+ /**
7
+ * Checks the JSDoc comments in source files.
8
+ *
9
+ * Wraps the following packages:
10
+ * - `eslint-plugin-jsdoc`
11
+ *
12
+ * @returns {import("../shared/types").FlatConfigArray}
13
+ * An array of configuration objects to be added to the flat configuration.
14
+ */
15
+ export default function jsdoc() {
16
+
17
+ return [
18
+
19
+ // register rule implementations and recommended rules
20
+ jsdocPlugin.configs["flat/recommended-error"],
21
+
22
+ // general configuration
23
+ {
24
+ settings: {
25
+ jsdoc: {
26
+ tagNamePreference: {
27
+ // disallowed tags for ES6 keywords `const`, `class`, `extends`
28
+ augments: false,
29
+ class: false,
30
+ const: false,
31
+ constant: false,
32
+ constructor: false,
33
+ extends: false,
34
+ },
35
+ },
36
+ },
37
+ },
38
+
39
+ // overrides for TypeScript files
40
+ {
41
+ files: ["**/*.{ts,tsx,cts,mts}"],
42
+ rules: {
43
+ ...jsdocPlugin.configs["flat/recommended-typescript-error"].rules,
44
+ "jsdoc/check-param-names": ["error", { allowExtraTrailingParamDocs: true }], // overload signatures
45
+ },
46
+ },
47
+
48
+ // configure plugin rules
49
+ {
50
+ rules: {
51
+ "jsdoc/tag-lines": "off",
52
+ },
53
+ },
54
+ ];
55
+ }
@@ -0,0 +1,37 @@
1
+
2
+ import jsonPlugin from "eslint-plugin-jsonc";
3
+
4
+ // functions ==================================================================
5
+
6
+ /**
7
+ * Defines standard linting rules for JSON files.
8
+ *
9
+ * Wraps the following packages:
10
+ * - `eslint-plugin-jsonc`
11
+ *
12
+ * @param {Required<import("../shared/types").StylisticOptions>} options
13
+ * Resolved configuration options.
14
+ *
15
+ * @returns {import("../shared/types").FlatConfigArray}
16
+ * An array of configuration objects to be added to the flat configuration.
17
+ */
18
+ export default function json(options) {
19
+
20
+ return [
21
+
22
+ // register rule implementations and recommended rules
23
+ ...jsonPlugin.configs["flat/recommended-with-json"],
24
+
25
+ // reconfigure plugin rules
26
+ {
27
+ rules: {
28
+ "jsonc/array-bracket-spacing": "error",
29
+ "jsonc/comma-style": "error",
30
+ "jsonc/indent": ["error", options.indent],
31
+ "jsonc/key-spacing": ["error", { mode: "minimum" }],
32
+ "jsonc/no-irregular-whitespace": "error",
33
+ "jsonc/no-octal-escape": "error",
34
+ },
35
+ },
36
+ ];
37
+ }
@@ -0,0 +1,33 @@
1
+
2
+ import licensePlugin from "eslint-plugin-license-header";
3
+
4
+ // functions ==================================================================
5
+
6
+ /**
7
+ * Checks the existence of license headers in source files.
8
+ *
9
+ * Wraps the following packages:
10
+ * - `eslint-plugin-license-header`
11
+ *
12
+ * @param {string} path
13
+ * Path to the template file containing the license header.
14
+ *
15
+ * @returns {import("../shared/types").FlatConfigArray}
16
+ * An array of configuration objects to be added to the flat configuration.
17
+ */
18
+ export default function license(path) {
19
+
20
+ return [{
21
+ files: ["**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}"],
22
+
23
+ // register rule implementations of the plugin
24
+ plugins: {
25
+ "license-header": licensePlugin,
26
+ },
27
+
28
+ // configure plugin rules
29
+ rules: {
30
+ "license-header/header": ["error", path],
31
+ },
32
+ }];
33
+ }
@@ -0,0 +1,33 @@
1
+
2
+ import promisePlugin from "eslint-plugin-promise";
3
+
4
+ // functions ==================================================================
5
+
6
+ /**
7
+ * Checks for correct usage of native promises.
8
+ *
9
+ * Wraps the following packages:
10
+ * - `eslint-plugin-promise`
11
+ *
12
+ * @returns {import("../shared/types").FlatConfigArray}
13
+ * An array of configuration objects to be added to the flat configuration.
14
+ */
15
+ export default function promises() {
16
+
17
+ return [
18
+
19
+ // register rule implementations and recommended rules
20
+ promisePlugin.configs["flat/recommended"],
21
+
22
+ // reconfigure plugin rules
23
+ {
24
+ rules: {
25
+ "promise/always-return": ["error", { ignoreLastCallback: true }],
26
+ "promise/no-callback-in-promise": "off",
27
+ "promise/no-nesting": "error", // warning => error
28
+ "promise/no-return-in-finally": "error",
29
+ "promise/valid-params": "error", // warning => error
30
+ },
31
+ },
32
+ ];
33
+ }
@@ -0,0 +1,123 @@
1
+
2
+ import stylisticPlugin from "@stylistic/eslint-plugin";
3
+ import migratePlugin from "@stylistic/eslint-plugin-migrate";
4
+
5
+ // functions ==================================================================
6
+
7
+ /**
8
+ * Defines standard (opinionated) linter rules for source code style.
9
+ *
10
+ * Wraps the following packages:
11
+ * - `@stylistic/eslint-plugin`
12
+ * - `@stylistic/eslint-plugin-migrate`
13
+ *
14
+ * @param {Required<import("../shared/types").StylisticOptions>} options
15
+ * Resolved configuration options.
16
+ *
17
+ * @returns {import("../shared/types").FlatConfigArray}
18
+ * An array of configuration objects to be added to the flat configuration.
19
+ */
20
+ export default function stylistic(options) {
21
+
22
+ // configuration properties
23
+ const { indent, semi, quotes, dangle } = options;
24
+
25
+ return [
26
+
27
+ // globally disable all deprecated stylistic core rules
28
+ stylisticPlugin.configs["disable-legacy"],
29
+
30
+ // "@stylistic" plugin
31
+ {
32
+ // register rule implementations of the plugins
33
+ plugins: {
34
+ "@stylistic": stylisticPlugin,
35
+ },
36
+
37
+ // configure plugin rules
38
+ rules: {
39
+ "@stylistic/array-bracket-spacing": "error",
40
+ "@stylistic/arrow-spacing": "error",
41
+ "@stylistic/block-spacing": "error",
42
+ "@stylistic/brace-style": ["error", "1tbs", { allowSingleLine: true }],
43
+ "@stylistic/comma-dangle": (dangle === "always") ? ["error", "always-multiline"] : (dangle === "never") ? ["error", "never"] : "off",
44
+ "@stylistic/comma-spacing": "error",
45
+ "@stylistic/comma-style": "error",
46
+ "@stylistic/computed-property-spacing": "error",
47
+ "@stylistic/eol-last": "error",
48
+ "@stylistic/function-call-spacing": "error",
49
+ "@stylistic/generator-star-spacing": "error",
50
+ "@stylistic/indent": ["error", indent, { SwitchCase: 1, MemberExpression: "off", flatTernaryExpressions: true }],
51
+ "@stylistic/indent-binary-ops": ["error", indent],
52
+ "@stylistic/jsx-child-element-spacing": "error",
53
+ "@stylistic/jsx-curly-brace-presence": "error",
54
+ "@stylistic/jsx-curly-spacing": "error",
55
+ "@stylistic/jsx-equals-spacing": "error",
56
+ "@stylistic/jsx-function-call-newline": "error",
57
+ "@stylistic/jsx-indent-props": ["error", indent],
58
+ "@stylistic/jsx-one-expression-per-line": "off",
59
+ "@stylistic/jsx-pascal-case": "error",
60
+ "@stylistic/jsx-quotes": "error",
61
+ "@stylistic/jsx-self-closing-comp": "error",
62
+ "@stylistic/jsx-wrap-multilines": "error",
63
+ "@stylistic/key-spacing": ["error", { mode: "minimum" }],
64
+ "@stylistic/keyword-spacing": "error",
65
+ "@stylistic/linebreak-style": "error",
66
+ "@stylistic/member-delimiter-style": "error",
67
+ "@stylistic/new-parens": "error",
68
+ "@stylistic/no-extra-semi": "error",
69
+ "@stylistic/no-floating-decimal": "error",
70
+ "@stylistic/no-mixed-operators": ["error", {
71
+ groups: [
72
+ // allow to mix arithmetic operators
73
+ // ["+", "-", "*", "/", "%", "**"],
74
+ ["&", "|", "^", "~", "<<", ">>", ">>>"],
75
+ ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
76
+ ["&&", "||"],
77
+ ["in", "instanceof"],
78
+ ],
79
+ allowSamePrecedence: true,
80
+ }],
81
+ "@stylistic/no-multiple-empty-lines": ["error", { max: 2 }],
82
+ "@stylistic/no-tabs": "error",
83
+ "@stylistic/no-trailing-spaces": "error",
84
+ "@stylistic/no-whitespace-before-property": "error",
85
+ "@stylistic/object-curly-spacing": ["error", "always"],
86
+ "@stylistic/quote-props": ["error", "as-needed"],
87
+ "@stylistic/quotes": (quotes === "off") ? "off" : ["error", quotes, { avoidEscape: true }],
88
+ "@stylistic/rest-spread-spacing": "error",
89
+ "@stylistic/semi": ["error", semi ? "always" : "never"],
90
+ "@stylistic/semi-spacing": "error",
91
+ "@stylistic/semi-style": "error",
92
+ "@stylistic/space-before-blocks": "error",
93
+ "@stylistic/space-before-function-paren": ["error", { anonymous: "always", named: "never", asyncArrow: "always" }],
94
+ "@stylistic/space-in-parens": "error",
95
+ "@stylistic/space-infix-ops": "error",
96
+ "@stylistic/space-unary-ops": "error",
97
+ "@stylistic/switch-colon-spacing": "error",
98
+ "@stylistic/template-curly-spacing": "error",
99
+ "@stylistic/template-tag-spacing": "error",
100
+ "@stylistic/type-annotation-spacing": "error",
101
+ "@stylistic/type-generic-spacing": "error",
102
+ "@stylistic/type-named-tuple-spacing": "error",
103
+ "@stylistic/wrap-iife": "error",
104
+ "@stylistic/yield-star-spacing": "error",
105
+ },
106
+ },
107
+
108
+ // "@stylistic/migrate" plugin
109
+ {
110
+ // register rule implementations of the plugins
111
+ plugins: {
112
+ "@stylistic/migrate": migratePlugin,
113
+ },
114
+
115
+ // configure plugin rules
116
+ rules: {
117
+ "@stylistic/migrate/migrate-js": "error",
118
+ "@stylistic/migrate/migrate-ts": "error",
119
+ "@stylistic/migrate/migrate-jsx": "error",
120
+ },
121
+ },
122
+ ];
123
+ }
@@ -0,0 +1,100 @@
1
+ /*
2
+ * Copyright (C) Open-Xchange GmbH, Germany <info@open-xchange.com>
3
+ *
4
+ * This program is proprietary software and licensed to you under Open-Xchange
5
+ * GmbH's Software License Agreement.
6
+ */
7
+
8
+ import typescriptEslint from "typescript-eslint";
9
+
10
+ import { NO_UNUSED_VARS_OPTIONS } from "../shared/constants.js";
11
+
12
+ // functions ==================================================================
13
+
14
+ /**
15
+ * Defines standard rules for TypeScript source files.
16
+ *
17
+ * Wraps the following packages:
18
+ * - `typescript-eslint`
19
+ *
20
+ * @returns {import("../shared/types.js").FlatConfigArray}
21
+ * An array of configuration objects to be added to the flat configuration.
22
+ */
23
+ export default function ts() {
24
+
25
+ // plugin configuration, additional rules
26
+ return typescriptEslint.config({
27
+ files: ["**/*.{ts,tsx,mts,cts}"],
28
+
29
+ // suppress warning for new TypeScript versions
30
+ languageOptions: {
31
+ parserOptions: {
32
+ warnOnUnsupportedTypeScriptVersion: false,
33
+ },
34
+ },
35
+
36
+ // recommended rules
37
+ extends: [
38
+ ...typescriptEslint.configs.recommendedTypeChecked,
39
+ ...typescriptEslint.configs.stylisticTypeChecked,
40
+ ],
41
+
42
+ // reconfigure plugin rules
43
+ rules: {
44
+ "@typescript-eslint/array-type": ["error", { default: "array-simple" }],
45
+ "@typescript-eslint/consistent-indexed-object-style": "off",
46
+ "@typescript-eslint/consistent-type-exports": "error",
47
+ "@typescript-eslint/consistent-type-imports": ["error", { disallowTypeAnnotations: false }],
48
+ "@typescript-eslint/default-param-last": "error",
49
+ "@typescript-eslint/dot-notation": "error",
50
+ "@typescript-eslint/explicit-function-return-type": ["error", {
51
+ allowExpressions: true,
52
+ allowTypedFunctionExpressions: true,
53
+ allowHigherOrderFunctions: true,
54
+ allowConciseArrowFunctionExpressionsStartingWithVoid: true,
55
+ }],
56
+ "@typescript-eslint/no-array-constructor": "error",
57
+ "@typescript-eslint/no-array-delete": "error",
58
+ "@typescript-eslint/no-duplicate-type-constituents": "error",
59
+ "@typescript-eslint/no-empty-function": ["error", {
60
+ allow: ["private-constructors", "protected-constructors", "decoratedFunctions", "overrideMethods"],
61
+ }],
62
+ "@typescript-eslint/no-empty-interface": "off",
63
+ "@typescript-eslint/no-explicit-any": "off",
64
+ "@typescript-eslint/no-import-type-side-effects": "error",
65
+ "@typescript-eslint/no-invalid-this": "error",
66
+ "@typescript-eslint/no-loop-func": "error",
67
+ "@typescript-eslint/no-mixed-enums": "error",
68
+ "@typescript-eslint/no-namespace": ["error", { allowDeclarations: true }],
69
+ "@typescript-eslint/no-non-null-assertion": "off",
70
+ "@typescript-eslint/no-redeclare": "error",
71
+ "@typescript-eslint/no-shadow": ["error", { ignoreOnInitialization: true }],
72
+ "@typescript-eslint/no-unnecessary-template-expression": "error",
73
+ "@typescript-eslint/no-unsafe-enum-comparison": "error",
74
+ "@typescript-eslint/no-unsafe-unary-minus": "error",
75
+ "@typescript-eslint/no-unused-vars": ["error", NO_UNUSED_VARS_OPTIONS],
76
+ "@typescript-eslint/no-useless-constructor": "error",
77
+ "@typescript-eslint/only-throw-error": "error",
78
+ "@typescript-eslint/prefer-find": "error",
79
+ "@typescript-eslint/prefer-literal-enum-member": "error",
80
+ "@typescript-eslint/prefer-nullish-coalescing": "off",
81
+ "@typescript-eslint/prefer-promise-reject-errors": "error",
82
+ "@typescript-eslint/prefer-readonly": "error",
83
+ "@typescript-eslint/require-await": "error",
84
+ "@typescript-eslint/restrict-template-expressions": "off",
85
+ "@typescript-eslint/return-await": ["error", "always"],
86
+ "@typescript-eslint/switch-exhaustiveness-check": "error",
87
+ "@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
88
+ },
89
+ },
90
+
91
+ // fixes for module definition files
92
+ {
93
+ files: ["**/*.d.{ts,tsx,mts,cts}"],
94
+ rules: {
95
+ "@typescript-eslint/consistent-type-exports": "off",
96
+ "@typescript-eslint/consistent-type-imports": ["error", { prefer: "no-type-imports", disallowTypeAnnotations: false }],
97
+ "@typescript-eslint/no-extraneous-class": "off",
98
+ },
99
+ });
100
+ }
@@ -0,0 +1,34 @@
1
+
2
+ import yamlPlugin from "eslint-plugin-yml";
3
+
4
+ // functions ==================================================================
5
+
6
+ /**
7
+ * Defines standard linting rules for YAML files.
8
+ *
9
+ * Wraps the following packages:
10
+ * - `eslint-plugin-yml`
11
+ *
12
+ * @param {Required<import("../shared/types").StylisticOptions>} options
13
+ * Resolved configuration options.
14
+ *
15
+ * @returns {import("../shared/types").FlatConfigArray}
16
+ * An array of configuration objects to be added to the flat configuration.
17
+ */
18
+ export default function yaml(options) {
19
+
20
+ return [
21
+
22
+ // register rule implementations and recommended rules
23
+ ...yamlPlugin.configs["flat/recommended"],
24
+
25
+ // reconfigure plugin rules
26
+ {
27
+ rules: {
28
+ "yml/indent": ["error", options.indent],
29
+ "yml/key-spacing": ["error", { mode: "minimum" }],
30
+ "yml/require-string-key": "error",
31
+ },
32
+ },
33
+ ];
34
+ }
@@ -0,0 +1,13 @@
1
+
2
+ import { FlatConfigArray, EnvBaseOptions } from "../shared/types.js";
3
+
4
+ // types ======================================================================
5
+
6
+ /**
7
+ * Configuration options for the environment preset "env.browser".
8
+ */
9
+ export interface EnvBrowserOptions extends EnvBaseOptions { }
10
+
11
+ // functions ==================================================================
12
+
13
+ export default function browser(options: EnvBrowserOptions): FlatConfigArray;
@@ -0,0 +1,127 @@
1
+
2
+ import JAVASCRIPT_GLOBALS from "globals";
3
+ import CONFUSING_BROWSER_GLOBALS from "confusing-browser-globals";
4
+
5
+ import { RESTRICTED_GLOBALS, RESTRICTED_SYNTAX } from "../shared/constants.js";
6
+
7
+ // constants ==================================================================
8
+
9
+ /**
10
+ * Global builtin symbols that are confusing or deprecated.
11
+ */
12
+ const CONFUSING_BUILTIN_GLOBALS = [
13
+ "constructor",
14
+ "escape",
15
+ "eval",
16
+ "hasOwnProperty",
17
+ "isPrototypeOf",
18
+ "propertyIsEnumerable",
19
+ "toLocaleString",
20
+ "toString",
21
+ "unescape",
22
+ "valueOf",
23
+ ];
24
+
25
+ /**
26
+ * Global browser classes that may conflict with custom application classes.
27
+ * For disambiguation, custom classes must be imported, and global browser
28
+ * classes must be used with their fully qualified name.
29
+ */
30
+ const AMBIGUOUS_BROWSER_TYPES = [
31
+ "Position",
32
+ "Point",
33
+ "Size",
34
+ "Range",
35
+ "Storage",
36
+ "Transformer",
37
+ ];
38
+
39
+ // initialization =============================================================
40
+
41
+ /**
42
+ * All supported global browser symbols intended to be used without fully
43
+ * qualified name (e.g. `HTMLElement` instead of `window.HTMLElement`).
44
+ * A few confusing globals will be filtered though, especially symbols with
45
+ * common names (e.g. `name`, `event`, etc.) to be able to catch missing or
46
+ * misspelled variables or parameter names.
47
+ */
48
+ const BROWSER_GLOBALS = {};
49
+
50
+ // Add all builtin ES globals.
51
+ for (const name of Object.keys(JAVASCRIPT_GLOBALS.builtin)) {
52
+ BROWSER_GLOBALS[name] = "readonly";
53
+ }
54
+
55
+ // Add browser globals (skip writable properties, e.g. window event handlers).
56
+ for (const [name, writable] of Object.entries(JAVASCRIPT_GLOBALS.browser)) {
57
+ if (!writable) { BROWSER_GLOBALS[name] = "readonly"; }
58
+ }
59
+
60
+ // Remove commonly known confusing or deprecated builtin globals.
61
+ for (const name of CONFUSING_BUILTIN_GLOBALS) {
62
+ delete BROWSER_GLOBALS[name];
63
+ }
64
+
65
+ // Remove commonly known confusing browser globals (e.g. `name`, `event`).
66
+ for (const name of CONFUSING_BROWSER_GLOBALS) {
67
+ delete BROWSER_GLOBALS[name];
68
+ }
69
+
70
+ // Create the configuration list for rule "no-restricted-globals".
71
+ const AMBIGUOUS_BROWSER_GLOBALS = AMBIGUOUS_BROWSER_TYPES.map(name => {
72
+ const message = `Import custom type '${name}', or use 'window.${name}' for disambiguation.`;
73
+ return { name, message };
74
+ });
75
+
76
+ // functions ==================================================================
77
+
78
+ /**
79
+ * Creates configuration objects with global symbols and linter rules for for
80
+ * browser modules.
81
+ *
82
+ * Wraps the following packages:
83
+ * - `globals`
84
+ * - `confusing-browser-globals`
85
+ *
86
+ * @param {import("./browser").EnvBrowserOptions} options
87
+ * Configuration options for the environment.
88
+ *
89
+ * @returns {import("../shared/types").FlatConfigArray}
90
+ * An array of configuration objects to be added to the flat configuration.
91
+ */
92
+ export default function browser(options) {
93
+
94
+ // configuration properties
95
+ const { files, ignores = [], rules } = options;
96
+
97
+ return [{
98
+ files,
99
+ ignores,
100
+
101
+ // register global symbols used in browser scripts
102
+ languageOptions: {
103
+ globals: BROWSER_GLOBALS,
104
+ },
105
+
106
+ // configure rules
107
+ rules: {
108
+ // ban specific browser globals
109
+ "no-restricted-globals": ["error",
110
+ ...RESTRICTED_GLOBALS,
111
+ ...AMBIGUOUS_BROWSER_GLOBALS,
112
+ ],
113
+ // ban static class functions
114
+ "no-restricted-properties": ["error",
115
+ { object: "Object", property: "hasOwn", message: "Missing browser support." },
116
+ ],
117
+ // ban specific syntax constructs
118
+ "no-restricted-syntax": ["error",
119
+ ...RESTRICTED_SYNTAX,
120
+ { selector: "ClassBody > StaticBlock", message: "Static blocks not supported yet." },
121
+ { selector: "ExportNamedDeclaration > TSEnumDeclaration[const=true]", message: "Do not export const enums." },
122
+ ],
123
+ // custom rules
124
+ ...rules,
125
+ },
126
+ }];
127
+ }
@@ -0,0 +1,13 @@
1
+
2
+ import { FlatConfigArray, EnvBaseOptions } from "../shared/types.js";
3
+
4
+ // types ======================================================================
5
+
6
+ /**
7
+ * Configuration options for the environment preset "env.codecept".
8
+ */
9
+ export interface EnvCodeceptOptions extends EnvBaseOptions { }
10
+
11
+ // functions ==================================================================
12
+
13
+ export default function codecept(options: EnvCodeceptOptions): FlatConfigArray;
@@ -0,0 +1,70 @@
1
+ /*
2
+ * Copyright (C) Open-Xchange GmbH, Germany <info@open-xchange.com>
3
+ *
4
+ * This program is proprietary software and licensed to you under Open-Xchange
5
+ * GmbH's Software License Agreement.
6
+ */
7
+
8
+ import codeceptPlugin from "eslint-plugin-codeceptjs";
9
+ import chaiExpectPlugin from "eslint-plugin-chai-expect";
10
+
11
+ // functions ==================================================================
12
+
13
+ /**
14
+ * Creates configuration objects with global symbols and linter rules for E2E
15
+ * tests using CodeceptJS.
16
+ *
17
+ * Wraps the following packages:
18
+ * - `eslint-plugin-codeceptjs`
19
+ * - `eslint-plugin-chai-expect`
20
+ *
21
+ * @param {import("./codecept").EnvCodeceptOptions} options
22
+ * Configuration options for the environment.
23
+ *
24
+ * @returns {import("../shared/types").FlatConfigArray}
25
+ * An array of configuration objects to be added to the flat configuration.
26
+ */
27
+ export default function codecept(options) {
28
+
29
+ // configuration properties
30
+ const { files, ignores = [], rules } = options;
31
+
32
+ return [
33
+ {
34
+ files,
35
+ ignores,
36
+
37
+ // register rule implementations of the plugins
38
+ plugins: {
39
+ codeceptjs: codeceptPlugin,
40
+ },
41
+
42
+ // register global symbols of CodeceptJS
43
+ languageOptions: {
44
+ globals: {
45
+ ...codeceptPlugin.environments.codeceptjs.globals,
46
+ },
47
+ },
48
+
49
+ // configure plugin rules
50
+ rules: {
51
+ // recommended rules
52
+ ...codeceptPlugin.configs.recommended.rules,
53
+ // extra rules
54
+ "new-cap": ["error", {
55
+ capIsNewExceptions: ["After", "AfterSuite", "Before", "BeforeSuite", "Feature", "Scenario"],
56
+ }],
57
+ "no-restricted-properties": ["warn", { object: "Scenario", property: "todo", message: "Unexpected unimplemented test." }],
58
+ "codeceptjs/no-skipped-tests": "warn",
59
+ // custom rules
60
+ ...rules,
61
+ },
62
+ },
63
+
64
+ {
65
+ files,
66
+ ignores,
67
+ ...chaiExpectPlugin.configs["recommended-flat"],
68
+ },
69
+ ];
70
+ }
@@ -0,0 +1,13 @@
1
+
2
+ import { FlatConfigArray, EnvBaseOptions } from "../shared/types.js";
3
+
4
+ // types ======================================================================
5
+
6
+ /**
7
+ * Configuration options for the environment preset "env.jest".
8
+ */
9
+ export interface EnvJestOptions extends EnvBaseOptions { }
10
+
11
+ // functions ==================================================================
12
+
13
+ export default function jest(options: EnvJestOptions): FlatConfigArray;