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

Fixed global eslint and tsconfig #36

Merged
merged 6 commits into from
Mar 7, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/node_modules/*
**/node_modules
# build artifacts
dist/*coverage/*
dist/*
lib/*

/**/dist/*
**/dist

# data definition files
**/*.d.ts

# custom definition files
/src/types/

!.eslintrc.js
!.eslintrc.js
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:prettier/recommended"
],
"ignorePatterns": ["dist/", "lib/"],
"ignorePatterns": ["**/dist/", "**/lib/"],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To ignore nested folders inside packages.

"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2023,
"sourceType": "module",
"project": "./tsconfig.json"
"project": "./tsconfig.eslint.json"
},
"rules": {
"no-unused-vars": "off",
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Build TS
run: npm run build:ts

- name: Run linting (ESlint and Prettier)
run: npm run lint --ws
run: npm run lint

- name: Build
run: npm run build -ws
run: npm run build

- name: Test
run: npm run test
1 change: 0 additions & 1 deletion docs/snippets/gettingStarted/webApi/apiSetup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { shoppingCartApi } from './simpleApi';

Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
"build": "npm run build:ts && npm run build --ws",
"build:ts": "tsc -b",
"build:ts:watch": "tsc -b --watch",
"lint": "npm run lint --ws",
"fix": "npm run fix --ws",
"lint": "npm run lint:eslint && npm run lint:prettier",
"lint:prettier": "prettier --check \"**/**/!(*.d).{ts,json,md}\"",
"lint:eslint": "eslint '**/*.ts'",
"fix": "run-s fix:eslint fix:prettier",
"fix:prettier": "prettier --write \"**/**/!(*.d).{ts,json,md}\"",
"fix:eslint": "eslint '**/*.ts' --fix",
"test": "run-s test:unit test:int test:e2e",
"test:unit": "glob -d -c \"node --import tsx --test\" **/*.unit.spec.ts",
"test:int": "glob -d -c \"node --import tsx --test\" **/*.int.spec.ts",
Expand Down
6 changes: 0 additions & 6 deletions packages/emmett-esdb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
"build": "tsup",
"build:ts": "tsc",
"build:ts:watch": "tsc --watch",
"lint": "npm run lint:eslint && npm run lint:prettier",
"lint:prettier": "prettier --check \"**/**/!(*.d).{ts,json,md}\"",
"lint:eslint": "eslint **/*.ts",
"fix": "run-s fix:eslint fix:prettier",
"fix:prettier": "prettier --write \"**/**/!(*.d).{ts,json,md}\"",
"fix:eslint": "eslint **/*.ts --fix",
"test": "run-s test:unit test:int test:e2e",
"test:unit": "glob -c \"node --import tsx --test\" **/*.unit.spec.ts",
"test:int": "glob -c \"node --import tsx --test\" **/*.int.spec.ts",
Expand Down
3 changes: 3 additions & 0 deletions packages/emmett-esdb/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those dummy files are needed for vscode eslint plugin, as it runs eslint config locally for packages. And as in the file, we have a reference for tsconfig.eslint.json. Then if it won't find such a file in the local package folder, then it will cry out loud and doesn't highlight eslint errors.

"extends": "./tsconfig.json"
}
6 changes: 0 additions & 6 deletions packages/emmett-expressjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
"build": "tsup",
"build:ts": "tsc",
"build:ts:watch": "tsc --watch",
"lint": "npm run lint:eslint && npm run lint:prettier",
"lint:prettier": "prettier --check \"**/**/!(*.d).{ts,json,md}\"",
"lint:eslint": "eslint **/*.ts",
"fix": "run-s fix:eslint fix:prettier",
"fix:prettier": "prettier --write \"**/**/!(*.d).{ts,json,md}\"",
"fix:eslint": "eslint **/*.ts --fix",
"test": "run-s test:unit test:int test:e2e",
"test:unit": "glob -c \"node --import tsx --test\" **/*.unit.spec.ts",
"test:int": "glob -c \"node --import tsx --test\" **/*.int.spec.ts",
Expand Down
2 changes: 0 additions & 2 deletions packages/emmett-expressjs/src/etag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ export const setETag = (response: Response, etag: ETag): void => {
};

