Skip to content

Commit 0124ee8

Browse files
committed
- Initial commit 🎉
1 parent 92c7d4f commit 0124ee8

File tree

7 files changed

+258
-0
lines changed

7 files changed

+258
-0
lines changed

.eslintrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "./index.js",
3+
"overrides": {
4+
files: ["**/*.ts", "**/*.tsx"],
5+
"rules": {
6+
"@typescript-eslint/no-unused-vars": "error"
7+
}
8+
},
9+
"rules": {
10+
"no-unused-vars": "error"
11+
}
12+
}

.gitignore

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Node template
3+
# Logs
4+
logs
5+
*.log
6+
npm-debug.log*
7+
yarn-debug.log*
8+
yarn-error.log*
9+
10+
# Runtime data
11+
pids
12+
*.pid
13+
*.seed
14+
*.pid.lock
15+
16+
# Directory for instrumented libs generated by jscoverage/JSCover
17+
lib-cov
18+
19+
# Coverage directory used by tools like istanbul
20+
coverage
21+
22+
# nyc test coverage
23+
.nyc_output
24+
25+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
26+
.grunt
27+
28+
# Bower dependency directory (https://bower.io/)
29+
bower_components
30+
31+
# node-waf configuration
32+
.lock-wscript
33+
34+
# Compiled binary addons (https://nodejs.org/api/addons.html)
35+
build/Release
36+
37+
# Dependency directories
38+
node_modules/
39+
jspm_packages/
40+
41+
# TypeScript v1 declaration files
42+
typings/
43+
44+
# Optional npm cache directory
45+
.npm
46+
47+
# Optional eslint cache
48+
.eslintcache
49+
50+
# Optional REPL history
51+
.node_repl_history
52+
53+
# Output of 'npm pack'
54+
*.tgz
55+
56+
# Yarn Integrity file
57+
.yarn-integrity
58+
59+
# dotenv environment variables file
60+
.env
61+
62+
# parcel-bundler cache (https://parceljs.org/)
63+
.cache
64+
65+
# next.js build output
66+
.next
67+
68+
# nuxt.js build output
69+
.nuxt
70+
71+
# vuepress build output
72+
.vuepress/dist
73+
74+
# Serverless directories
75+
.serverless
76+

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# eslint-config-plain-typescript
2+
3+
Plain config without any rules that makes ESLint working with typescript
4+
5+
## How to use.
6+
- Install it as a dependency.
7+
```
8+
yarn add eslint-config-plain-typescript
9+
```
10+
- Make sure you have `typescript` and `tsconfig.json` in root of the project
11+
12+
- Add in your `.eslintrc` extension like that:
13+
```
14+
"extends": ["plain-typescript"]
15+
```
16+
17+
- After that your ESLint will start to parse all Typescript code.
18+
19+
## How to extend.
20+
21+
There is some rules that are not compatible with `js` so when you use them it's nice
22+
to put the inside of the `override` object in your `.eslintrc` config like that.
23+
```json5
24+
{
25+
"extends": ["airbnb", "plain-typescript"],
26+
"overrides": {
27+
files: ["**/*.ts", "**/*.tsx"],
28+
"rules": { // These are rules that should apply to ts/tsx files only
29+
"@typescript-eslint/no-unused-vars": "error"
30+
}
31+
},
32+
"rules": { // These are rules that go for both and are proven to not be conflicting
33+
"no-unused-vars": "error"
34+
}
35+
}
36+
```
37+
38+
Also please refer to the `typescript` [recommended config](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/recommended.json) for more info about available rules and rules that are incompatible.
39+
40+
## Note
41+
42+
Not 100% sure, but put it after all the other configs that you may import.
43+
The only configs that you should export after is `prettier` related stuff, others should go before this one I assume.
44+
45+
## Depends on.
46+
There three suckers gonna be installed along the way with installation.
47+
```
48+
"dependencies": {
49+
"babel-eslint": "10.0.1",
50+
"@typescript-eslint/parser": "^1.4.2",
51+
"@typescript-eslint/eslint-plugin": "1.4.2"
52+
}
53+
```
54+
55+
These two suckers should be installed separatly as `devDependencies`:
56+
```
57+
"peerDependencies": {
58+
"eslint": ">=5.15",
59+
"typescript": "^>=3"
60+
}
61+
```

