Skip to content

Commit

Permalink
feat(eslint): copy over eslint-config
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewLeedham committed Nov 18, 2019
1 parent 9fe2540 commit a4170c6
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 0 deletions.
59 changes: 59 additions & 0 deletions packages/xerox-eslint-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# @xerox/eslint-config

> ESLint shareable configuration for Xerox projects.
[![circleci status][circleci-badge]][circleci-link]
[![npm package][npm-badge]][npm-link]
[![license MIT][license-badge]][license-link]
[![commit style angular][commit-style-badge]][commit-style-link]
[![semantic-release][semantic-release-badge]][semantic-release-link]
[![Dependabot Status][dependabot-badge]][dependabot-link]

## Usage
1. Install this config and eslint as a `devDependency`:
```bash
yarn add eslint@5.12.1 @xerox/eslint-config --dev
# or
npm install eslint@5.12.1 @xerox/eslint-config --save-dev
```
2. Extend the base and any additional configs in your `.eslintrc` file (or just add an `eslintConfig` entry to your `package.json`):
```jsonc
{
"extends": [
"@xerox",
"@xerox/eslint-config/typescript", // Optional
"@xerox/eslint-config/react" // Optional
]
}
```

## Configurations
### xerox (base)
The base eslint configuration i.e. `"extends": ["@xerox"]` includes rules for Jest and Prettier, and some general preferences like linebreak-style.
### xerox/typescript
The typescript eslint configuration i.e. `"extends": ["@xerox/eslint-config/typescript"]` includes various TypeScript related rules, as well as swapping the default parser in order for eslint to work with TypeScript. You should call eslint using `--ext .js,.ts`, add `.jsx` and/or `.tsx` if necessary. This also adds a JSDoc requirement for only TypeScript files, `.js` and `test.{js,ts}` files are excluded, this allows you to progressively convert from TS to JS without having to add JSdoc to all the old JS source. These JSDoc rules are setup to mimick TSDoc, eslint-plugin-tsdoc doesn't yet exist, so this is a workaround, try to follow the example set out [here](https://github.com/Microsoft/tsdoc).
### xerox/react
The react eslint configuration i.e. `"extends": ["@xerox/eslint-config/react"]` enables jsx and includes the react reccomended settings from eslint-plugin-react, this sub-config needs some fleshing out.

---
[LICENSE][license-link] | [CHANGELOG][changelog-link]

[license-link]: ../../LICENSE
[changelog-link]: ../../CHANGELOG.md

[circleci-badge]: https://flat.badgen.net/circleci/github/xeroxinteractive/config/master
[circleci-link]: https://circleci.com/gh/xeroxinteractive/config/tree/master

[npm-badge]: https://flat.badgen.net/npm/v/@xerox/eslint-config?color=cyan
[npm-link]: https://www.npmjs.com/package/@xerox/eslint-config

[license-badge]: https://flat.badgen.net/badge/license/MIT

[commit-style-badge]: https://flat.badgen.net/badge/commit%20style/angular/purple
[commit-style-link]: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines

[semantic-release-badge]: https://flat.badgen.net/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80/semantic%20release/e10079
[semantic-release-link]: https://github.com/semantic-release/semantic-release

[dependabot-badge]: https://flat.badgen.net/dependabot/xeroxinteractive/config?icon=dependabot
[dependabot-link]: https://dependabot.com
26 changes: 26 additions & 0 deletions packages/xerox-eslint-config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
plugins: ['jest', 'prettier'],
extends: [
'plugin:jest/recommended',
'prettier',
'prettier/babel',
'prettier/standard',
],

env: {
node: true,
es6: true,
},

rules: {
'linebreak-style': ['error', 'unix'],
'arrow-parens': ['error', 'always'],
'prettier/prettier': 'error',
'prefer-const': [
'error',
{
destructuring: 'all',
},
],
},
};
35 changes: 35 additions & 0 deletions packages/xerox-eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@xerox/eslint-config",
"version": "1.10.3",
"description": "ESLint shareable configuration for Xerox projects.",
"main": "index.js",
"repository": "git@github.com:xeroxinteractive/config.git",
"author": "Andrew Leedham <andrew.leedham@xerox.com>",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"release": {
"extends": "../xerox-semantic-release-config/npm.js",
"commitPaths": [
"packages/xerox-eslint-config/*"
]
},
"devDependencies": {
"typescript": "^3.7.2"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^2.7.0",
"@typescript-eslint/parser": "^2.7.0",
"babel-eslint": "^10.0.1",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-jest": "^23.0.0",
"eslint-plugin-jsdoc": "^18.0.1",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.12.4"
},
"peerDependencies": {
"eslint": "~5",
"prettier": "~1"
}
}
13 changes: 13 additions & 0 deletions packages/xerox-eslint-config/react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
extends: ['plugin:react/recommended'],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
settings: {
react: {
version: 'detect',
},
},
};
13 changes: 13 additions & 0 deletions packages/xerox-eslint-config/typescript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
extends: ['plugin:react/recommended'],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
settings: {
react: {
version: 'detect',
},
},
};

0 comments on commit a4170c6

Please sign in to comment.