-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(workspace): reducing typescript config complexity (#647)
#### What this PR does / why we need it: As per title.
- Loading branch information
Showing
25 changed files
with
330 additions
and
436 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
module.exports = { | ||
plugins: ['simple-import-sort', 'check-file', 'unused-imports', 'no-only-tests'], | ||
extends: ['airbnb-base', 'airbnb-typescript/base', 'prettier'], | ||
ignorePatterns: ['dist', 'node_modules'], | ||
rules: { | ||
'class-methods-use-this': 'off', | ||
'max-classes-per-file': 'off', | ||
'no-use-before-define': 'off', | ||
'no-console': 'error', | ||
|
||
// https://github.com/airbnb/javascript/issues/1271 | ||
'no-restricted-syntax': 'off', | ||
|
||
'no-await-in-loop': 'off', | ||
|
||
// import | ||
'import/no-extraneous-dependencies': 'off', | ||
'import/prefer-default-export': 'off', | ||
'import/no-default-export': 'error', | ||
|
||
// simple-import-sort | ||
'simple-import-sort/imports': 'error', | ||
'simple-import-sort/exports': 'error', | ||
|
||
/** | ||
* Enforce PascalCase for filenames. | ||
*/ | ||
'check-file/filename-naming-convention': [ | ||
'error', | ||
{ | ||
'src/**/*.{js,jsx,tsx,ts}': 'PASCAL_CASE', | ||
}, | ||
{ | ||
ignoreMiddleExtensions: true, | ||
}, | ||
], | ||
|
||
'@typescript-eslint/no-throw-literal': 'warn', | ||
|
||
'@typescript-eslint/no-floating-promises': 'error', | ||
'no-void': [ | ||
'error', | ||
{ | ||
allowAsStatement: true, | ||
}, | ||
], | ||
|
||
// @typescript-eslint | ||
'@typescript-eslint/no-use-before-define': 'off', | ||
|
||
/** | ||
* Separates out the `no-unused-vars` rule depending on it being an import statement in the AST and providing | ||
* an auto-fix rule to remove the nodes if they are imports. | ||
* With this, we can now target test files with `'unused-imports/no-unused-vars': 'off'` for testing DX. | ||
*/ | ||
'@typescript-eslint/no-unused-vars': 'off', | ||
'unused-imports/no-unused-imports': 'error', | ||
'unused-imports/no-unused-vars': 'error', | ||
|
||
/** | ||
* Do not use ambiguous identifiers like `id`, use context identifiers like `userId` or `postId` instead. | ||
* Please do not ignore this rule completely, for scenarios where you need to use `id` as a variable name, | ||
* use `// eslint-disable-next-line no-restricted-properties` to disable this rule for that line. | ||
*/ | ||
'no-restricted-properties': [ | ||
'error', | ||
{ | ||
property: 'id', | ||
message: | ||
'Do not use ambiguous identifiers like `id`, use context identifiers like `userId` or `postId` instead.', | ||
}, | ||
], | ||
|
||
/** | ||
* disallow .only to be used in tests | ||
*/ | ||
'no-only-tests/no-only-tests': 'error', | ||
}, | ||
env: { | ||
node: true, | ||
jest: true, | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['**/*.unit.ts', '**/*.i9n.ts', '**/*.e2e.ts'], | ||
rules: { | ||
/** | ||
* To cater for complex test scenarios, where we need to scope blocks. This allows variables to be reused, | ||
* so we don't have to create `const getObject` and `const updatedObject` for each scenario. | ||
* We can just use `const object`. | ||
*/ | ||
'no-lone-blocks': 'off', | ||
|
||
/** | ||
* Separates out the `no-unused-vars` rule depending on it being an import statement in the AST and providing | ||
* an auto-fix rule to remove the nodes if they are imports. | ||
* With this, we can now target test files with `'unused-imports/no-unused-vars': 'off'` for testing DX. | ||
*/ | ||
'unused-imports/no-unused-imports': 'error', | ||
'unused-imports/no-unused-vars': 'off', | ||
}, | ||
}, | ||
{ | ||
/** | ||
* Enforce PascalCase for filenames, ignoring common files like `index.ts`, `cli.ts`, `main.ts`. | ||
*/ | ||
files: ['**/{index,cli}.ts'], | ||
rules: { | ||
'check-file/filename-naming-convention': ['off'], | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,3 @@ | ||
# Hosting Dev Tools | ||
public-hoist-pattern[]=husky | ||
public-hoist-pattern[]=lint-staged | ||
public-hoist-pattern[]=typescript | ||
public-hoist-pattern[]=turbo | ||
public-hoist-pattern[]=*jest* | ||
public-hoist-pattern[]=*eslint* | ||
public-hoist-pattern[]=*prettier* | ||
public-hoist-pattern[]=@types/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,11 +19,27 @@ | |
"lint-staged": { | ||
"*": "prettier --write --ignore-unknown" | ||
}, | ||
"prettier": "@stickyjs/prettier", | ||
"devDependencies": { | ||
"@stickyjs/eslint-config": "1.3.4", | ||
"@stickyjs/prettier": "1.3.4", | ||
"turbo": "^1.10.16" | ||
"@typescript-eslint/eslint-plugin": "^6.7.0", | ||
"@typescript-eslint/parser": "^6.7.0", | ||
"@workspace/jest-preset": "workspace:*", | ||
"@workspace/tsconfig": "workspace:*", | ||
"eslint": "^8.49.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-airbnb-typescript": "^17.1.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-check-file": "^2.6.2", | ||
"eslint-plugin-import": "^2.28.1", | ||
"eslint-plugin-no-only-tests": "^3.1.0", | ||
"eslint-plugin-simple-import-sort": "^10.0.0", | ||
"eslint-plugin-unused-imports": "^3.0.0", | ||
"husky": "^8.0.3", | ||
"lint-staged": "^14.0.1", | ||
"prettier": "^3.0.3", | ||
"prettier-plugin-packagejson": "^2.4.5", | ||
"prettier-plugin-tailwindcss": "^0.4.1", | ||
"turbo": "^1.10.16", | ||
"typescript": "5.2.2" | ||
}, | ||
"packageManager": "[email protected]", | ||
"engines": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"extends": "@workspace/tsconfig", | ||
"compilerOptions": { | ||
"outDir": "dist" | ||
}, | ||
"include": ["src"], | ||
"exclude": ["**/*.unit.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "./dist" | ||
}, | ||
"include": ["src"] | ||
"extends": "@workspace/tsconfig" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"extends": "@workspace/tsconfig", | ||
"compilerOptions": { | ||
"outDir": "dist" | ||
}, | ||
"include": ["src"], | ||
"exclude": ["**/*.unit.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "./dist" | ||
}, | ||
"include": ["src"] | ||
"extends": "@workspace/tsconfig" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"extends": "@workspace/tsconfig", | ||
"compilerOptions": { | ||
"outDir": "dist" | ||
}, | ||
"include": ["src"], | ||
"exclude": ["**/*.unit.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "./dist" | ||
}, | ||
"include": ["src"] | ||
"extends": "@workspace/tsconfig" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"extends": "@workspace/tsconfig", | ||
"compilerOptions": { | ||
"outDir": "dist" | ||
}, | ||
"include": ["src"], | ||
"exclude": ["**/*.unit.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "./dist" | ||
}, | ||
"include": ["src"] | ||
"extends": "@workspace/tsconfig" | ||
} |
Oops, something went wrong.