export const getETagValueFromIfMatch = (request: Request): string => {
// TODO: https://github.com/event-driven-io/emmett/issues/18
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const eTagValue: ETag = getETagFromIfMatch(request);

return isWeakETag(eTagValue)
Expand Down
6 changes: 0 additions & 6 deletions packages/emmett-expressjs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ export const sendCreated = (
send(response, 201, {
location: `${urlPrefix ?? response.req.url}/${createdId}`,
body: { id: createdId },
// TODO: https://github.com/event-driven-io/emmett/issues/18
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
eTag,
});

Expand All @@ -145,8 +143,6 @@ export const send = (
statusCode: number,
options?: HttpResponseOptions,
): void => {
// TODO: https://github.com/event-driven-io/emmett/issues/18
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { location, body, eTag } = options ?? DefaultHttpResponseOptions;
// HEADERS
if (eTag) setETag(response, eTag);
Expand All @@ -167,8 +163,6 @@ export const sendProblem = (
): void => {
options = options ?? DefaultHttpProblemResponseOptions;

// TODO: https://github.com/event-driven-io/emmett/issues/18
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { location, eTag } = options;

const problemDetails =
Expand Down
3 changes: 3 additions & 0 deletions packages/emmett-expressjs/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./tsconfig.json"
}
6 changes: 0 additions & 6 deletions packages/emmett-fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
"build": "tsup",
"build:ts": "tsc",
"build:ts:watch": "tsc --watch",
"lint": "npm run lint:eslint && npm run lint:prettier",
"lint:prettier": "prettier --check \"**/**/!(*.d).{ts,json,md}\"",
"lint:eslint": "eslint **/*.ts",
"fix": "run-s fix:eslint fix:prettier",
"fix:prettier": "prettier --write \"**/**/!(*.d).{ts,json,md}\"",
"fix:eslint": "eslint **/*.ts --fix",
"test": "run-s test:unit test:int test:e2e",
"test:unit": "glob -c \"node --import tsx --test\" **/*.unit.spec.ts",
"test:int": "glob -c \"node --import tsx --test\" **/*.int.spec.ts",
Expand Down
3 changes: 3 additions & 0 deletions packages/emmett-fastify/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./tsconfig.json"
}
6 changes: 0 additions & 6 deletions packages/emmett-testcontainers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
"build": "tsup",
"build:ts": "tsc",
"build:ts:watch": "tsc --watch",
"lint": "npm run lint:eslint && npm run lint:prettier",
"lint:prettier": "prettier --check \"**/**/!(*.d).{ts,json,md}\"",
"lint:eslint": "eslint **/*.ts",
"fix": "run-s fix:eslint fix:prettier",
"fix:prettier": "prettier --write \"**/**/!(*.d).{ts,json,md}\"",
"fix:eslint": "eslint **/*.ts --fix",
"test": "run-s test:unit test:int test:e2e",
"test:unit": "glob -c \"node --import tsx --test\" **/*.unit.spec.ts",
"test:int": "glob -c \"node --import tsx --test\" **/*.int.spec.ts",
Expand Down
3 changes: 3 additions & 0 deletions packages/emmett-testcontainers/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./tsconfig.json"
}
6 changes: 0 additions & 6 deletions packages/emmett/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
"build": "tsup",
"build:ts": "tsc",
"build:ts:watch": "tsc --watch",
"lint": "npm run lint:eslint && npm run lint:prettier",
"lint:prettier": "prettier --check \"**/**/!(*.d).{ts,json,md}\"",
"lint:eslint": "eslint **/*.ts",
"fix": "run-s fix:eslint fix:prettier",
"fix:prettier": "prettier --write \"**/**/!(*.d).{ts,json,md}\"",
"fix:eslint": "eslint **/*.ts --fix",
"test": "run-s test:unit test:int test:e2e",
"test:unit": "glob -c \"node --import tsx --test\" **/*.unit.spec.ts",
"test:int": "glob -c \"node --import tsx --test\" **/*.int.spec.ts",
Expand Down
3 changes: 3 additions & 0 deletions packages/emmett/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./tsconfig.json"
}
9 changes: 9 additions & 0 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.shared.json",
"include": ["./packages/**/*.ts", "./docs/**/*.ts", "./tsup.config.ts"],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eslint seems not to deal well with the project references. But they're needed to correctly resolve correctly dependencies by TypeScript. That's why, as a workaround, I added a dedicated file that removes dependencies but adds "./packages/**/*.ts". It's weird, but it works...

"exclude": ["node_modules", "tmp"],
"files": [],
"compilerOptions": {
"noEmit": true /* Do not emit outputs. */
}
}
1 change: 1 addition & 0 deletions tsconfig.shared.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"exclude": ["**/node_modules", "**/tmp", "**/dist", "**/lib"],
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */

Expand Down