Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create and export custom ESLint TypeScript configuration #1

Merged
merged 5 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
root: true,
env: {
node: true,
},
extends: ["eslint:recommended", require.resolve("./index")],
overrides: [
{
files: ["test/**.spec.ts"],
env: {
jest: true,
},
},
],
};
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI

on:
push:
branches:
- master
- "v*"
pull_request: {}

concurrency:
group: ci-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
test:
name: "Tests"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install pnpm
uses: wyvox/action-setup-pnpm@v3
with:
node-version: 18.x
args: "--frozen-lockfile"
- name: Tests
run: pnpm test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,6 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# Apple Desktop Services Store
/.DS_Store
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
# eslint-config-typescript
Shared ESLint TypeScript config for Qonto's open source projects.
# @qonto/eslint-config-typescript

A shared ESLint TypeScript configuration used at Qonto. It has TypeScript specific rules from [@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin).

## Installation

`@qonto/eslint-config-typescript` has a few peer dependencies that need to be installed alongside:

- [`eslint`](https://eslint.org/)
- [`typescript`](https://www.typescriptlang.org/)

Install `@qonto/eslint-config-typescript` and its peer dependencies:

```bash
pnpm add -D @qonto/eslint-config-typescript eslint typescript
```

You can use the package manager of your choice.

## Usage

Here is an example of a `.eslintrc.js` file.

```js
module.exports = {
extends: ["eslint:recommended"],
overrides: [
files: ['*.ts'],
extends: ["@qonto/eslint-config-typescript"],
]
};
```
68 changes: 68 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
extends: [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
],
overrides: [
{
files: ["*.ts", "*.cts", "*.mts", "*.tsx"],
rules: {
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/array-type": [
"error",
{
default: "array",
readonly: "array",
},
],
"@typescript-eslint/ban-tslint-comment": "error",
"@typescript-eslint/class-literal-property-style": "error",
"@typescript-eslint/consistent-generic-constructors": "error",
"@typescript-eslint/consistent-indexed-object-style": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
accessibility: "no-public",
},
],
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/member-delimiter-style": "error",
"@typescript-eslint/member-ordering": "error",
"@typescript-eslint/method-signature-style": "error",
"@typescript-eslint/no-confusing-non-null-assertion": "error",
"@typescript-eslint/no-duplicate-enum-values": "error",
"@typescript-eslint/no-dynamic-delete": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-import-type-side-effects": "error",
"@typescript-eslint/no-invalid-void-type": "error",
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-type-alias": [
"error",
{
allowGenerics: "always",
},
],
"@typescript-eslint/no-unsafe-declaration-merging": "error",
"@typescript-eslint/parameter-properties": "error",
"@typescript-eslint/prefer-enum-initializers": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-literal-enum-member": "error",
"@typescript-eslint/prefer-ts-expect-error": "error",
"@typescript-eslint/sort-type-constituents": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/typedef": "error",
"@typescript-eslint/unified-signatures": "error",
},
},
],
};
12 changes: 12 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { Config } from 'jest';

const config: Config = {
preset: 'ts-jest/presets/default-esm',
testEnvironment: 'node',
testMatch: ["**/tests/**/*.spec.ts"],
transform: {
'^.+\\.(ts|tsx)?$': ['ts-jest', { useESM: true }]
},
};

export default config;
51 changes: 51 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@qonto/eslint-config-typescript",
"version": "0.0.1",
"description": "ESLint TypeScript configuration.",
"scripts": {
"test": "NODE_OPTIONS=--experimental-vm-modules pnpm exec jest"
vscav marked this conversation as resolved.
Show resolved Hide resolved
},
"main": "index.js",
"files": [
"index.js"
],
"repository": {
"type": "git",
"url": "https://github.com/qonto/eslint-config-typescript"
},
"keywords": [
"eslint"
],
"author": "Qonto",
"license": "MIT",
"bugs": {
"url": "https://github.com/qonto/eslint-config-typescript/issues"
},
"homepage": "https://github.com/qonto/eslint-config-typescript",
"peerDependencies": {
"eslint": "^7.0.0 || ^8.0.0",
"typescript": "*"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0"
},
"devDependencies": {
"@types/jest": "^29.5.6",
"@types/node": "^20.8.7",
"eslint": "^8.51.0",
"execa": "^8.0.1",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
},
"packageManager": "pnpm@8.6.11",
"engines": {
"node": ">= 18.*"
},
"volta": {
"node": "18.18.2",
"pnpm": "8.6.11"
}
}