Skip to content

Commit 23cc6f4

Browse files
authored
Add CommonJS ESLint configuration (#267)
A new package has been added for CommonJS projects. Primarily this configuration will allow CommonJS globals such as `require`. The environment config generation script was updated to support this new package. This required changes to allow combining both `shared-node-browser` and `commonjs` globals in the same configuration.
1 parent 4ff88e8 commit 23cc6f4

File tree

11 files changed

+5840
-13
lines changed

11 files changed

+5840
-13
lines changed

packages/commonjs/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [Unreleased]
8+
9+
[Unreleased]: https://github.com/MetaMask/eslint-config/

packages/commonjs/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 MetaMask
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/commonjs/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# `@metamask/eslint-config-commonjs`
2+
3+
MetaMask's ESLint configuration for projects using CommonJS.
4+
5+
## Usage
6+
7+
```bash
8+
yarn add --dev \
9+
@metamask/eslint-config@^11.0.1 \
10+
@metamask/eslint-config-commonjs@^11.0.2 \
11+
eslint@^8.27.0 \
12+
eslint-config-prettier@^8.5.0 \
13+
eslint-plugin-import@^2.26.0 \
14+
eslint-plugin-jsdoc@^39.6.2 \
15+
eslint-plugin-prettier@^4.2.1 \
16+
prettier@^2.7.1
17+
```
18+
19+
The order in which you extend ESLint rules matters.
20+
The `@metamask/*` eslint configs should be added to the `extends` array _last_,
21+
with `@metamask/eslint-config` first, and `@metamask/eslint-config-*` in any
22+
order thereafter.
23+
24+
```js
25+
module.exports = {
26+
extends: [
27+
// This should be added last unless you know what you're doing.
28+
'@metamask/eslint-config',
29+
'@metamask/eslint-config-commonjs',
30+
],
31+
};
32+
```

packages/commonjs/jest.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const packageJson = require('./package.json');
2+
3+
module.exports = {
4+
displayName: packageJson.name,
5+
};

packages/commonjs/package.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "@metamask/eslint-config-commonjs",
3+
"version": "11.0.2",
4+
"description": "Shareable MetaMask ESLint config for CommonJS projects.",
5+
"homepage": "https://github.com/MetaMask/eslint-config#readme",
6+
"bugs": {
7+
"url": "https://github.com/MetaMask/eslint-config/issues"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/MetaMask/eslint-config.git"
12+
},
13+
"license": "MIT",
14+
"main": "src/index.js",
15+
"files": [
16+
"src/",
17+
"!src/**/*.test.js"
18+
],
19+
"scripts": {
20+
"lint:changelog": "auto-changelog validate",
21+
"publish": "npm publish",
22+
"test": "eslint ."
23+
},
24+
"devDependencies": {
25+
"@metamask/auto-changelog": "^3.0.0",
26+
"eslint": "^8.27.0",
27+
"eslint-config-prettier": "^8.5.0",
28+
"eslint-plugin-import": "^2.26.0",
29+
"eslint-plugin-jsdoc": "^39.6.2",
30+
"eslint-plugin-prettier": "^4.2.1",
31+
"prettier": "^2.7.1"
32+
},
33+
"peerDependencies": {
34+
"eslint": "^8.27.0",
35+
"eslint-config-prettier": "^8.5.0",
36+
"eslint-plugin-import": "^2.26.0",
37+
"eslint-plugin-jsdoc": "^39.6.2",
38+
"eslint-plugin-prettier": "^4.2.1",
39+
"prettier": "^2.7.1"
40+
},
41+
"engines": {
42+
"node": ">=14.0.0"
43+
},
44+
"publishConfig": {
45+
"access": "public",
46+
"registry": "https://registry.npmjs.org/"
47+
}
48+
}

0 commit comments

Comments
 (0)