Skip to content

Commit

Permalink
chore: ESLint config for Electron-TypeScript projects
Browse files Browse the repository at this point in the history
  • Loading branch information
alex8088 committed Jul 24, 2023
1 parent db04c32 commit 95211dc
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 21 deletions.
21 changes: 21 additions & 0 deletions packages/eslint-config-ts/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022-present, Alex.Wei

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
49 changes: 49 additions & 0 deletions packages/eslint-config-ts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# @electron-toolkit/eslint-config-ts

> Basic ESLint config for Electron-TypeScript projects.
Requires `eslint >= 8.0.0`.

This config is specifically designed to be used by `@quick-start/create-electron` setups.

See [@typescript-eslint/eslint-plugin](https://typescript-eslint.io/rules/) for available rules.

## Installation

```sh
npm add -D @electron-toolkit/eslint-config-ts
```

## Usage

This package comes with 3 rulesets.

### @electron-toolkit/eslint-config-ts

This ruleset is the base configuration for Electron-TypeScript projects.

```js
module.exports = {
extends: ['@electron-toolkit/eslint-config-ts']
}
```

### @electron-toolkit/eslint-config-ts/eslint-recommended

Built-in some recommended rules for Electron-TypeScript projects.

```js
module.exports = {
extends: ['@electron-toolkit/eslint-config-ts/eslint-recommended']
}
```

### @electron-toolkit/eslint-config-ts/recommended

This is extended from `@electron-toolkit/eslint-config-ts` and `@electron-toolkit/eslint-config-ts/eslint-recommended` ruleset.

```js
module.exports = {
extends: ['@electron-toolkit/eslint-config-ts/recommended']
}
```
20 changes: 20 additions & 0 deletions packages/eslint-config-ts/eslint-recommended.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
rules: {
'@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': 'allow-with-description' }],
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-function': ['error', { allow: ['arrowFunctions'] }],
'@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-var-requires': 'off'
},
overrides: [
{
files: ['*.js'],
rules: {
'@typescript-eslint/explicit-function-return-type': 'off'
}
}
]
}
18 changes: 18 additions & 0 deletions packages/eslint-config-ts/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es6: true,
node: true
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true
},
sourceType: 'module',
ecmaVersion: 2021
},
plugins: ['@typescript-eslint'],
extends: ['plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/eslint-recommended']
}
44 changes: 44 additions & 0 deletions packages/eslint-config-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "@electron-toolkit/eslint-config-ts",
"version": "0.0.0",
"description": "Basic ESLint config for Electron-TypeScript projects.",
"main": "index.js",
"files": [
"eslint-recommended.js",
"index.js",
"recommended.js"
],
"author": "Alex Wei<https://github.com/alex8088>",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/alex8088/electron-toolkit.git",
"directory": "packages/eslint-config-ts"
},
"bugs": {
"url": "https://github.com/alex8088/electron-toolkit/issues"
},
"homepage": "https://github.com/alex8088/electron-toolkit/tree/master/packages/eslint-config-ts#readme",
"keywords": [
"electron",
"eslint",
"typescript"
],
"dependencies": {
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0"
},
"devDependencies": {
"eslint": "^8.45.0",
"typescript": "^4.5.4"
},
"peerDependencies": {
"eslint": ">=8.0.0",
"typescript": "*"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
}
3 changes: 3 additions & 0 deletions packages/eslint-config-ts/recommended.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: [require.resolve('./index'), require.resolve('./eslint-recommended')]
}
34 changes: 13 additions & 21 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 95211dc

Please sign in to comment.