@dfds-ui/eslint-config 2.2.1 → 3.0.0-alpha.2acb68f8

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,22 +5,17 @@
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
- "version": "2.2.1",
8
+ "version": "3.0.0-alpha.2acb68f8",
9
+ "type": "module",
10
+ "exports": {
11
+ ".": "./eslint.config.mjs"
12
+ },
9
13
  "dependencies": {
10
- "@typescript-eslint/eslint-plugin": "^5.40.1",
11
- "@typescript-eslint/parser": "^5.40.1",
12
- "eslint": "8.26.0",
13
- "eslint-import-resolver-babel-module": "^5.3.1",
14
- "eslint-import-resolver-lerna": "^2.0.0",
15
- "eslint-import-resolver-typescript": "^3.5.2",
16
- "eslint-import-resolver-workspaces": "^1.2.0",
17
- "eslint-plugin-deprecation": "^1.3.2",
18
- "eslint-plugin-import": "^2.26.0",
19
- "eslint-plugin-prettier": "4.2.1",
20
- "eslint-plugin-react": "7.31.10",
21
- "eslint-plugin-react-hooks": "4.6.0",
22
- "eslint-plugin-simple-import-sort": "^8.0.0",
23
- "prettier": "2.7.1"
14
+ "@eslint-react/eslint-plugin": "5.7.5",
15
+ "@eslint/js": "10.0.1",
16
+ "eslint": "10.4.1",
17
+ "globals": "17.6.0",
18
+ "typescript-eslint": "8.59.2"
24
19
  },
25
- "gitHead": "ff968cd26c278c656e617042759efdea213c0661"
20
+ "gitHead": "2acb68f8d36d638def6fb8f77d19073760d9b7d0"
26
21
  }
package/eslint.config.js DELETED
@@ -1,138 +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', 'deprecation'],
39
- extends: [
40
- 'plugin:@typescript-eslint/recommended',
41
- 'plugin:@typescript-eslint/recommended-requiring-type-checking',
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/member-delimiter-style': [
69
- 'warn',
70
- {
71
- multiline: {
72
- delimiter: 'none',
73
- requireLast: false,
74
- },
75
- singleline: {
76
- delimiter: 'semi',
77
- requireLast: false,
78
- },
79
- },
80
- ],
81
- '@typescript-eslint/interface-name-prefix': ['warn', { prefixWithI: 'always' }],
82
- '@typescript-eslint/no-use-before-define': 'off', // TODO: maybe enable this?
83
- '@typescript-eslint/no-explicit-any': 'off',
84
- //TODO: use naming-convention
85
- //'@typescript-eslint/camelcase': 'warn',
86
- '@typescript-eslint/type-annotation-spacing': 'warn',
87
- //TODO: use ban-ts-comment
88
- //'@typescript-eslint/ban-ts-ignore': 'error',
89
-
90
- '@typescript-eslint/explicit-module-boundary-types': 'off', // TODO: TS4 consider enabling
91
- '@typescript-eslint/no-unsafe-argument': 'off', // TODO: Consider eabling
92
- '@typescript-eslint/no-unsafe-assignment': 'off', // TODO: TS4 consider enabling
93
- '@typescript-eslint/no-unsafe-call': 'off', // TODO: TS4 consider enabling
94
- '@typescript-eslint/no-unsafe-member-access': 'off', // TODO: TS4 consider enabling
95
- '@typescript-eslint/no-unsafe-return': 'off', // TODO: TS4 consider enabling
96
- '@typescript-eslint/restrict-template-expressions': 'off',
97
- '@typescript-eslint/no-misused-promises': 'error',
98
-
99
- // TODO: enable this again when babel-lint supports it
100
- // Using babel-eslint (v11 beta ATTOW) as the parser have issues with this rule so it's disabled
101
- // The rule is currently covered by 'noUnusedLocals' in tsconfig.json
102
- // https://github.com/babel/babel-eslint/milestone/1
103
- '@typescript-eslint/no-unused-vars': [
104
- 'off',
105
- {
106
- vars: 'all',
107
- args: 'after-used',
108
- ignoreRestSiblings: false,
109
- argsIgnorePattern: '^_',
110
- },
111
- ],
112
-
113
- 'react/display-name': 'off',
114
- 'react/prop-types': 'off',
115
- 'react-hooks/rules-of-hooks': 'error',
116
- 'react-hooks/exhaustive-deps': 'warn',
117
- 'react/no-unescaped-entities': 'off', // TODO: maybe enable this?
118
- 'react/no-unknown-property': ['error', { ignore: ['css'] }],
119
- 'react/jsx-no-literals': 'off', // TODO: maybe enable this?
120
-
121
- 'deprecation/deprecation': 'warn',
122
- },
123
- },
124
- // javascript overrides
125
- {
126
- files: ['*.js'],
127
- env: {
128
- node: true,
129
- },
130
- },
131
- {
132
- files: ['scripts/jest/setup.js'],
133
- env: {
134
- browser: true,
135
- },
136
- },
137
- ],
138
- }
package/index.js DELETED
@@ -1,3 +0,0 @@
1
- const config = require('./eslint.config')
2
-
3
- module.exports = config