Skip to content

Commit fa0edb6

Browse files
Add linting for Typescript (#2)
* feat(package): extend eslint:recommended * dep: add prettier to project * feat(package): add support for linting typescript * refactor: rename file names
1 parent d0b4113 commit fa0edb6

12 files changed

Lines changed: 4292 additions & 4192 deletions

File tree

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"editor.formatOnSave": true
4+
}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# react-native-project-config
2+
23
Monorepo with packages for setting up ESLint, Typescript, Prettier and Jest.
34

45
## Presentation
@@ -12,4 +13,4 @@ There is also an example app under `packages/example-app` whose goal is to demon
1213
## Commands
1314

1415
- `yarn lerna run start`: run the 'start' script in all packages (currently only present in `example-app`),
15-
- `yarn lerna run lint`: run the 'lint' script in all packages (currently only present in `example-app`).
16+
- `yarn lerna run lint`: run the 'lint' script in all packages (currently only present in `example-app`).

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"packages/*"
66
],
77
"devDependencies": {
8-
"lerna": "^6.3.0"
8+
"lerna": "^6.3.0",
9+
"prettier": "^2.8.1"
910
}
1011
}

packages/eslint/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
"use strict";
22

33
module.exports = {
4-
rules: {
5-
"no-console": "error",
4+
env: {
5+
node: true,
66
},
7+
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
8+
parser: "@typescript-eslint/parser",
9+
parserOptions: {
10+
ecmaVersion: "latest",
11+
},
12+
plugins: ["@typescript-eslint"],
713
};

packages/eslint/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,12 @@
22
"name": "@bam.tech/eslint-config",
33
"version": "0.0.0",
44
"main": "index.js",
5-
"license": "MIT"
5+
"license": "MIT",
6+
"peerDependencies": {
7+
"@typescript-eslint/eslint-plugin": ">= 5",
8+
"eslint": ">= 8"
9+
},
10+
"devDependencies": {
11+
"@typescript-eslint/parser": "^5.48.0"
12+
}
613
}

packages/example-app/.eslintrc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
{
2-
"env": {
3-
"es6": true
4-
},
5-
"extends": "@bam.tech/eslint-config",
6-
"parserOptions": {
7-
"ecmaVersion": "latest"
8-
}
2+
"extends": "@bam.tech/eslint-config"
93
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"use strict";
2+
3+
console.log(
4+
"This is a console.log statement to see it the linter produces an error"
5+
);
6+
7+
// This should trigger two errors breaking eslint:recommended rules:
8+
// no-constant-condition
9+
// no-empty
10+
if (true) {
11+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// This should trigger two errors breaking typescript-eslint rules:
2+
// @typescript-eslint/no-unused-vars
3+
// @typescript-eslint/ban-types
4+
const str: String = "foo";

packages/example-app/index.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)