Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chadly committed Mar 23, 2020
0 parents commit 0eef382
Show file tree
Hide file tree
Showing 11 changed files with 1,825 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2016 Archon Information Systems, LLC.

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.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Runly ESLint Configuration

> Shareable ESLint configuration used in Runly client applications
[Read more](http://eslint.org/docs/developer-guide/shareable-configs) in general about how eslint shareable configurations work.

## Install

```
yarn add @runly/eslint-config --dev
```

## Usage

Add to your `.eslintrc.js`:

```js
module.exports = {
extends: [
"@runly"
]
};
```

The testing rules are not included by default and can be included via:

```js
module.exports = {
extends: [
"@runly/eslint-config/jest"
]
};
```

## Contributing

When adding rules or plugins, put them into the correct js file based on category (e.g. add react rules to `react.js`). Make sure to add a small comment explaining what the rule does (feel free to be as snarky as possible) along with a link to the rule documentation.

### Versioning

When making changes, be sure to [follow semantic versioning](http://semver.org/).

* Any new _error_ rules you add should be a major version bump.
* Any more restrictive changes to existing _error_ rules should be a major version bump.
* Any easing of restrictions to existing _error_ rules can be a minor version bump.
* Any new fixable _error_ rules can be a minor version bump.
* Any addition or changes to _warning_ rules should be a minor version bump.
* Any bug fixes should be a patch version bump.
* Anytime you realize you broke one of these rules, fixing it should be a patch version bump.
77 changes: 77 additions & 0 deletions imports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
module.exports = {
plugins: [
"import"
],
settings: {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".json", ".mjs"]
}
}
},
rules: {
// don't import from files that don't exist
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
"import/no-unresolved": "error",

// don't import stuff you don't explicitly depend on
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
"import/no-extraneous-dependencies": "error",

// don't import non-existent stuff out of a file
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md
"import/named": "error",

// don't dereference non-existent stuff out of a file
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md
"import/namespace": "error",

// don't import a default if no default is exported
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md
"import/default": "error",

// no funny business with exports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md
"import/export": "error",

// don't do weird stuff with absolute file paths
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md
"import/no-absolute-path": "error",

// don't dynamically require stuff
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md
"import/no-dynamic-require": "error",

// don't do weird stuff with mutating exports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md
"import/no-mutable-exports": "error",

// just say no to require
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
"import/no-commonjs": "error",

// just say no to AMD
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md
"import/no-amd": "error",

// first things first -> imports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md
"import/first": "error",

// just import a module once
// http://eslint.org/docs/rules/no-duplicate-imports
"no-duplicate-imports": "error",

// we don't need no stinkin` extensions, except ya know, sometimes
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
"import/extensions": ["error", "always", { "js": "never", "jsx": "never", "json": "never", "mjs": "never" }],

// put some damn space between your code and your imports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md
"import/newline-after-import": "error",

// just import default without extra ceremony
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md
"import/no-named-default": "error"
}
};
10 changes: 10 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
parser: "babel-eslint",
extends: [
"eslint:recommended",
"@runly/eslint-config/imports",
"@runly/eslint-config/style",
"@runly/eslint-config/react",
"prettier" // this should always be last
]
};
14 changes: 14 additions & 0 deletions jest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// https://github.com/jest-community/eslint-plugin-jest

