Skip to content

Commit

Permalink
Merge pull request #2 from ColourboxDevelopment/update-rules
Browse files Browse the repository at this point in the history
Updates rules
  • Loading branch information
lars-bo-colourbox authored Dec 19, 2018
2 parents db32571 + b2353f8 commit 6f00522
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 18 deletions.
52 changes: 38 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ This rule enforces a consistent indentation style. 4 spaces.
### ```'react/jsx-indent-props': [2, 'first'],```
This option validates a specific indentation style for props.

### ```'react/jsx-boolean-value': 0,```

This rule enforces style for boolean attributes.

Disabled, because we want to allow a more explicit syntax like `<MyComponent bool={true} />` instead of having to write `<MyComponent bool />` for the same.

### ```'react/jsx-indent': [2, 4],```
This rule enforces a consistent indentation style in JSX. 4 spaces.

Expand All @@ -54,22 +60,25 @@ If a class method does not use this, it can sometimes be made into a static func

Disabled, makes difficult to use ```this``` in all methods of a class.

### ```'max-len': 0,```
Enforce a maximum line length

Disabled, sometimes we have long texts.

### ```'jsx-a11y/anchor-is-valid': 0,```

Enforce that ```a``` tags are used for open link and not ```onClick```, ```button``` should be used instead.

Disabled, some cases easyer to work with ```a```.

### ```'no-script-url': 0,```
### ```'max-len'```

Disallow Script URLs. Using javascript: URLs is considered by some as a form of eval.
```
'max-len': [
'error',
{
code: 120,
tabWidth: 4,
ignoreComments: true,
ignoreTrailingComments: true,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
},
],
```

Disabled, I like to use ```javascript:{}```.
Sets the max line length to 120. Read more about the options at [https://eslint.org/docs/rules/max-len](https://eslint.org/docs/rules/max-len).

### ```'jsx-a11y/click-events-have-key-events': 0,```

Expand All @@ -82,3 +91,18 @@ Disabled. We want to be able add onClick attributes without additional events.
Prevent usage of dangerous JSX properties.

Disabled. In some cases, we want to use it for editable content.

### ```'no-restricted-syntax': [ 'ForStatement' ]```

Disallows for loops. Full rule:

```
'no-restricted-syntax': [
'error',
'ForStatement',
'ForInStatement',
'ForOfStatement',
'LabeledStatement',
'WithStatement',
],
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-colourbox",
"version": "1.0.3",
"version": "1.0.4",
"description": "This package provides Colourbox's .eslintrc as an extensible shared config.",
"main": "index.js",
"scripts": {
Expand Down
25 changes: 22 additions & 3 deletions rules/colourbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,32 @@ module.exports = {
indent: ['error', 4],
'react/jsx-indent': [2, 4],
'react/jsx-indent-props': [2, 'first'],
'react/jsx-boolean-value': 0,
'import/no-unresolved': 0,
'class-methods-use-this': 0,
'max-len': 0,
'jsx-a11y/anchor-is-valid': 0,
'max-len': [
'error',
{
code: 120,
tabWidth: 4,
ignoreComments: true,
ignoreTrailingComments: true,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
},
],
'jsx-a11y/click-events-have-key-events': 0,
'no-script-url': 0,
'react/no-danger': 0,
'no-restricted-syntax': [
'error',
'ForStatement',
'ForInStatement',
'ForOfStatement',
'LabeledStatement',
'WithStatement',
],
},
plugins: [
'react',
Expand Down

0 comments on commit 6f00522

Please sign in to comment.