@automattic/eslint-config-target-es 2.1.0 → 2.2.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 +18 -0
- package/README.md +17 -15
- package/package.json +25 -11
- package/src/flatconfig/all.js +6 -0
- package/src/flatconfig/base.js +21 -0
- package/src/flatconfig/builtins.js +6 -0
- package/src/flatconfig/language.js +6 -0
- package/src/funcs.js +7 -7
- package/src/needsCheck.js +4 -4
- package/src/rulesMap.js +28 -1
- /package/src/{configs → eslintrc}/all.js +0 -0
- /package/src/{configs → eslintrc}/base.js +0 -0
- /package/src/{configs → eslintrc}/builtins.js +0 -0
- /package/src/{configs → eslintrc}/language.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.2.1] - 2024-12-04
|
|
9
|
+
### Added
|
|
10
|
+
- Enable test coverage. [#39961]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- Updated package dependencies. [#39176] [#39177] [#39302] [#39594] [#39707] [#39898] [#39999] [#40288] [#40363]
|
|
14
|
+
|
|
15
|
+
## [2.2.0] - 2024-08-29
|
|
16
|
+
### Added
|
|
17
|
+
- Add mapping for `es-x/no-regexp-duplicate-named-capturing-groups`. [#39005]
|
|
18
|
+
- Support eslint flat configs (`eslint.config.js`). [#37855]
|
|
19
|
+
- Updated `eslint-plugin-es-x` adds additional rules: `es-x/no-arraybuffer-prototype-transfer`, `es-x/no-object-map-groupby`, `es-x/no-promise-withresolvers`, `es-x/no-resizable-and-growable-arraybuffers`, `es-x/no-set-prototype-difference`, `es-x/no-set-prototype-intersection`, `es-x/no-set-prototype-isdisjointfrom`, `es-x/no-set-prototype-issubsetof`, `es-x/no-set-prototype-issupersetof`, `es-x/no-set-prototype-symmetricdifference`, and `es-x/no-set-prototype-union`. [#37830]
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- Updated package dependencies. [#35608] [#36095] [#36325] [#36585] [#36760] [#37147] [#37379] [#37669] [#37828] [#37830] [#38132] [#38662] [#39002]
|
|
23
|
+
|
|
8
24
|
## [2.1.0] - 2024-02-07
|
|
9
25
|
### Added
|
|
10
26
|
- All versions indicated by browserslist are now checked, not just the lowest. Added `getAllBrowsers` function to support this. [#31658]
|
|
@@ -59,6 +75,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
59
75
|
### Added
|
|
60
76
|
- Initial release.
|
|
61
77
|
|
|
78
|
+
[2.2.1]: https://github.com/Automattic/eslint-config-target-es/compare/2.2.0...2.2.1
|
|
79
|
+
[2.2.0]: https://github.com/Automattic/eslint-config-target-es/compare/2.1.0...2.2.0
|
|
62
80
|
[2.1.0]: https://github.com/Automattic/eslint-config-target-es/compare/2.0.0...2.1.0
|
|
63
81
|
[2.0.0]: https://github.com/Automattic/eslint-config-target-es/compare/1.0.6...2.0.0
|
|
64
82
|
[1.0.6]: https://github.com/Automattic/eslint-config-target-es/compare/1.0.5...1.0.6
|
package/README.md
CHANGED
|
@@ -14,30 +14,30 @@ npm install --save-dev eslint eslint-plugin-es-x @automattic/eslint-config-targe
|
|
|
14
14
|
|
|
15
15
|
First, you'll probably want to set up a [browserslist] configuration.
|
|
16
16
|
|
|
17
|
-
Then you can use this like any other sharable config in your `.eslintrc.*` file. Three configurations are offered.
|
|
17
|
+
Then you can use this like any other sharable config in your `eslint.config.js` or `.eslintrc.*` file. Three configurations are offered.
|
|
18
18
|
|
|
19
|
-
To check only for language features, such as nullish coalescing,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
extends: [ '@automattic/eslint-config-target-es/language' ],
|
|
23
|
-
}
|
|
24
|
-
```
|
|
19
|
+
* To check only for language features, such as nullish coalescing, use the 'language' config.
|
|
20
|
+
* To check only for builtins, such as Promise, WeakRef, and various features of RegExp, use the 'builtins' config.
|
|
21
|
+
* To check both, use the 'all' config.
|
|
25
22
|
|
|
26
|
-
|
|
23
|
+
For `eslint.config.js`, that might look like this:
|
|
27
24
|
```js
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
import eslintConfigTargetEs from '@automattic/eslint-config-target-es/flat/language';
|
|
26
|
+
|
|
27
|
+
export default [
|
|
28
|
+
eslintConfigTargetEs,
|
|
29
|
+
// etc
|
|
30
|
+
];
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
while for eslintrc you'd do like
|
|
34
34
|
```js
|
|
35
35
|
{
|
|
36
|
-
extends: [ '@automattic/eslint-config-target-es/
|
|
36
|
+
extends: [ '@automattic/eslint-config-target-es/rc/language' ],
|
|
37
37
|
}
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
For
|
|
40
|
+
For backwards compatibility, the eslintrc configs may also be accessed without the `/rc/` path component (e.g. as `@automattic/eslint-config-target-es/language`), and `@automattic/eslint-config-target-es` is equivalent to `@automattic/eslint-config-target-es/rc/all`.
|
|
41
41
|
|
|
42
42
|
### Checking built files
|
|
43
43
|
|
|
@@ -45,7 +45,7 @@ If you want to check your built files to make sure you didn't omit transpiling a
|
|
|
45
45
|
```js
|
|
46
46
|
module.exports = {
|
|
47
47
|
root: true,
|
|
48
|
-
extends: [ '@automattic/eslint-config-target-es/language' ],
|
|
48
|
+
extends: [ '@automattic/eslint-config-target-es/rc/language' ],
|
|
49
49
|
env: {
|
|
50
50
|
// Whatever environments you need.
|
|
51
51
|
},
|
|
@@ -57,6 +57,8 @@ eslint --no-eslintrc --no-inline-config --config validate-es.config.js --no-igno
|
|
|
57
57
|
```
|
|
58
58
|
to avoid your standard eslintrc and eslintignore and to avoid errors from any inline directives.
|
|
59
59
|
|
|
60
|
+
Something similar can be done for flat config.
|
|
61
|
+
|
|
60
62
|
### Advanced usage
|
|
61
63
|
|
|
62
64
|
You can import or require `@automattic/eslint-config-target-es/functions` to gain access to some functions that can be used to build your own configuration.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/eslint-config-target-es",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "ESLint sharable config to activate eslint-plugin-es checks based on browserslist targets.",
|
|
5
5
|
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/eslint-config-target-es/README.md#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -14,29 +14,43 @@
|
|
|
14
14
|
"license": "GPL-2.0-or-later",
|
|
15
15
|
"author": "Automattic",
|
|
16
16
|
"scripts": {
|
|
17
|
-
"test": "jest tests"
|
|
17
|
+
"test": "jest --config=tests/jest.config.cjs",
|
|
18
|
+
"test-coverage": "pnpm run test --coverage"
|
|
18
19
|
},
|
|
19
20
|
"dependencies": {
|
|
20
|
-
"@mdn/browser-compat-data": "5.
|
|
21
|
+
"@mdn/browser-compat-data": "5.5.49",
|
|
21
22
|
"browserslist": "^4.17.6",
|
|
22
23
|
"debug": "^4.3.2",
|
|
23
24
|
"semver": "^7.3.5"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
|
-
"@wordpress/browserslist-config": "
|
|
27
|
-
"eslint": "8.
|
|
28
|
-
"eslint-plugin-es-x": "7.
|
|
27
|
+
"@wordpress/browserslist-config": "6.13.0",
|
|
28
|
+
"eslint": "8.57.1",
|
|
29
|
+
"eslint-plugin-es-x": "7.8.0",
|
|
30
|
+
"globals": "15.4.0",
|
|
29
31
|
"jest": "29.7.0"
|
|
30
32
|
},
|
|
31
33
|
"peerDependencies": {
|
|
32
34
|
"eslint": ">=4.19.1",
|
|
33
|
-
"eslint-plugin-es-x": "^7.
|
|
35
|
+
"eslint-plugin-es-x": "^7.6.0",
|
|
36
|
+
"globals": ">=15.4.0"
|
|
37
|
+
},
|
|
38
|
+
"peerDependenciesMeta": {
|
|
39
|
+
"globals": {
|
|
40
|
+
"optional": true
|
|
41
|
+
}
|
|
34
42
|
},
|
|
35
43
|
"exports": {
|
|
36
|
-
".": "./src/
|
|
37
|
-
"./language": "./src/
|
|
38
|
-
"./builtins": "./src/
|
|
39
|
-
"./all": "./src/
|
|
44
|
+
".": "./src/eslintrc/all.js",
|
|
45
|
+
"./language": "./src/eslintrc/language.js",
|
|
46
|
+
"./builtins": "./src/eslintrc/builtins.js",
|
|
47
|
+
"./all": "./src/eslintrc/all.js",
|
|
48
|
+
"./rc/language": "./src/eslintrc/language.js",
|
|
49
|
+
"./rc/builtins": "./src/eslintrc/builtins.js",
|
|
50
|
+
"./rc/all": "./src/eslintrc/all.js",
|
|
51
|
+
"./flat/language": "./src/flatconfig/language.js",
|
|
52
|
+
"./flat/builtins": "./src/flatconfig/builtins.js",
|
|
53
|
+
"./flat/all": "./src/flatconfig/all.js",
|
|
40
54
|
"./functions": "./src/funcs.js"
|
|
41
55
|
}
|
|
42
56
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const esx = require( 'eslint-plugin-es-x' );
|
|
2
|
+
|
|
3
|
+
const flatBase = {
|
|
4
|
+
plugins: {
|
|
5
|
+
'es-x': esx,
|
|
6
|
+
},
|
|
7
|
+
languageOptions: {
|
|
8
|
+
ecmaVersion: 2022,
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
const globals = require( 'globals' );
|
|
14
|
+
if ( globals?.es2022 ) {
|
|
15
|
+
flatBase.languageOptions.globals = globals.es2022;
|
|
16
|
+
}
|
|
17
|
+
} catch ( e ) {
|
|
18
|
+
// `globals` is optional.
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = flatBase;
|
package/src/funcs.js
CHANGED
|
@@ -10,9 +10,9 @@ const warn = debug( '@automattic/eslint-config-target-es:warn' );
|
|
|
10
10
|
/**
|
|
11
11
|
* Get the list of supported browsers.
|
|
12
12
|
*
|
|
13
|
-
* @param {object} options
|
|
13
|
+
* @param {object} options - Options.
|
|
14
14
|
* @param {string} options.query - Browserslist query.
|
|
15
|
-
* @
|
|
15
|
+
* @return {object} Browsers mapped to arrays of versions.
|
|
16
16
|
*/
|
|
17
17
|
function getAllBrowsers( options = {} ) {
|
|
18
18
|
const browsers = {};
|
|
@@ -42,9 +42,9 @@ function getAllBrowsers( options = {} ) {
|
|
|
42
42
|
* Get the list of supported browsers.
|
|
43
43
|
*
|
|
44
44
|
* @deprecated since 2.1.0. Use getAllBrowsers instead.
|
|
45
|
-
* @param {object} options
|
|
45
|
+
* @param {object} options - Options.
|
|
46
46
|
* @param {string} options.query - Browserslist query.
|
|
47
|
-
* @
|
|
47
|
+
* @return {object} Browsers mapped to minimum versions.
|
|
48
48
|
*/
|
|
49
49
|
function getBrowsers( options = {} ) {
|
|
50
50
|
warn( 'getBrowsers is deprecated. Use getAllBrowsers instead.' );
|
|
@@ -59,10 +59,10 @@ function getBrowsers( options = {} ) {
|
|
|
59
59
|
/**
|
|
60
60
|
* Get the es-x rule configurations.
|
|
61
61
|
*
|
|
62
|
-
* @param {object}
|
|
62
|
+
* @param {object} options - Options.
|
|
63
63
|
* @param {boolean|null} options.builtins - If true, only rules with "javascript.builtins" paths are checked. If false, such rules are not checked. If null/undefined, all may be checked.
|
|
64
|
-
* @param {string}
|
|
65
|
-
* @
|
|
64
|
+
* @param {string} options.query - Browserslist query.
|
|
65
|
+
* @return {object} Rules configuration.
|
|
66
66
|
*/
|
|
67
67
|
function getRules( options = {} ) {
|
|
68
68
|
const browsers = getAllBrowsers( options );
|
package/src/needsCheck.js
CHANGED
|
@@ -9,11 +9,11 @@ const debuglog = debug( '@automattic/eslint-config-target-es:debug' );
|
|
|
9
9
|
/**
|
|
10
10
|
* Test if a rule needs to be checked.
|
|
11
11
|
*
|
|
12
|
-
* @param {string}
|
|
13
|
-
* @param {object}
|
|
14
|
-
* @param {object}
|
|
12
|
+
* @param {string} rule - Rule.
|
|
13
|
+
* @param {object} browsers - Browsers targeted.
|
|
14
|
+
* @param {object} options - Options.
|
|
15
15
|
* @param {boolean|null} options.builtins - If true, only rules with "javascript.builtins" paths are checked. If false, such rules are not checked. If null/undefined, all may be checked.
|
|
16
|
-
* @
|
|
16
|
+
* @return {boolean} Whether the rule needs to be checked.
|
|
17
17
|
*/
|
|
18
18
|
function needsCheck( rule, browsers, options = {} ) {
|
|
19
19
|
let paths = rulesMap[ rule ];
|
package/src/rulesMap.js
CHANGED
|
@@ -1,9 +1,36 @@
|
|
|
1
1
|
// Map of eslint-plugin-es-x rules to MDN compat-data paths.
|
|
2
2
|
// Values are either a path, an array of paths, true to always enable the rule, or false to always disable it.
|
|
3
3
|
module.exports = {
|
|
4
|
-
//
|
|
4
|
+
// ES2025
|
|
5
|
+
'no-regexp-duplicate-named-capturing-groups':
|
|
6
|
+
'javascript.regular_expressions.named_capturing_group.duplicate_named_capturing_groups',
|
|
7
|
+
|
|
8
|
+
// ES2024
|
|
9
|
+
'no-arraybuffer-prototype-transfer': 'javascript.builtins.ArrayBuffer.transfer',
|
|
5
10
|
'no-atomics-waitasync': 'javascript.builtins.Atomics.waitAsync',
|
|
11
|
+
'no-object-map-groupby': [
|
|
12
|
+
'javascript.builtins.Map.groupBy',
|
|
13
|
+
'javascript.builtins.Object.groupBy',
|
|
14
|
+
],
|
|
15
|
+
'no-promise-withresolvers': 'javascript.builtins.Promise.withResolvers',
|
|
6
16
|
'no-regexp-v-flag': 'javascript.builtins.RegExp.unicodeSets',
|
|
17
|
+
'no-resizable-and-growable-arraybuffers': [
|
|
18
|
+
'javascript.builtins.ArrayBuffer.ArrayBuffer.maxByteLength_option',
|
|
19
|
+
'javascript.builtins.ArrayBuffer.maxByteLength',
|
|
20
|
+
'javascript.builtins.ArrayBuffer.resizable',
|
|
21
|
+
'javascript.builtins.ArrayBuffer.resize',
|
|
22
|
+
'javascript.builtins.SharedArrayBuffer.SharedArrayBuffer.maxByteLength_option',
|
|
23
|
+
'javascript.builtins.SharedArrayBuffer.grow',
|
|
24
|
+
'javascript.builtins.SharedArrayBuffer.growable',
|
|
25
|
+
'javascript.builtins.SharedArrayBuffer.maxByteLength',
|
|
26
|
+
],
|
|
27
|
+
'no-set-prototype-difference': 'javascript.builtins.Set.difference',
|
|
28
|
+
'no-set-prototype-intersection': 'javascript.builtins.Set.intersection',
|
|
29
|
+
'no-set-prototype-isdisjointfrom': 'javascript.builtins.Set.isDisjointFrom',
|
|
30
|
+
'no-set-prototype-issubsetof': 'javascript.builtins.Set.isSubsetOf',
|
|
31
|
+
'no-set-prototype-issupersetof': 'javascript.builtins.Set.isSupersetOf',
|
|
32
|
+
'no-set-prototype-symmetricdifference': 'javascript.builtins.Set.symmetricDifference',
|
|
33
|
+
'no-set-prototype-union': 'javascript.builtins.Set.union',
|
|
7
34
|
'no-string-prototype-iswellformed-towellformed': [
|
|
8
35
|
'javascript.builtins.String.isWellFormed',
|
|
9
36
|
'javascript.builtins.String.toWellFormed',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|