module.exports = {
env: {
jest: true
},
plugins: [
"jest"
],
extends: [
"plugin:jest/recommended",
"plugin:jest/style"
]
};
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@runly/eslint-config",
"description": "Shareable ESLint configuration used in Runly client applications",
"main": "index.js",
"version": "1.0.0",
"repository": {
"type": "git",
"url": "https://github.com/runlyio/eslint-config.git"
},
"author": "Runly LLC",
"license": "MIT",
"keywords": [
"eslint",
"eslintconfig",
"runly"
],
"dependencies": {
"babel-eslint": "^10.1.0",
"eslint-config-prettier": "6.10.1",
"eslint-plugin-filenames": "^1.3.2",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jest": "^23.8.2",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-react": "^7.19.0",
"eslint-plugin-react-functional-set-state": "^1.2.1",
"eslint-plugin-react-hooks": "^2.5.1"
},
"peerDependencies": {
"eslint": "6.x"
}
}
95 changes: 95 additions & 0 deletions react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
module.exports = {
extends: [
"plugin:react/recommended"
],
plugins: [
"react",
"react-functional-set-state",
"react-hooks",
"jsx-a11y"
],
rules: {
// we don't use propTypes
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md
"react/prop-types": ["off"],

// this shit just don't work and doesn't really help IMO anyway...
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md
"react/no-unescaped-entities": ["off"],

// ERRORS

// don't reference this.props or this.state from within a setState call,
// what are you some kind of maniac?!?
// https://medium.freecodecamp.org/functional-setstate-is-the-future-of-react-374f30401b6b
"react-functional-set-state/no-this-state-props": ["error"],

// don't go creating all kinds of anonymous functions in render methods,
// unless they're refs
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
"react/jsx-no-bind": ["error", { "ignoreRefs": true }],

// don't write components like a n00b
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
"react/prefer-stateless-function": ["error"],

// don't write components like a n00b
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
"react/prefer-es6-class": ["error", "always"],

// put stuff in order
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
"react/sort-comp": ["error"],

// make missing collection key compile error rather than runtime error
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
"react/jsx-key": ["error"],

// don't use bools like a n00b
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
"react/jsx-boolean-value": ["error", "never"],

// don't waste half a day debugging because you decided to use an array index to key a list
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
"react/no-array-index-key": ["error"],

// don't write invalid aria props
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md
"jsx-a11y/aria-props": ["error"],

// don't write invalid aria proptypes
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md
"jsx-a11y/aria-proptypes": ["error"],

// don't write invalid aria roles
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md
"jsx-a11y/aria-role": ["error"],

// don't put aria on shit that don't want it
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md
"jsx-a11y/aria-unsupported-elements": ["error"],

// you best be putting aria props on 'dem aria roles
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md
"jsx-a11y/role-has-required-aria-props": ["error"],

// don't put invalid aria props on aria roles
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md
"jsx-a11y/role-supports-aria-props": ["error"],

// =======================================================================================
// WARNINGS

// make sure those keyboard people are happy
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md
"jsx-a11y/mouse-events-have-key-events": ["warn"],

// make sure those keyboard people are happy
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md
"jsx-a11y/click-events-have-key-events": ["warn"],

// https://reactjs.org/docs/hooks-rules.html
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps":"error"
}
};
41 changes: 41 additions & 0 deletions style.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module.exports = {
plugins: [
"filenames",
"prettier"
],
rules: {
// ERRORS

// No more bikeshedding on style; just use prettier
// https://github.com/not-an-aardvark/eslint-plugin-prettier
"prettier/prettier": ["error", { useTabs: true, trailingComma: "none", arrowParens: "avoid" }],

// enforce lowercase kebab case for filenames
// we have had issues in the past with case sensitivity & module resolution
// https://github.com/selaux/eslint-plugin-filenames
"filenames/match-regex": ["error", "^[a-z0-9\-\.]+$"],

// don't concatenate strings like a n00b
// http://eslint.org/docs/rules/prefer-template
"prefer-template": ["error"],

// put a space after the comment slashes
// http://eslint.org/docs/rules/spaced-comment
"spaced-comment": ["error", "always"],

// force curly braces for control-flow blocks unless it is single line
// http://eslint.org/docs/rules/curly
"curly": ["error", "multi-line", "consistent"],

// =======================================================================================
// WARNINGS

// don't write a whole application in one single js file (default 301 lines is too big)
// http://eslint.org/docs/rules/max-lines
"max-lines": ["warn"],

// don't make ridiculous functions that take billions upon billions of arguments
// http://eslint.org/docs/rules/max-params
"max-params": ["warn", { max: 4 }]
}
};
Loading

0 comments on commit 0eef382

Please sign in to comment.