Skip to content
This repository has been archived by the owner on Jan 11, 2018. It is now read-only.

Commit

Permalink
feat(id-match): Allow CONSTANTS_NAMES. Add to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeysova committed Jan 8, 2018
1 parent f4edf3f commit d132881
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {

'arrow-parens': ['warn', 'always'],

'id-match': ['error', '^[a-z]([A-Za-z0-9]+){2,}$', {
'id-match': ['error', '^([a-z]([A-Za-z0-9]+){2,})|([A-Z][A-Z_0-9]+)$', {
properties: false,
onlyDeclarations: true,
}],
Expand Down
5 changes: 4 additions & 1 deletion example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ const example = {
four,
}

const getAsync = (data) => new Promise((res) => setTimeout(res, 1, data))
const CONSTANT_NAME = 123
const valueName = 1 + CONSTANT_NAME

const getAsync = (data) => new Promise((res) => setTimeout(res, 1 * valueName, data))

async function testAsync(list) {
for (const item of list) {
Expand Down
33 changes: 33 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,39 @@ const baz = example => {
}
```

## id-match: `error`, `^([a-z]([A-Za-z0-9]+){2,})|([A-Z][A-Z_0-9]+$`

```js
{
properties: false,
onlyDeclarations: true,
}
```

https://eslint.org/docs/rules/id-match

All identifiers should be camelCased and more that 2 symbols length.
Constants can be SCREAMING_UNDERSCORED

```js
// Good

let value = 1
const functionDummy = (argument) => {}
const CONSTANT_NAME = 123
class ExampleName {}
```


```js
// Bad
const Value = 1
const function_dummy = (MySuper_Argument) => {}
const constant_NAME = 1
class example_CLASS_name {}
```


## no-magic-numbers: `warn`

```js
Expand Down

0 comments on commit d132881

Please sign in to comment.