Skip to content

Commit 3b13d34

Browse files
2.4.0 Deps, Monorepo
1 parent c4adeaf commit 3b13d34

File tree

15 files changed

+6335
-29
lines changed

15 files changed

+6335
-29
lines changed

.travis.yml

+20-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
language: node_js
2+
23
node_js:
34
- stable
5+
46
cache:
5-
directories:
6-
- node_modules
7-
before_deploy:
8-
- cd eslint-config-ringcentral
7+
yarn: true
8+
9+
addons:
10+
firefox: latest
11+
12+
before_install:
13+
- npm config set //registry.npmjs.org/:_authToken=${NPM_TOKEN}
14+
- yarn config set //registry.npmjs.org/:_authToken=${NPM_TOKEN}
15+
916
deploy:
10-
provider: npm
11-
12-
api_key: $NPM_TOKEN
17+
- provider: script
18+
script: yarn publish:release --canary --preid=$TRAVIS_BRANCH.$TRAVIS_JOB_NUMBER --dist-tag=$TRAVIS_BRANCH --yes
19+
skip_cleanup: true
20+
on:
21+
branch: master
22+
tags: false
23+
repo: ringcentral/ringcentral-javascript
24+
- provider: script
25+
script: yarn publish:release $TRAVIS_TAG --yes
1326
skip_cleanup: true
1427
on:
1528
tags: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": [
3+
"./src/index.js"
4+
]
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
RingCentral TypeScript
2+
======================
3+
4+
A stricter and TypeScript-enabled version of https://github.com/ringcentral/ringcentral-javascript.
5+
6+
## Installation
7+
8+
```bash
9+
$ npm install eslint eslint-config-ringcentral-typescript --save-dev
10+
```
11+
12+
Add this to `scripts` section of `package.json`:
13+
14+
```json
15+
{
16+
"scripts": {
17+
"lint": "eslint --cache --cache-location node_modules/.cache/eslint --fix ",
18+
"lint:all": "npm run lint 'src/**/*.ts' 'src/**/*.tsx'"
19+
}
20+
}
21+
```
22+
23+
You can add `--quiet` to suppress warnings, but that's not recommended.
24+
You can add `DEBUG=eslint:cli-engine` to output files that were linted.
25+
26+
:warning: Please note commas around globs: `'src/**/*.ts'`, this will prevent your OS to expand those globs.
27+
28+
Create `.eslintrc`:
29+
30+
```json
31+
{
32+
"extends": [
33+
"ringcentral-typescript"
34+
]
35+
}
36+
```
37+
38+
Create `.prettierrc` (optional):
39+
40+
```bash
41+
{
42+
"printWidth": 120
43+
}
44+
```
45+
46+
:warning: Keep in mind that anything you set in `.prettierrc` may be overridden by config specified in this repo.
47+
48+
You may use following trick in `.eslintrc` if you need to take control:
49+
50+
```js
51+
const prettierOptions = JSON.parse(require('fs').readFileSync('./.prettierrc').toString());
52+
53+
module.exports = {
54+
...
55+
rules: {
56+
'prettier/prettier': ['warn', Object.assign({}, prettierOptions)]
57+
}
58+
};
59+
```
60+
61+
Create a `.editorconfig` (optional):
62+
63+
```ini
64+
root = true
65+
66+
[*]
67+
indent_style = space
68+
end_of_line = lf
69+
charset = utf-8
70+
trim_trailing_whitespace = true
71+
insert_final_newline = false
72+
73+
[*.{js,jsx,ts,tsx}]
74+
indent_size = 4
75+
76+
[*.{css,sass,scss,yml,json}]
77+
indent_size = 2
78+
79+
[Makefile]
80+
indent_style = tab
81+
```
82+
83+
## Suggested use
84+
85+
Works best when used together with [Husky](https://github.com/typicode/husky) and [Lint Staged](https://github.com/okonet/lint-staged):
86+
87+
```bash
88+
$ npm install husky lint-staged --save-dev
89+
```
90+
91+
Add this to `scripts` section of `package.json`:
92+
93+
```json
94+
{
95+
"scripts": {
96+
"lint:staged": "lint-staged"
97+
}
98+
}
99+
```
100+
101+
Create `.huskyrc`:
102+
103+
```json
104+
{
105+
"hooks": {
106+
"pre-commit": "npm run lint:staged"
107+
}
108+
}
109+
```
110+
111+
Create `.lintstagedrc`:
112+
113+
```json
114+
{
115+
"*.{js,jsx,ts,tsx}": [
116+
"npm run lint --",
117+
"git add"
118+
]
119+
}
120+
```
121+
122+
## Integration with JetBrains products (Idea, WebStorm, PhpStorm)
123+
124+
Due to a bug you need to manually add extensions to registry: click `Help -> Find Action -> Registry`, search for
125+
`eslint.additional.file.extensions` and add `ts,tsx`, see https://youtrack.jetbrains.com/issue/WEB-29829#focus=streamItem-27-3182764-0-0.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "eslint-config-ringcentral-typescript",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "src/index.js",
6+
"scripts": {
7+
"test": "yarn lint 'src/**/*.{js*,ts*}'",
8+
"lint": "eslint --cache --cache-location node_modules/.cache/eslint --fix --quiet"
9+
},
10+
"dependencies": {
11+
"@typescript-eslint/eslint-plugin": "^2.11.0",
12+
"@typescript-eslint/parser": "^2.11.0",
13+
"babel-eslint": "^10.0.3",
14+
"eslint-config-prettier": "^6.7.0",
15+
"eslint-config-react-app": "^5.1.0",
16+
"eslint-config-ringcentral": "^1.0.0",
17+
"eslint-plugin-flowtype": "^4.5.2",
18+
"eslint-plugin-import": "^2.19.1",
19+
"eslint-plugin-jsx-a11y": "^6.2.3",
20+
"eslint-plugin-prettier": "^3.1.1",
21+
"eslint-plugin-react": "^7.17.0",
22+
"eslint-plugin-react-hooks": "^2.3.0",
23+
"eslint-plugin-ringcentral": "^1.0.0",
24+
"eslint-plugin-sonarjs": "^0.5.0",
25+
"prettier": "^1.19.1"
26+
},
27+
"peerDependencies": {
28+
"eslint": ">=6"
29+
},
30+
"devDependencies": {
31+
"eslint": "^6.7.2",
32+
"react": "^16.12.0",
33+
"typescript": "^3.7.3"
34+
},
35+
"repository": {
36+
"type": "git",
37+
"url": "git+https://github.com/ringcentral/ringcentral-typescript.git"
38+
},
39+
"author": "Kirill Konshin",
40+
"license": "MIT",
41+
"bugs": {
42+
"url": "https://github.com/ringcentral/ringcentral-typescript/issues"
43+
},
44+
"homepage": "https://github.com/ringcentral/ringcentral-typescript#readme"
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as React from 'react';
2+
3+
export const Foo = () => <div>Foo!</div>;
4+
Foo.displayName = 'Foo';
5+
6+
const bar = {foo: {baz: 'qux'}};
7+
const baz = bar?.foo?.baz;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module.exports = {
2+
root: true,
3+
extends: [
4+
'eslint:recommended',
5+
'plugin:import/recommended',
6+
'plugin:jsx-a11y/recommended',
7+
'plugin:react/recommended',
8+
require.resolve('eslint-config-react-app'),
9+
'ringcentral',
10+
'plugin:prettier/recommended', // must be belowe ringcentral to override react prefs
11+
'prettier/react', // must be belowe ringcentral to override react prefs
12+
'plugin:@typescript-eslint/recommended', // must be below react-app & ringcentral to enable proper parser
13+
'plugin:import/typescript',
14+
],
15+
rules: {
16+
'prettier/prettier': [
17+
'error',
18+
{
19+
bracketSpacing: false,
20+
parser: 'typescript',
21+
singleQuote: true,
22+
tabWidth: 4,
23+
trailingComma: 'all',
24+
},
25+
],
26+
'@typescript-eslint/indent': 'off', // prettier takes care of it
27+
},
28+
env: {
29+
browser: true,
30+
node: true,
31+
},
32+
settings: {
33+
react: {
34+
version: 'detect',
35+
},
36+
},
37+
};
+11-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "eslint-config-ringcentral",
3-
"version": "0.5.0",
3+
"version": "1.0.0",
44
"description": "ESLint config for the RingCentral style guide",
55
"main": "index.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"test": "echo \"No test specified\""
88
},
99
"repository": {
1010
"type": "git",
@@ -20,24 +20,24 @@
2020
"tools",
2121
"config"
2222
],
23-
"author": "RingCentral developers",
23+
"author": "RingCentral Developers",
2424
"license": "MIT",
2525
"bugs": {
2626
"url": "https://github.com/ringcentral/ringcentral-javascript/issues"
2727
},
2828
"homepage": "https://github.com/ringcentral/ringcentral-javascript",
2929
"devDependencies": {
3030
"eslint": ">=4.1.1",
31-
"eslint-plugin-import": "^2.16.0",
32-
"eslint-plugin-react": "^7.1.0",
33-
"eslint-plugin-ringcentral": "~1.0.5",
34-
"eslint-plugin-sonarjs": "^0.4.0"
31+
"eslint-plugin-import": "^2.19.1",
32+
"eslint-plugin-react": "^7.17.0",
33+
"eslint-plugin-ringcentral": "^1.0.0",
34+
"eslint-plugin-sonarjs": "^0.5.0"
3535
},
3636
"peerDependencies": {
3737
"eslint": ">=4.1.1",
38-
"eslint-plugin-import": "^2.16.0",
39-
"eslint-plugin-react": "^7.1.0",
40-
"eslint-plugin-ringcentral": "~1.0.5",
41-
"eslint-plugin-sonarjs": "^0.4.0"
38+
"eslint-plugin-import": "^2.19.1",
39+
"eslint-plugin-react": "^7.17.0",
40+
"eslint-plugin-ringcentral": "*",
41+
"eslint-plugin-sonarjs": "^0.5.0"
4242
}
4343
}

