@foray1010/eslint-config 7.3.4 → 7.4.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
+ ## [7.4.1](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@7.4.0...@foray1010/eslint-config@7.4.1) (2022-09-23)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **eslint-config:** allow es2020 globals ([f5d8e61](https://github.com/foray1010/common-presets/commit/f5d8e61a9f22572d3523e833671a1c9b24dff568))
11
+
12
+ ## [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)
13
+
14
+ ### Features
15
+
16
+ - **eslint-config:** explicitly import node.js only built-in modules ([969c1d2](https://github.com/foray1010/common-presets/commit/969c1d299a3d092eaa373ba9ceca4d7616076cfc))
17
+
18
+ ### Bug Fixes
19
+
20
+ - **deps:** update dependency eslint-plugin-jest to v27 ([6534504](https://github.com/foray1010/common-presets/commit/65345046f6300b583d7a7b614ed4285486917e4d))
21
+
6
22
  ## [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)
7
23
 
8
24
  ### Bug Fixes
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.4",
4
+ "version": "7.4.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": {
@@ -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": "8cdf88d4e40b34322f8777bff70a5116c66aef0e"
59
+ "gitHead": "df95064c3e2e91de237c7893938a28bedb1e98dc"
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,13 @@ module.exports = {
36
50
  'eslint-plugin-simple-import-sort',
37
51
  ],
38
52
  env: {
39
- es6: true,
53
+ // should align with parserOptions.ecmaVersion
54
+ es2020: true,
55
+ /* Not using `node` to explicitly import node.js only built-in modules, e.g.
56
+ * import { Buffer } from 'node:buffer'
57
+ * import process from 'node:process'
58
+ */
59
+ 'shared-node-browser': true,
40
60
  },
41
61
  rules: {
42
62
  // allow disable eslint rules for whole file without re-enable it in the end of the file
@@ -100,23 +120,15 @@ module.exports = {
100
120
  overrides: [
101
121
  {
102
122
  files: ['*.js'],
103
- parserOptions: {
104
- sourceType: isESM() ? 'module' : 'script',
105
- },
106
- rules: isESM() ? esmRules : {},
123
+ ...(isESM() ? esmConfigForJs : cjsConfig),
107
124
  },
108
125
  {
109
126
  files: ['*.cjs'],
110
- parserOptions: {
111
- sourceType: 'script',
112
- },
127
+ ...cjsConfig,
113
128
  },
114
129
  {
115
130
  files: ['*.mjs'],
116
- parserOptions: {
117
- sourceType: 'module',
118
- },
119
- rules: esmRules,
131
+ ...esmConfigForJs,
120
132
  },
121
133
  {
122
134
  files: testFileGlobs,
@@ -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',