Skip to content

Commit

Permalink
add a basic mocha configuration (#85)
Browse files Browse the repository at this point in the history
* add a basic mocha configuration

* Update validate.test.js
  • Loading branch information
ktalebian authored Jun 12, 2020
1 parent aa6cce6 commit 41e19c3
Show file tree
Hide file tree
Showing 13 changed files with 1,976 additions and 77 deletions.
7 changes: 7 additions & 0 deletions packages/eslint-config-twilio-mocha/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "twilio",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module"
}
}
69 changes: 69 additions & 0 deletions packages/eslint-config-twilio-mocha/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# eslint-config-twilio-mocha

[![Version](https://img.shields.io/npm/v/eslint-config-twilio-mocha.svg?style=square)](https://www.npmjs.com/package/eslint-config-twilio-mocha)
[![Downloads](https://img.shields.io/npm/dt/eslint-config-twilio-mocha.svg?style=square)](https://www.npmjs.com/package/eslint-config-twilio-mocha)
[![License](https://img.shields.io/npm/l/eslint-config-twilio.svg?style=square)](../../LICENSE)

Twilio's approach to Mocha/Chai styling.

## Plugins and Extensions

This config includes the following plugins and extensions:

- [`eslint-plugin-chai-friendly`](https://www.npmjs.com/package/eslint-plugin-chai-friendly)

## Installation

```bash
$ npm install eslint eslint-config-twilio-mocha --save-dev
```

## Usage

Add the ESLint config to either your `package.json` or your `.eslintrc`:

### package.json

```json
{
"name": "my-project",
"eslintConfig": {
"extends": [
"twilio-mocha"
]
}
}
```

### .eslintrc

```json
{
"extends": [
"twilio-mocha"
]
}
```

Then add the following two scripts for running and fixing your codebase:

```json
{
"scripts": {
"lint": "eslint --ext js --ext jsx src/ test/",
"lint:fix": "npm run lint -- --fix"
}
}
```

### .prettier.js

If you want to allow your IDE to auto-format your code as you save it, then create a `.prettierrc.js` and add:

```js
const baseConfig = require('./node_modules/eslint-config-twilio/rules/prettier');

module.exports = {
...baseConfig,
};
```
7 changes: 7 additions & 0 deletions packages/eslint-config-twilio-mocha/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const overrides = require('./overrides');

module.exports = {
extends: ['twilio'],
plugins: ['chai-friendly'],
overrides: [overrides],
};
12 changes: 12 additions & 0 deletions packages/eslint-config-twilio-mocha/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const base = require('./../../jest.base');
const pkg = require('./package');

module.exports = {
...base,
name: pkg.name,
displayName: pkg.name,
rootDir: '../..',
testMatch: [
`<rootDir>/packages/${pkg.name}/test/**/*.test.js`
],
};
7 changes: 7 additions & 0 deletions packages/eslint-config-twilio-mocha/overrides/chai.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
files: ['*.spec.js', '*.spec.jsx', '*.test.js', '*.test.jsx', '*.spec.ts', '*.spec.tsx', '*.test.ts', '*.test.tsx'],
rules: {
'no-unused-expressions': 'off',
'chai-friendly/no-unused-expressions': 'error',
},
};
5 changes: 5 additions & 0 deletions packages/eslint-config-twilio-mocha/overrides/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* eslint global-require: 0 */

module.exports = {
...require('./chai'),
};
Loading

0 comments on commit 41e19c3

Please sign in to comment.