Skip to content

Commit a0e9151

Browse files
authored
feat(eslint-config): add typescript config (#258)
BREAKING CHANGE: environments are not set anymore, need to be specified on a per project basis
1 parent 767c94b commit a0e9151

File tree

8 files changed

+189
-55
lines changed

8 files changed

+189
-55
lines changed

.eslintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"root": true,
33
"parser": "@babel/eslint-parser",
4+
"env": {
5+
"browser": true,
6+
"jest": true
7+
},
48
"extends": "./packages/eslint-config-react/index.js",
59
"rules": {
610
"import/no-extraneous-dependencies": [

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ scaleway-lib is a set of NPM packages used at Scaleway.
3939
![npm bundle size](https://img.shields.io/bundlephobia/min/@scaleway/countries)
4040
![npm](https://img.shields.io/npm/v/@scaleway/countries)
4141

42-
- [`@scaleway/eslint-config-react`](./packages/eslint-config-react/README.md): A shared eslint react opiniated configuration.
42+
- [`@scaleway/eslint-config-react`](./packages/eslint-config-react/README.md): A shared eslint react opiniated configuration. Available in Javascript and Typescript.
4343

4444
![npm](https://img.shields.io/npm/dm/@scaleway/eslint-config-react)
4545
![npm bundle size](https://img.shields.io/bundlephobia/min/@scaleway/eslint-config-react)

packages/eslint-config-react/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
A shared eslint react opiniated configuration
44

5+
Available in Javascript and Typescript
6+
57
---
68

79
## Install
@@ -19,3 +21,13 @@ Add to your `.eslintrc`
1921
"extends": "@scaleway/react"
2022
}
2123
```
24+
25+
Or for Typescript
26+
```json
27+
{
28+
"extends": "@scaleway/react/typescript",
29+
"parserOptions": {
30+
"project": "./path/to/tsconfig.json"
31+
}
32+
}
33+
```
Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,6 @@
11
module.exports = {
2-
env: {
3-
browser: true,
4-
jest: true,
5-
},
6-
extends: ['airbnb', 'airbnb/hooks', 'prettier'],
2+
extends: ['eslint-config-airbnb', require.resolve('./shared')],
73
rules: {
8-
'import/order': [
9-
'error',
10-
{
11-
alphabetize: {
12-
caseInsensitive: false,
13-
order: 'asc',
14-
},
15-
groups: [
16-
['builtin', 'external'],
17-
'internal',
18-
'parent',
19-
'sibling',
20-
'index',
21-
],
22-
'newlines-between': 'never',
23-
},
24-
],
25-
'padding-line-between-statements': [
26-
'error',
27-
{
28-
blankLine: 'always',
29-
next: 'return',
30-
prev: '*',
31-
},
32-
],
334
'react/jsx-filename-extension': ['error', { extensions: ['.js'] }],
34-
'react/jsx-no-constructed-context-values': 'warn',
35-
'react/jsx-no-script-url': 'error',
36-
'react/jsx-no-useless-fragment': 'error',
37-
'react/no-adjacent-inline-elements': 'error',
38-
'react/sort-prop-types': [
39-
'error',
40-
{ ignoreCase: true, requiredFirst: false, sortShapeProp: true },
41-
],
42-
'sort-imports': [
43-
'error',
44-
{
45-
ignoreDeclarationSort: true,
46-
memberSyntaxSortOrder: ['single', 'multiple', 'all', 'none'],
47-
},
48-
],
49-
'sort-keys': ['error', 'asc', { caseSensitive: true, natural: true }],
505
},
516
}

packages/eslint-config-react/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,19 @@
1717
},
1818
"license": "MIT",
1919
"dependencies": {
20-
"@babel/eslint-parser": "^7.12.1",
20+
"@typescript-eslint/eslint-plugin": "^4.28.1",
2121
"eslint-config-airbnb": "^18.2.1",
22+
"eslint-config-airbnb-typescript": "^12.3.1",
2223
"eslint-config-prettier": "^8.1.0",
2324
"eslint-plugin-import": "^2.22.1",
2425
"eslint-plugin-jsx-a11y": "^6.4.1",
2526
"eslint-plugin-react": "^7.22.0",
2627
"eslint-plugin-react-hooks": "^4.2.0"
2728
},
2829
"devDependencies": {
29-
"@babel/core": "^7.12.10",
3030
"eslint": "^7.18.0"
3131
},
3232
"peerDependencies": {
33-
"@babel/core": "7.x",
3433
"eslint": "7.x"
3534
}
3635
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
module.exports = {
2+
extends: ['airbnb/hooks', 'prettier'],
3+
rules: {
4+
'import/order': [
5+
'error',
6+
{
7+
alphabetize: {
8+
caseInsensitive: false,
9+
order: 'asc',
10+
},
11+
groups: [
12+
['builtin', 'external'],
13+
'internal',
14+
'parent',
15+
'sibling',
16+
'index',
17+
],
18+
'newlines-between': 'never',
19+
},
20+
],
21+
'padding-line-between-statements': [
22+
'error',
23+
{
24+
blankLine: 'always',
25+
next: 'return',
26+
prev: '*',
27+
},
28+
],
29+
'react/jsx-no-constructed-context-values': 'warn',
30+
'react/jsx-no-script-url': 'error',
31+
'react/jsx-no-useless-fragment': 'error',
32+
'react/no-adjacent-inline-elements': 'error',
33+
'react/sort-prop-types': [
34+
'error',
35+
{ ignoreCase: true, requiredFirst: false, sortShapeProp: true },
36+
],
37+
'sort-imports': [
38+
'error',
39+
{
40+
ignoreDeclarationSort: true,
41+
memberSyntaxSortOrder: ['single', 'multiple', 'all', 'none'],
42+
},
43+
],
44+
'sort-keys': ['error', 'asc', { caseSensitive: false, natural: true }],
45+
},
46+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
extends: [
3+
'eslint-config-airbnb-typescript',
4+
'plugin:@typescript-eslint/recommended',
5+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
6+
require.resolve('./shared'),
7+
],
8+
plugins: ['@typescript-eslint'],
9+
}

yarn.lock

Lines changed: 114 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
semver "^6.3.0"
4343
source-map "^0.5.0"
4444

45-
"@babel/eslint-parser@^7.12.1", "@babel/eslint-parser@^7.13.10":
45+
"@babel/eslint-parser@^7.13.10":
4646
version "7.14.7"
4747
resolved "https://registry.yarnpkg.com/@babel/eslint-parser/-/eslint-parser-7.14.7.tgz#91be59a4f7dd60d02a3ef772d156976465596bda"
4848
integrity sha512-6WPwZqO5priAGIwV6msJcdc9TsEPzYeYdS/Xuoap+/ihkgN6dzHp2bcAAwyWZ5bLzk0vvjDmKvRwkqNaiJ8BiQ==
@@ -2409,6 +2409,11 @@
24092409
jest-diff "^26.0.0"
24102410
pretty-format "^26.0.0"
24112411

2412+
"@types/json-schema@^7.0.7":
2413+
version "7.0.7"
2414+
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad"
2415+
integrity sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==
2416+
24122417
"@types/json5@^0.0.29":
24132418
version "0.0.29"
24142419
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
@@ -2515,6 +2520,75 @@
25152520
dependencies:
25162521
"@types/yargs-parser" "*"
25172522

2523+
"@typescript-eslint/eslint-plugin@^4.28.1":
2524+
version "4.28.1"
2525+
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.28.1.tgz#c045e440196ae45464e08e20c38aff5c3a825947"
2526+
integrity sha512-9yfcNpDaNGQ6/LQOX/KhUFTR1sCKH+PBr234k6hI9XJ0VP5UqGxap0AnNwBnWFk1MNyWBylJH9ZkzBXC+5akZQ==
2527+
dependencies:
2528+
"@typescript-eslint/experimental-utils" "4.28.1"
2529+
"@typescript-eslint/scope-manager" "4.28.1"
2530+
debug "^4.3.1"
2531+
functional-red-black-tree "^1.0.1"
2532+
regexpp "^3.1.0"
2533+
semver "^7.3.5"
2534+
tsutils "^3.21.0"
2535+
2536+
"@typescript-eslint/[email protected]":
2537+
version "4.28.1"
2538+
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.28.1.tgz#3869489dcca3c18523c46018b8996e15948dbadc"
2539+
integrity sha512-n8/ggadrZ+uyrfrSEchx3jgODdmcx7MzVM2sI3cTpI/YlfSm0+9HEUaWw3aQn2urL2KYlWYMDgn45iLfjDYB+Q==
2540+
dependencies:
2541+
"@types/json-schema" "^7.0.7"
2542+
"@typescript-eslint/scope-manager" "4.28.1"
2543+
"@typescript-eslint/types" "4.28.1"
2544+
"@typescript-eslint/typescript-estree" "4.28.1"
2545+
eslint-scope "^5.1.1"
2546+
eslint-utils "^3.0.0"
2547+
2548+
"@typescript-eslint/parser@^4.4.1":
2549+
version "4.28.1"
2550+
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.28.1.tgz#5181b81658414f47291452c15bf6cd44a32f85bd"
2551+
integrity sha512-UjrMsgnhQIIK82hXGaD+MCN8IfORS1CbMdu7VlZbYa8LCZtbZjJA26De4IPQB7XYZbL8gJ99KWNj0l6WD0guJg==
2552+
dependencies:
2553+
"@typescript-eslint/scope-manager" "4.28.1"
2554+
"@typescript-eslint/types" "4.28.1"
2555+
"@typescript-eslint/typescript-estree" "4.28.1"
2556+
debug "^4.3.1"
2557+
2558+
"@typescript-eslint/[email protected]":
2559+
version "4.28.1"
2560+
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.28.1.tgz#fd3c20627cdc12933f6d98b386940d8d0ce8a991"
2561+
integrity sha512-o95bvGKfss6705x7jFGDyS7trAORTy57lwJ+VsYwil/lOUxKQ9tA7Suuq+ciMhJc/1qPwB3XE2DKh9wubW8YYA==
2562+
dependencies:
2563+
"@typescript-eslint/types" "4.28.1"
2564+
"@typescript-eslint/visitor-keys" "4.28.1"
2565+
2566+
"@typescript-eslint/[email protected]":
2567+
version "4.28.1"
2568+
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.28.1.tgz#d0f2ecbef3684634db357b9bbfc97b94b828f83f"
2569+
integrity sha512-4z+knEihcyX7blAGi7O3Fm3O6YRCP+r56NJFMNGsmtdw+NCdpG5SgNz427LS9nQkRVTswZLhz484hakQwB8RRg==
2570+
2571+
"@typescript-eslint/[email protected]":
2572+
version "4.28.1"
2573+
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.28.1.tgz#af882ae41740d1f268e38b4d0fad21e7e8d86a81"
2574+
integrity sha512-GhKxmC4sHXxHGJv8e8egAZeTZ6HI4mLU6S7FUzvFOtsk7ZIDN1ksA9r9DyOgNqowA9yAtZXV0Uiap61bIO81FQ==
2575+
dependencies:
2576+
"@typescript-eslint/types" "4.28.1"
2577+
"@typescript-eslint/visitor-keys" "4.28.1"
2578+
debug "^4.3.1"
2579+
globby "^11.0.3"
2580+
is-glob "^4.0.1"
2581+
semver "^7.3.5"
2582+
tsutils "^3.21.0"
2583+
2584+
"@typescript-eslint/[email protected]":
2585+
version "4.28.1"
2586+
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.28.1.tgz#162a515ee255f18a6068edc26df793cdc1ec9157"
2587+
integrity sha512-K4HMrdFqr9PFquPu178SaSb92CaWe2yErXyPumc8cYWxFmhgJsNY9eSePmO05j0JhBvf2Cdhptd6E6Yv9HVHcg==
2588+
dependencies:
2589+
"@typescript-eslint/types" "4.28.1"
2590+
eslint-visitor-keys "^2.0.0"
2591+
25182592
JSONStream@^1.0.4:
25192593
version "1.3.5"
25202594
resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0"
@@ -3842,7 +3916,7 @@ escodegen@^2.0.0:
38423916
optionalDependencies:
38433917
source-map "~0.6.1"
38443918

3845-
eslint-config-airbnb-base@^14.2.1:
3919+
eslint-config-airbnb-base@^14.2.0, eslint-config-airbnb-base@^14.2.1:
38463920
version "14.2.1"
38473921
resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-14.2.1.tgz#8a2eb38455dc5a312550193b319cdaeef042cd1e"
38483922
integrity sha512-GOrQyDtVEc1Xy20U7vsB2yAoB4nBlfH5HZJeatRXHleO+OS5Ot+MWij4Dpltw4/DyIkqUfqz1epfhVR5XWWQPA==
@@ -3851,7 +3925,16 @@ eslint-config-airbnb-base@^14.2.1:
38513925
object.assign "^4.1.2"
38523926
object.entries "^1.1.2"
38533927

3854-
eslint-config-airbnb@^18.2.1:
3928+
eslint-config-airbnb-typescript@^12.3.1:
3929+
version "12.3.1"
3930+
resolved "https://registry.yarnpkg.com/eslint-config-airbnb-typescript/-/eslint-config-airbnb-typescript-12.3.1.tgz#83ab40d76402c208eb08516260d1d6fac8f8acbc"
3931+
integrity sha512-ql/Pe6/hppYuRp4m3iPaHJqkBB7dgeEmGPQ6X0UNmrQOfTF+dXw29/ZjU2kQ6RDoLxaxOA+Xqv07Vbef6oVTWw==
3932+
dependencies:
3933+
"@typescript-eslint/parser" "^4.4.1"
3934+
eslint-config-airbnb "^18.2.0"
3935+
eslint-config-airbnb-base "^14.2.0"
3936+
3937+
eslint-config-airbnb@^18.2.0, eslint-config-airbnb@^18.2.1:
38553938
version "18.2.1"
38563939
resolved "https://registry.yarnpkg.com/eslint-config-airbnb/-/eslint-config-airbnb-18.2.1.tgz#b7fe2b42f9f8173e825b73c8014b592e449c98d9"
38573940
integrity sha512-glZNDEZ36VdlZWoxn/bUR1r/sdFKPd1mHPbqUtkctgNG4yT2DLLtJ3D+yCV+jzZCc2V1nBVkmdknOJBZ5Hc0fg==
@@ -3957,6 +4040,13 @@ eslint-utils@^2.1.0:
39574040
dependencies:
39584041
eslint-visitor-keys "^1.1.0"
39594042

4043+
eslint-utils@^3.0.0:
4044+
version "3.0.0"
4045+
resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-3.0.0.tgz#8aebaface7345bb33559db0a1f13a1d2d48c3672"
4046+
integrity sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==
4047+
dependencies:
4048+
eslint-visitor-keys "^2.0.0"
4049+
39604050
eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0:
39614051
version "1.3.0"
39624052
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e"
@@ -4474,6 +4564,18 @@ globby@^11.0.2:
44744564
merge2 "^1.3.0"
44754565
slash "^3.0.0"
44764566

4567+
globby@^11.0.3:
4568+
version "11.0.4"
4569+
resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5"
4570+
integrity sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==
4571+
dependencies:
4572+
array-union "^2.1.0"
4573+
dir-glob "^3.0.1"
4574+
fast-glob "^3.1.1"
4575+
ignore "^5.1.4"
4576+
merge2 "^1.3.0"
4577+
slash "^3.0.0"
4578+
44774579
graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.2, graceful-fs@^4.2.3, graceful-fs@^4.2.4:
44784580
version "4.2.6"
44794581
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.6.tgz#ff040b2b0853b23c3d31027523706f1885d76bee"
@@ -7547,7 +7649,7 @@ [email protected]:
75477649
resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e"
75487650
integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==
75497651

7550-
[email protected], semver@^7.0.0, semver@^7.1.1, semver@^7.1.3, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4:
7652+
[email protected], semver@^7.0.0, semver@^7.1.1, semver@^7.1.3, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5:
75517653
version "7.3.5"
75527654
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7"
75537655
integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==
@@ -8182,7 +8284,7 @@ tsconfig-paths@^3.9.0:
81828284
minimist "^1.2.0"
81838285
strip-bom "^3.0.0"
81848286

8185-
tslib@^1.9.0:
8287+
tslib@^1.8.1, tslib@^1.9.0:
81868288
version "1.14.1"
81878289
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
81888290
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
@@ -8192,6 +8294,13 @@ tslib@^2.1.0:
81928294
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a"
81938295
integrity sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==
81948296

8297+
tsutils@^3.21.0:
8298+
version "3.21.0"
8299+
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"
8300+
integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==
8301+
dependencies:
8302+
tslib "^1.8.1"
8303+
81958304
tunnel-agent@^0.6.0:
81968305
version "0.6.0"
81978306
resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd"

0 commit comments

Comments
 (0)