@dfds-ui/eslint-config 2.2.0-alpha.a78c2264 → 2.2.0-alpha.af6aeee8

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.
@@ -0,0 +1,113 @@
1
+ // @ts-check
2
+ import eslintReact from '@eslint-react/eslint-plugin'
3
+ import eslintJs from '@eslint/js'
4
+ import globals from 'globals'
5
+ import tseslint from 'typescript-eslint'
6
+
7
+ /**
8
+ * Shared ESLint config for DFDS UI Components.
9
+ *
10
+ * Usage in the repo root eslint.config.mjs:
11
+ * import dfdsConfig from '@dfds-ui/eslint-config'
12
+ * export default [...dfdsConfig]
13
+ *
14
+ * @param {object} options
15
+ * @param {string} options.tsconfigRootDir - absolute path to the project root (use import.meta.dirname)
16
+ */
17
+ export function createConfig({ tsconfigRootDir }) {
18
+ return tseslint.config(
19
+ // ── JS recommended ──────────────────────────────────────────────
20
+ eslintJs.configs.recommended,
21
+
22
+ // ── TypeScript ──────────────────────────────────────────────────
23
+ ...tseslint.configs.recommended,
24
+
25
+ // ── React (eslint-react) ────────────────────────────────────────
26
+ eslintReact.configs['recommended-typescript'],
27
+
28
+ // ── Base rule overrides ─────────────────────────────────────────
29
+ {
30
+ rules: {
31
+ 'no-irregular-whitespace': [
32
+ 'warn',
33
+ {
34
+ skipComments: true,
35
+ skipRegExps: true,
36
+ skipTemplates: true,
37
+ },
38
+ ],
39
+ },
40
+ },
41
+
42
+ // ── CommonJS files (Node scripts, configs) ──────────────────────
43
+ {
44
+ files: ['**/*.js', '**/*.cjs'],
45
+ languageOptions: {
46
+ globals: globals.node,
47
+ },
48
+ rules: {
49
+ '@typescript-eslint/no-require-imports': 'off',
50
+ '@typescript-eslint/no-unused-vars': 'off',
51
+ 'preserve-caught-error': 'off',
52
+ },
53
+ },
54
+
55
+ // ── TypeScript file overrides ───────────────────────────────────
56
+ {
57
+ files: ['**/*.ts', '**/*.tsx'],
58
+ languageOptions: {
59
+ parser: tseslint.parser,
60
+ parserOptions: {
61
+ projectService: true,
62
+ tsconfigRootDir,
63
+ },
64
+ },
65
+ rules: {
66
+ 'no-console': 'warn',
67
+
68
+ // Prevent import of modules from other packages via relative paths
69
+ 'no-restricted-imports': [
70
+ 'error',
71
+ {
72
+ patterns: ['../**/src'],
73
+ },
74
+ ],
75
+
76
+ '@typescript-eslint/no-explicit-any': 'off',
77
+ '@typescript-eslint/no-unused-vars': [
78
+ 'off', // covered by noUnusedLocals in tsconfig
79
+ ],
80
+ '@typescript-eslint/no-unsafe-argument': 'off',
81
+ '@typescript-eslint/no-unsafe-assignment': 'off',
82
+ '@typescript-eslint/no-unsafe-call': 'off',
83
+ '@typescript-eslint/no-unsafe-member-access': 'off',
84
+ '@typescript-eslint/no-unsafe-return': 'off',
85
+ '@typescript-eslint/no-unused-expressions': 'off',
86
+ '@typescript-eslint/no-deprecated': 'warn',
87
+
88
+ 'prefer-rest-params': 'off',
89
+ 'no-extra-boolean-cast': 'off',
90
+ 'no-useless-assignment': 'off',
91
+
92
+ '@eslint-react/no-nested-component-definitions': 'off',
93
+ '@eslint-react/static-components': 'off',
94
+ '@eslint-react/no-create-ref': 'off',
95
+ },
96
+ },
97
+
98
+ // ── Story / test file relaxations ───────────────────────────────
99
+ {
100
+ files: ['**/*story.ts*', '**/*stories.ts*', '**/*test.ts*', '**/*tests.ts*', '**/*demo.ts*'],
101
+ rules: {
102
+ '@typescript-eslint/no-unsafe-argument': 'off',
103
+ },
104
+ },
105
+
106
+ // ── Global ignores ──────────────────────────────────────────────
107
+ {
108
+ ignores: ['**/dist/**', '**/node_modules/**'],
109
+ }
110
+ )
111
+ }
112
+
113
+ export default createConfig({ tsconfigRootDir: import.meta.dirname })
package/package.json CHANGED
@@ -5,21 +5,17 @@
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
- "version": "2.2.0-alpha.a78c2264",
8
+ "version": "2.2.0-alpha.af6aeee8",
9
+ "type": "module",
10
+ "exports": {
11
+ ".": "./eslint.config.mjs"
12
+ },
9
13
  "dependencies": {
10
- "@typescript-eslint/eslint-plugin": "^8.59.2",
11
- "@typescript-eslint/parser": "^8.59.2",
12
- "eslint": "8.57.1",
13
- "eslint-import-resolver-babel-module": "^5.3.2",
14
- "eslint-import-resolver-lerna": "^2.0.0",
15
- "eslint-import-resolver-typescript": "^3.10.1",
16
- "eslint-import-resolver-workspaces": "^1.2.0",
17
- "eslint-plugin-import": "^2.32.0",
18
- "eslint-plugin-prettier": "5.5.5",
19
- "eslint-plugin-react": "7.37.5",
20
- "eslint-plugin-react-hooks": "4.6.0",
21
- "eslint-plugin-simple-import-sort": "^13.0.0",
22
- "prettier": "3.8.3"
14
+ "@eslint-react/eslint-plugin": "5.7.5",
15
+ "@eslint/js": "10.0.1",
16
+ "eslint": "10.3.0",
17
+ "globals": "17.6.0",
18
+ "typescript-eslint": "8.59.2"
23
19
  },