eslint-plugin-ringcentral/README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# eslint-plugin-ringcentral
2+
3+
plugin for ringcentral products
4+
5+
## Installation
6+
7+
You'll first need to install [ESLint](http://eslint.org):
8+
9+
```
10+
$ npm i eslint --save-dev
11+
```
12+
13+
Next, install `eslint-plugin-ringcentral`:
14+
15+
```
16+
$ npm i eslint-plugin-ringcentral --save-dev
17+
```
18+
19+
**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-ringcentral` globally.
20+
21+
## Usage
22+
23+
Add `ringcentral` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
24+
25+
```json
26+
{
27+
"plugins": ["ringcentral"],
28+
"extends": ["plugin:ringcentral/all"],
29+
// or
30+
"extends": ["plugin:ringcentral/all-warn"]
31+
}
32+
```
33+
34+
35+
36+
37+

eslint-plugin-ringcentral/index.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
rules: {
3+
'specified-comment-with-task-id': require('./lib/rules/specified-comment-with-task-id')
4+
},
5+
configs: {
6+
all: {
7+
rules: {
8+
'ringcentral/specified-comment-with-task-id': 2,
9+
},
10+
},
11+
'all-warn': {
12+
rules: {
13+
'ringcentral/specified-comment-with-task-id': 1,
14+
},
15+
},
16+
recommended: {
17+
rules: {
18+
'ringcentral/specified-comment-with-task-id': 1,
19+
},
20+
},
21+
}
22+
};

0 commit comments

Comments
 (0)