@foray1010/eslint-config 7.3.3 → 7.4.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.
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
+ ## [7.4.0](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@7.3.4...@foray1010/eslint-config@7.4.0) (2022-09-22)
7
+
8
+ ### Features
9
+
10
+ - **eslint-config:** explicitly import node.js only built-in modules ([969c1d2](https://github.com/foray1010/common-presets/commit/969c1d299a3d092eaa373ba9ceca4d7616076cfc))
11
+
12
+ ### Bug Fixes
13
+
14
+ - **deps:** update dependency eslint-plugin-jest to v27 ([6534504](https://github.com/foray1010/common-presets/commit/65345046f6300b583d7a7b614ed4285486917e4d))
15
+
16
+ ## [7.3.4](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@7.3.3...@foray1010/eslint-config@7.3.4) (2022-08-26)
17
+
18
+ ### Bug Fixes
19
+
20
+ - **eslint-config:** allow {} type ([930a2fa](https://github.com/foray1010/common-presets/commit/930a2fa03fe5f14435890226266c8b103baa8221))
21
+
6
22
  ## [7.3.3](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@7.3.2...@foray1010/eslint-config@7.3.3) (2022-08-24)
7
23
 
8
24
  **Note:** Version bump only for package @foray1010/eslint-config
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.3.3",
4
+ "version": "7.4.0",
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": {
@@ -23,7 +23,7 @@
23
23
  "type:check": "tsc"
24
24
  },
25
25
  "dependencies": {
26
- "@foray1010/common-presets-utils": "^5.0.2",
26
+ "@foray1010/common-presets-utils": "^5.0.3",
27
27
  "@typescript-eslint/eslint-plugin": "^5.13.0",
28
28
  "@typescript-eslint/parser": "^5.13.0",
29
29
  "confusing-browser-globals": "^1.0.10",
@@ -31,20 +31,20 @@
31
31
  "eslint-plugin-compat": "^4.0.0",
32
32
  "eslint-plugin-eslint-comments": "^3.2.0",
33
33
  "eslint-plugin-import": "^2.22.1",
34
- "eslint-plugin-jest": "^26.0.0",
34
+ "eslint-plugin-jest": "^27.0.0",
35
35
  "eslint-plugin-jest-dom": "^4.0.0",
36
36
  "eslint-plugin-jsdoc": "^39.0.0",
37
37
  "eslint-plugin-n": "^15.2.2",
38
38
  "eslint-plugin-prettier": "^4.0.0",
39
39
  "eslint-plugin-react": "^7.23.2",
40
40
  "eslint-plugin-react-hooks": "^4.2.0",
41
- "eslint-plugin-simple-import-sort": "^7.0.0",
41
+ "eslint-plugin-simple-import-sort": "^8.0.0",
42
42
  "eslint-plugin-testing-library": "^5.3.1"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/confusing-browser-globals": "1.0.0",
46
46
  "@types/eslint": "8.4.6",
47
- "typescript": "4.7.4"
47
+ "typescript": "4.8.3"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "eslint": "^8.0.0",
@@ -56,5 +56,5 @@
56
56
  "publishConfig": {
57
57
  "access": "public"
58
58
  },
59
- "gitHead": "8f4681aea3421297bffa13e0bbbf7f6dba20ca70"
59
+ "gitHead": "73bd0116236620e7171c9e7c5442afa50bcfbed7"
60
60
  }
package/presets/base.js CHANGED
@@ -5,13 +5,28 @@ const { hasDep, isESM } = require('@foray1010/common-presets-utils')
5
5
 
6
6
  const { testFileGlobs } = require('./utils/testUtil')
7
7
 
8
- /** @type {import('eslint').Linter.RulesRecord} */
9
- const esmRules = {
10
- 'import/extensions': [
11
- 'error',
12
- // https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_mandatory_file_extensions
13
- 'always',
14
- ],
8
+ /** @type {import('eslint').Linter.BaseConfig} */
9
+ const cjsConfig = {
10
+ parserOptions: {
11
+ sourceType: 'script',
12
+ },
13
+ env: {
14
+ commonjs: true,
15
+ },
16
+ }
17
+
18
+ /** @type {import('eslint').Linter.BaseConfig} */
19
+ const esmConfigForJs = {
20
+ parserOptions: {
21
+ sourceType: 'module',
22
+ },
23
+ rules: {
24
+ 'import/extensions': [
25
+ 'error',
26
+ // https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_mandatory_file_extensions
27
+ 'always',
28
+ ],
29
+ },
15
30
  }
16
31
 
17
32
  /** @type {import('eslint').Linter.Config} */
@@ -26,7 +41,6 @@ module.exports = {
26
41
  ],
27
42
  parserOptions: {
28
43
  ecmaVersion: 2020,
29
- sourceType: 'script',
30
44
  },
31
45
  plugins: [
32
46
  'eslint-plugin-eslint-comments',
@@ -36,7 +50,11 @@ module.exports = {
36
50
  'eslint-plugin-simple-import-sort',
37
51
  ],
38
52
  env: {
39
- es6: true,
53
+ /* Not using `node` to explicitly import node.js only built-in modules, e.g.
54
+ * import { Buffer } from 'node:buffer'
55
+ * import process from 'node:process'
56
+ */
57
+ 'shared-node-browser': true,
40
58
  },
41
59
  rules: {
42
60
  // allow disable eslint rules for whole file without re-enable it in the end of the file
@@ -100,23 +118,15 @@ module.exports = {
100
118
  overrides: [
101
119
  {
102
120
  files: ['*.js'],
103
- parserOptions: {
104
- sourceType: isESM() ? 'module' : 'script',
105
- },
106
- rules: isESM() ? esmRules : {},
121
+ ...(isESM() ? esmConfigForJs : cjsConfig),
107
122
  },
108
123
  {
109
124
  files: ['*.cjs'],
110
- parserOptions: {
111
- sourceType: 'script',
112
- },
125
+ ...cjsConfig,
113
126
  },
114
127
  {
115
128
  files: ['*.mjs'],
116
- parserOptions: {
117
- sourceType: 'module',
118
- },
119
- rules: esmRules,
129
+ ...esmConfigForJs,
120
130
  },
121
131
  {
122
132
  files: testFileGlobs,
@@ -149,6 +159,17 @@ module.exports = {
149
159
  },
150
160
  plugins: ['@typescript-eslint/eslint-plugin'],
151
161
  rules: {
162
+ // extend existing rule
163
+ '@typescript-eslint/ban-types': [
164
+ 'error',
165
+ {
166
+ types: {
167
+ // TypeScript team suggests to use `<T extends {}>` https://devblogs.microsoft.com/typescript/announcing-typescript-4-8/#unconstrained-generics-no-longer-assignable-to
168
+ '{}': false,
169
+ },
170
+ extendDefaults: true,
171
+ },
172
+ ],
152
173
  // separate type imports which allow certain optimizations within compilers
153
174
  '@typescript-eslint/consistent-type-imports': [
154
175
  'error',
@@ -9,6 +9,10 @@ module.exports = {
9
9
  env: {
10
10
  browser: true,
11
11
  },
12
+ globals: {
13
+ // keep it until webpack has an official way to define env: https://github.com/webpack/webpack/issues/15833
14
+ process: 'readonly',
15
+ },
12
16
  rules: {
13
17
  'no-restricted-globals': ['error', ...restrictedGlobals],
14
18
  },
package/presets/node.js CHANGED
@@ -3,9 +3,6 @@
3
3
  /** @type {import('eslint').Linter.Config} */
4
4
  module.exports = {
5
5
  plugins: ['eslint-plugin-n'],
6
- env: {
7
- node: true,
8
- },
9
6
  rules: {
10
7
  // disallow deprecated node APIs
11
8
  'n/no-deprecated-api': 'error',