24
- "gitHead": "a78c2264aa558061cf24673e789db86617e849cc"
20
+ "gitHead": "af6aeee86fe74e3962e75a24f028385142a42e1d"
25
21
  }
package/eslint.config.js DELETED
@@ -1,125 +0,0 @@
1
- module.exports = {
2
- root: true,
3
-
4
- parser: '@typescript-eslint/parser',
5
- extends: ['eslint:recommended'],
6
-
7
- rules: {
8
- 'no-irregular-whitespace': [
9
- 'warn',
10
- {
11
- skipComments: true,
12
- skipRegExps: true,
13
- skipTemplates: true,
14
- },
15
- ],
16
- 'no-extra-boolean-cast': 'off', // TODO: this will trigger in a few files. Consider enabling
17
- },
18
-
19
- settings: {
20
- react: {
21
- version: 'detect',
22
- },
23
- 'import/extensions': ['.ts', '.tsx', '.d.ts', '.js', '.jsx'],
24
-
25
- 'import/parsers': {
26
- '@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
27
- },
28
-
29
- 'import/resolver': {
30
- typescript: { alwaysTryTypes: true },
31
- },
32
- },
33
-
34
- overrides: [
35
- // typescript overrides
36
- {
37
- files: ['*.ts', '*.tsx'],
38
- plugins: ['@typescript-eslint', 'react-hooks', 'simple-import-sort', 'import'],
39
- extends: [
40
- 'plugin:@typescript-eslint/recommended',
41
- 'plugin:@typescript-eslint/recommended-type-checked',
42
- 'plugin:react/recommended',
43
- ],
44
- rules: {
45
- 'prefer-rest-params': 'off',
46
- 'no-console': 'warn',
47
- // prevent import of modules from other packages in the workspace using relative paths
48
- 'no-restricted-imports': [
49
- 'error',
50
- {
51
- patterns: ['../**/src'],
52
- },
53
- ],
54
-
55
- // Ordering of imports
56
- 'sort-imports': 'off', // turned off since we use simple-import-sort to handle ordering
57
- 'import/order': 'off', // turned off since we use simple-import-sort to handle ordering
58
- 'simple-import-sort/sort': 'off',
59
- 'import/no-extraneous-dependencies': 'error',
60
- 'import/no-named-as-default-member': 'off', // TODO: consider enable this?
61
- 'import/no-named-as-default': 'off', // TODO: consider enable this?
62
- 'import/default': 'off',
63
- 'import/export': 'error',
64
- 'import/no-unresolved': ['error'],
65
- 'import/namespace': ['error', { allowComputed: true }],
66
-
67
- '@typescript-eslint/explicit-function-return-type': 'off',
68
- '@typescript-eslint/no-use-before-define': 'off', // TODO: maybe enable this?
69
- '@typescript-eslint/no-explicit-any': 'off',
70
- //TODO: use naming-convention
71
- //'@typescript-eslint/camelcase': 'warn',
72
- //TODO: use ban-ts-comment
73
- //'@typescript-eslint/ban-ts-ignore': 'error',
74
-
75
- '@typescript-eslint/explicit-module-boundary-types': 'off', // TODO: TS4 consider enabling
76
- '@typescript-eslint/no-unsafe-argument': 'off', // TODO: Consider eabling
77
- '@typescript-eslint/no-unsafe-assignment': 'off', // TODO: TS4 consider enabling
78
- '@typescript-eslint/no-unsafe-call': 'off', // TODO: TS4 consider enabling
79
- '@typescript-eslint/no-unsafe-member-access': 'off', // TODO: TS4 consider enabling
80
- '@typescript-eslint/no-unsafe-return': 'off', // TODO: TS4 consider enabling
81
- '@typescript-eslint/restrict-template-expressions': 'off',
82
- '@typescript-eslint/no-misused-promises': 'error',
83
- '@typescript-eslint/no-deprecated': 'warn',
84
-
85
- // TODO: enable this again when babel-lint supports it
86
- // Using babel-eslint (v11 beta ATTOW) as the parser have issues with this rule so it's disabled
87
- // The rule is currently covered by 'noUnusedLocals' in tsconfig.json
88
- // https://github.com/babel/babel-eslint/milestone/1
89
- '@typescript-eslint/no-unused-vars': [
90
- 'off',
91
- {
92
- vars: 'all',
93
- args: 'after-used',
94
- ignoreRestSiblings: false,
95
- argsIgnorePattern: '^_',
96
- },
97
- ],
98
-
99
- '@typescript-eslint/no-unused-expressions': 'off', // TODO: New in TSESLint8 consider enabling
100
-
101
- 'react/display-name': 'off',
102
- 'react/prop-types': 'off',
103
- 'react/react-in-jsx-scope': 'off',
104
- 'react-hooks/rules-of-hooks': 'error',
105
- 'react-hooks/exhaustive-deps': 'warn',
106
- 'react/no-unescaped-entities': 'off', // TODO: maybe enable this?
107
- 'react/no-unknown-property': ['error', { ignore: ['css'] }],
108
- 'react/jsx-no-literals': 'off', // TODO: maybe enable this?
109
- },
110
- },
111
- // javascript overrides
112
- {
113
- files: ['*.js'],
114
- env: {
115
- node: true,
116
- },
117
- },
118
- {
119
- files: ['scripts/jest/setup.js'],
120
- env: {
121
- browser: true,
122
- },
123
- },
124
- ],
125
- }
package/index.js DELETED
@@ -1,3 +0,0 @@
1
- const config = require('./eslint.config')
2
-
3
- module.exports = config