checkme.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
enum Kek {
2+
Kek
3+
}

index.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"use strict";
2+
// The following is copied from `react-scripts/config/paths.js`.
3+
const path = require("path");
4+
const fs = require("fs");
5+
6+
const appDirectory = fs.realpathSync(process.cwd());
7+
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
8+
const projectRootPath = resolveApp(".");
9+
const tsConfigPath = resolveApp("tsconfig.json");
10+
11+
module.exports = {
12+
root: true,
13+
parser: "babel-eslint",
14+
env: {
15+
browser: true,
16+
commonjs: true,
17+
es6: true,
18+
jest: true,
19+
node: true
20+
},
21+
parserOptions: {
22+
ecmaVersion: 2018,
23+
sourceType: "module",
24+
ecmaFeatures: {
25+
jsx: true
26+
}
27+
},
28+
overrides: {
29+
files: ["**/*.ts", "**/*.tsx"],
30+
parser: "@typescript-eslint/parser",
31+
parserOptions: {
32+
ecmaVersion: 2018,
33+
sourceType: "module",
34+
ecmaFeatures: {
35+
jsx: true
36+
},
37+
38+
// typescript-eslint specific options
39+
project: tsConfigPath,
40+
tsconfigRootDir: projectRootPath,
41+
warnOnUnsupportedTypeScriptVersion: true
42+
},
43+
plugins: ["@typescript-eslint"],
44+
rules: {
45+
// These ESLint rules are known to cause issues with typescript-eslint
46+
// See https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/recommended.json
47+
camelcase: "off",
48+
indent: "off",
49+
"no-array-constructor": "off",
50+
"no-unused-vars": "off"
51+
}
52+
}
53+
};

package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "eslint-config-plain-typescript",
3+
"version": "0.0.1",
4+
"description": "Plain config without any rules that makes typescript working with ESLint",
5+
"repository": "https://github.com/RIP21/eslint-config-plain-typescript",
6+
"license": "MIT",
7+
"bugs": {
8+
"url": "https://github.com/RIP21/eslint-config-plain-typescript/issues"
9+
},
10+
"files": [
11+
"index.js"
12+
],
13+
"devDependencies": {
14+
"eslint": "^5.15.3",
15+
"typescript": "^3.3.3333"
16+
},
17+
"dependencies": {
18+
"babel-eslint": "10.0.1",
19+
"@typescript-eslint/parser": "^1.4.2",
20+
"@typescript-eslint/eslint-plugin": "1.4.2"
21+
},
22+
"peerDependencies": {
23+
"eslint": ">=5.15",
24+
"typescript": "^>=3"
25+
},
26+
"scripts": {
27+
"test": "eslint checkme.ts && exit 1 || exit 0"
28+
}
29+
}

tsconfig.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"compilerOptions": {
3+
"downlevelIteration": true,
4+
"lib": ["esnext", "dom", "dom.iterable"],
5+
"module": "esnext",
6+
"target": "esnext",
7+
"allowJs": true,
8+
"esModuleInterop": true,
9+
"jsx": "preserve",
10+
"experimentalDecorators": true,
11+
"moduleResolution": "node",
12+
"forceConsistentCasingInFileNames": false,
13+
"noUnusedParameters": true,
14+
"noUnusedLocals": true,
15+
"suppressImplicitAnyIndexErrors": true,
16+
"skipLibCheck": true,
17+
"noEmit": true,
18+
"resolveJsonModule": true,
19+
"strict": true,
20+
"allowSyntheticDefaultImports": true,
21+
"emitDecoratorMetadata": true
22+
},
23+
"include": ["checkme.ts"]
24+
}

0 commit comments

Comments
 (0)