Skip to content

Commit

Permalink
Add CommonJS ESLint configuration (#267)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Gudahtt committed Dec 15, 2022
1 parent 4ff88e8 commit 23cc6f4
Show file tree
Hide file tree
Showing 11 changed files with 5,840 additions and 13 deletions.
9 changes: 9 additions & 0 deletions packages/commonjs/CHANGELOG.md
@@ -0,0 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

[Unreleased]: https://github.com/MetaMask/eslint-config/
21 changes: 21 additions & 0 deletions packages/commonjs/LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 MetaMask

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
32 changes: 32 additions & 0 deletions packages/commonjs/README.md
@@ -0,0 +1,32 @@
# `@metamask/eslint-config-commonjs`

MetaMask's ESLint configuration for projects using CommonJS.

## Usage

```bash
yarn add --dev \
@metamask/eslint-config@^11.0.1 \
@metamask/eslint-config-commonjs@^11.0.2 \
eslint@^8.27.0 \
eslint-config-prettier@^8.5.0 \
eslint-plugin-import@^2.26.0 \
eslint-plugin-jsdoc@^39.6.2 \
eslint-plugin-prettier@^4.2.1 \
prettier@^2.7.1
```

The order in which you extend ESLint rules matters.
The `@metamask/*` eslint configs should be added to the `extends` array _last_,
with `@metamask/eslint-config` first, and `@metamask/eslint-config-*` in any
order thereafter.

```js
module.exports = {
extends: [
// This should be added last unless you know what you're doing.
'@metamask/eslint-config',
'@metamask/eslint-config-commonjs',
],
};
```
5 changes: 5 additions & 0 deletions packages/commonjs/jest.config.js
@@ -0,0 +1,5 @@
const packageJson = require('./package.json');

module.exports = {
displayName: packageJson.name,
};
48 changes: 48 additions & 0 deletions packages/commonjs/package.json
@@ -0,0 +1,48 @@
{
"name": "@metamask/eslint-config-commonjs",
"version": "11.0.2",
"description": "Shareable MetaMask ESLint config for CommonJS projects.",
"homepage": "https://github.com/MetaMask/eslint-config#readme",
"bugs": {
"url": "https://github.com/MetaMask/eslint-config/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/MetaMask/eslint-config.git"
},
"license": "MIT",
"main": "src/index.js",
"files": [
"src/",
"!src/**/*.test.js"
],
"scripts": {
"lint:changelog": "auto-changelog validate",
"publish": "npm publish",
"test": "eslint ."
},
"devDependencies": {
"@metamask/auto-changelog": "^3.0.0",
"eslint": "^8.27.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsdoc": "^39.6.2",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1"
},
"peerDependencies": {
"eslint": "^8.27.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsdoc": "^39.6.2",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1"
},
"engines": {
"node": ">=14.0.0"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}

0 comments on commit 23cc6f4

Please sign in to comment.