@foray1010/eslint-config 7.12.0 → 8.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [8.0.1](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@8.0.0...@foray1010/eslint-config@8.0.1) (2022-10-22)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **eslint-config:** add back support for node 14.17 ([3264119](https://github.com/foray1010/common-presets/commit/3264119b95b5364cd6c952536dffce49b5f14955))
11
+
12
+ ## [8.0.0](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@7.12.0...@foray1010/eslint-config@8.0.0) (2022-10-21)
13
+
14
+ ### ⚠ BREAKING CHANGES
15
+
16
+ - enforce file extension and use native esm typescript
17
+
18
+ ### Features
19
+
20
+ - enforce file extension and use native esm typescript ([c885710](https://github.com/foray1010/common-presets/commit/c8857103a3f828d2cf9946885495bd92d15b8d5d))
21
+
6
22
  ## [7.12.0](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@7.11.0...@foray1010/eslint-config@7.12.0) (2022-10-20)
7
23
 
8
24
  ### Features
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@foray1010/eslint-config",
4
- "version": "7.12.0",
4
+ "version": "8.0.1",
5
5
  "homepage": "https://github.com/foray1010/common-presets/tree/master/packages/eslint-config#readme",
6
6
  "bugs": "https://github.com/foray1010/common-presets/issues",
7
7
  "repository": {
@@ -28,6 +28,7 @@
28
28
  "@typescript-eslint/parser": "^5.38.1",
29
29
  "confusing-browser-globals": "^1.0.10",
30
30
  "eslint-config-prettier": "^8.3.0",
31
+ "eslint-import-resolver-typescript": "^2.7.1",
31
32
  "eslint-plugin-compat": "^4.0.0",
32
33
  "eslint-plugin-deprecation": "^1.3.2",
33
34
  "eslint-plugin-eslint-comments": "^3.2.0",
@@ -58,5 +59,5 @@
58
59
  "publishConfig": {
59
60
  "access": "public"
60
61
  },
61
- "gitHead": "122e9b3aaffb9257c1c119d0f60352a8ca006414"
62
+ "gitHead": "6e59bebe2614d102dc890d1524e3c54e6906af99"
62
63
  }
package/presets/base.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // @ts-expect-error
4
4
  const { hasDep, isESM } = require('@foray1010/common-presets-utils')
5
5
 
6
- const { testFileGlobs } = require('./utils/testUtil')
6
+ const { testFileGlobs } = require('./utils/testUtil.js')
7
7
 
8
8
  /** @type {import('eslint').Linter.BaseConfig} */
9
9
  const cjsConfig = {
@@ -33,19 +33,6 @@ const esmConfig = {
33
33
  },
34
34
  }
35
35
 
36
- /** @type {import('eslint').Linter.BaseConfig} */
37
- const esmConfigForJs = {
38
- ...esmConfig,
39
- rules: {
40
- ...esmConfig.rules,
41
- 'import/extensions': [
42
- 'error',
43
- // https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_mandatory_file_extensions
44
- 'always',
45
- ],
46
- },
47
- }
48
-
49
36
  /** @type {import('eslint').Linter.Config} */
50
37
  module.exports = {
51
38
  extends: [
@@ -84,6 +71,21 @@ module.exports = {
84
71
  'func-names': ['error', 'as-needed'],
85
72
  // this rule doesn't support commonjs, some dependencies are using commonjs
86
73
  'import/default': 'off',
74
+ // enforce extensions for both cjs and esm
75
+ 'import/extensions': [
76
+ 'error',
77
+ // https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_mandatory_file_extensions
78
+ 'always',
79
+ {
80
+ pattern: {
81
+ // ignore cts/mts/ts/tsx because typescript uses cjs/mjs/js instead
82
+ cts: 'never',
83
+ mts: 'never',
84
+ ts: 'never',
85
+ tsx: 'never',
86
+ },
87
+ },
88
+ ],
87
89
  // make sure import statements above the others
88
90
  'import/first': 'error',
89
91
  // separate import statements from the others
@@ -143,7 +145,7 @@ module.exports = {
143
145
  overrides: [
144
146
  {
145
147
  files: ['*.js'],
146
- ...(isESM() ? esmConfigForJs : cjsConfig),
148
+ ...(isESM() ? esmConfig : cjsConfig),
147
149
  },
148
150
  {
149
151
  files: ['*.cjs'],
@@ -151,7 +153,7 @@ module.exports = {
151
153
  },
152
154
  {
153
155
  files: ['*.mjs'],
154
- ...esmConfigForJs,
156
+ ...esmConfig,
155
157
  },
156
158
  {
157
159
  files: testFileGlobs,
@@ -186,15 +188,16 @@ module.exports = {
186
188
  // allowAutomaticSingleRunInference: true,
187
189
  project: ['./tsconfig*.json', './packages/*/tsconfig*.json'],
188
190
  },
191
+ settings: {
192
+ 'import/resolver': {
193
+ typescript: true,
194
+ },
195
+ },
189
196
  plugins: [
190
197
  '@typescript-eslint/eslint-plugin',
191
198
  'eslint-plugin-deprecation',
192
199
  'eslint-plugin-functional',
193
200
  ],
194
- env: {
195
- // allow commonjs globals as we haven't moved to es modules
196
- commonjs: true,
197
- },
198
201
  rules: {
199
202
  // extend existing rule
200
203
  '@typescript-eslint/ban-types': [
package/presets/node.js CHANGED
@@ -1,13 +1,20 @@
1
1
  'use strict'
2
2
 
3
+ // @ts-expect-error
4
+ const { isESM } = require('@foray1010/common-presets-utils')
5
+
6
+ /** @type {import('eslint').Linter.BaseConfig} */
7
+ const cjsConfig = {
8
+ globals: {
9
+ __dirname: 'readonly',
10
+ __filename: 'readonly',
11
+ },
12
+ }
13
+
3
14
  /** @type {import('eslint').Linter.Config} */
4
15
  module.exports = {
5
16
  plugins: ['eslint-plugin-n'],
6
17
  globals: {
7
- // used in commonjs and typescript
8
- __dirname: 'readonly',
9
- // used in commonjs and typescript
10
- __filename: 'readonly',
11
18
  // hack to mute no-undef error, and show n/prefer-global/buffer error instead
12
19
  Buffer: 'readonly',
13
20
  // hack to mute no-undef error, and show n/prefer-global/process error instead
@@ -41,4 +48,14 @@ module.exports = {
41
48
  // enforce shebang on the entry bin file
42
49
  'n/shebang': 'error',
43
50
  },
51
+ overrides: [
52
+ {
53
+ files: ['*.js'],
54
+ ...(isESM() ? {} : cjsConfig),
55
+ },
56
+ {
57
+ files: ['*.cjs', '*.cts'],
58
+ ...cjsConfig,
59
+ },
60
+ ],
44
61
  }
package/presets/react.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const { testFileGlobs } = require('./utils/testUtil')
3
+ const { testFileGlobs } = require('./utils/testUtil.js')
4
4
 
5
5
  /** @type {import('eslint').Linter.Config} */
6
6
  module.exports = {