@bigbinary/neeto-playwright-commons 1.21.3 → 1.22.0

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.
@@ -1,95 +1,128 @@
1
+ import neeto from "@bigbinary/eslint-plugin-neeto";
2
+ import js from "@eslint/js";
3
+ import tsEslint from "@typescript-eslint/eslint-plugin";
4
+ import tsParser from "@typescript-eslint/parser";
5
+ import playwrightPlugin from "eslint-plugin-playwright";
6
+ import importPlugin from "eslint-plugin-import";
7
+ import globals from "globals";
8
+ import path from "path";
9
+
1
10
  const commonEslintConfig = ({
2
- ignorePatterns = [],
11
+ ignores = [],
3
12
  extendsOverrides = [],
4
13
  overrideRules = {},
5
14
  tsconfigRootDir = "",
6
15
  }) => {
7
- return {
8
- ignorePatterns,
9
- env: { browser: true, es2021: true, node: true },
10
- extends: [
11
- "eslint:recommended",
12
- "plugin:@typescript-eslint/recommended",
13
- "plugin:playwright/recommended",
14
- ...extendsOverrides,
15
- ],
16
- overrides: [
17
- {
18
- env: { node: true },
19
- files: [".eslintrc.{js,cjs}"],
20
- parserOptions: { sourceType: "script", requireConfigFile: false },
21
- rules: { "@typescript-eslint/no-var-requires": "off" },
22
- },
23
- {
24
- env: { node: true },
25
- files: ["*.ts", "*.spec.ts"],
26
- parser: "@typescript-eslint/parser",
16
+ const configs = [
17
+ js.configs.recommended,
18
+ {
19
+ ignores: [...ignores],
20
+ },
21
+
22
+ {
23
+ files: ["**/*.ts", "**/*.spec.ts"],
24
+ ignores: ["**/*.d.ts"],
25
+ languageOptions: {
26
+ parser: tsParser,
27
27
  parserOptions: {
28
28
  ecmaVersion: "latest",
29
29
  sourceType: "module",
30
30
  tsconfigRootDir,
31
31
  project: ["./tsconfig.json"],
32
32
  },
33
- plugins: ["@typescript-eslint", "import"],
34
- rules: {
35
- "@bigbinary/neeto/use-dayjs-from-neeto-commons-fronted": "off",
36
- "@bigbinary/neeto/use-array-methods": "off",
37
- "@typescript-eslint/no-floating-promises": "error",
38
- "no-unused-vars": "off",
39
- "@typescript-eslint/no-unused-vars": [
40
- "error",
41
- { destructuredArrayIgnorePattern: "^_" },
42
- ],
43
- "@typescript-eslint/no-explicit-any": [
44
- "error",
45
- { ignoreRestArgs: true },
46
- ],
33
+ globals: {
34
+ ...globals.browser,
35
+ ...globals.es2021,
36
+ ...globals.node,
37
+ },
38
+ },
39
+ plugins: {
40
+ "@typescript-eslint": tsEslint,
41
+ playwright: playwrightPlugin,
42
+ import: importPlugin,
43
+ "@bigbinary/neeto": neeto,
44
+ },
45
+ rules: {
46
+ ...tsEslint.configs.recommended.rules,
47
+ ...playwrightPlugin.configs.recommended.rules,
48
+
49
+ "@bigbinary/neeto/use-dayjs-from-neeto-commons-fronted": "off",
50
+ "@bigbinary/neeto/use-array-methods": "off",
51
+ "@typescript-eslint/no-floating-promises": "error",
52
+ "no-unused-vars": "off",
53
+ "@typescript-eslint/no-unused-vars": [
54
+ "error",
55
+ { destructuredArrayIgnorePattern: "^_" },
56
+ ],
57
+ "@typescript-eslint/no-explicit-any": [
58
+ "error",
59
+ { ignoreRestArgs: true },
60
+ ],
61
+ "@typescript-eslint/no-unused-expressions": [
62
+ "error",
63
+ { allowShortCircuit: true, allowTernary: true },
64
+ ],
47
65
 
48
- "playwright/expect-expect": "off",
49
- "playwright/no-conditional-in-test": "warn",
50
- "playwright/no-nth-methods": "error",
51
- "playwright/no-page-pause": "error",
52
- "playwright/no-raw-locators": "warn",
53
- "playwright/no-useless-await": "error",
54
- "playwright/no-useless-not": "error",
55
- "playwright/no-wait-for-timeout": "error",
56
- "playwright/prefer-strict-equal": "warn",
57
- "playwright/prefer-to-be": "warn",
58
- "playwright/prefer-to-contain": "error",
59
- "playwright/prefer-to-have-count": "error",
60
- "playwright/prefer-to-have-length": "error",
61
- "playwright/prefer-web-first-assertions": "error",
62
- "playwright/require-top-level-describe": "error",
63
- "playwright/require-soft-assertions": "off",
64
- "playwright/valid-expect": "error",
65
- "playwright/no-standalone-expect": "warn",
66
- "playwright/prefer-lowercase-title": [
67
- "error",
68
- { ignoreTopLevelDescribe: true, allowedPrefixes: ["Step"] },
69
- ],
70
- "import/order": [
71
- "error",
72
- {
73
- "newlines-between": "always",
74
- alphabetize: { order: "asc", caseInsensitive: true },
75
- warnOnUnassignedImports: true,
76
- groups: [
77
- "builtin",
78
- "external",
79
- "internal",
80
- "index",
81
- "sibling",
82
- "parent",
83
- "object",
84
- "type",
85
- ],
86
- },
87
- ],
88
- ...overrideRules,
66
+ "playwright/expect-expect": "off",
67
+ "playwright/no-conditional-in-test": "warn",
68
+ "playwright/no-nth-methods": "error",
69
+ "playwright/no-page-pause": "error",
70
+ "playwright/no-raw-locators": "warn",
71
+ "playwright/no-useless-await": "error",
72
+ "playwright/no-useless-not": "error",
73
+ "playwright/no-wait-for-timeout": "error",
74
+ "playwright/prefer-strict-equal": "warn",
75
+ "playwright/prefer-to-be": "warn",
76
+ "playwright/prefer-to-contain": "error",
77
+ "playwright/prefer-to-have-count": "error",
78
+ "playwright/prefer-to-have-length": "error",
79
+ "playwright/prefer-web-first-assertions": "error",
80
+ "playwright/require-top-level-describe": "error",
81
+ "playwright/require-soft-assertions": "off",
82
+ "playwright/valid-expect": "error",
83
+ "playwright/no-standalone-expect": "warn",
84
+ "playwright/valid-title": [
85
+ "warn",
86
+ { mustMatch: { test: "^(must|should)" }, ignoreTypeOfStepName: true },
87
+ ],
88
+ "playwright/prefer-lowercase-title": [
89
+ "error",
90
+ { ignoreTopLevelDescribe: true, allowedPrefixes: ["Step"] },
91
+ ],
92
+ "import/order": [
93
+ "error",
94
+ {
95
+ "newlines-between": "always",
96
+ alphabetize: { order: "asc", caseInsensitive: true },
97
+ warnOnUnassignedImports: true,
98
+ groups: [
99
+ "builtin",
100
+ "external",
101
+ "internal",
102
+ "index",
103
+ "sibling",
104
+ "parent",
105
+ "object",
106
+ "type",
107
+ ],
108
+ },
109
+ ],
110
+ ...overrideRules,
111
+ },
112
+ settings: {
113
+ "import/resolver": {
114
+ typescript: {
115
+ alwaysTryTypes: true,
116
+ project: path.join(tsconfigRootDir, "tsconfig.json"),
117
+ },
89
118
  },
90
119
  },
91
- ],
92
- };
120
+ },
121
+
122
+ ...extendsOverrides,
123
+ ];
124
+
125
+ return configs;
93
126
  };
94
127
 
95
- module.exports = commonEslintConfig;
128
+ export default commonEslintConfig;
@@ -1,17 +1,42 @@
1
- const eslintConfig = require("./common");
1
+ import path from "path";
2
+ import eslintConfig from "./common.js";
3
+ import { fileURLToPath } from "url";
4
+ import { dirname } from "path";
2
5
 
3
- const hostEslintConfig = ({ rules = {}, tsconfigRootDir = "" }) => {
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
8
+
9
+ const hostEslintConfig = ({ rules = {}, tsconfigRootDir = "", ignores }) => {
4
10
  return eslintConfig({
5
11
  tsconfigRootDir,
6
- extendsOverrides: ["../.eslintrc.js"],
7
12
  overrideRules: {
8
- "@bigbinary/neeto/no-missing-localization": "warn",
13
+ "import/named": "off",
14
+ "react-hooks/rules-of-hooks": "off",
15
+ "@bigbinary/neeto/no-missing-localization": [
16
+ "warn",
17
+ {
18
+ translationsDir: path.resolve(
19
+ __dirname,
20
+ "../../../../../..",
21
+ "app/javascript/src/translations"
22
+ ),
23
+ languages: ["en"],
24
+ nanosTranslationDir: [
25
+ path.resolve(
26
+ __dirname,
27
+ "../../../../../..",
28
+ "node_modules/@bigbinary/neeto-commons-frontend/translations"
29
+ ),
30
+ ],
31
+ },
32
+ ],
9
33
  "@bigbinary/neeto/use-standard-date-time-formats": "warn",
10
34
  "@bigbinary/neeto/no-dangling-constants": "off",
11
35
  "@bigbinary/neeto/use-webpack-alias": "off",
12
36
  ...rules,
13
37
  },
38
+ ignores,
14
39
  });
15
40
  };
16
41
 
17
- module.exports = hostEslintConfig;
42
+ export default hostEslintConfig;