-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61fed7e
commit 72d3df7
Showing
22 changed files
with
6,430 additions
and
1,676 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,119 @@ | ||
const { resolve } = require('path'); | ||
const { readdirSync } = require('fs'); | ||
|
||
module.exports = { | ||
env: { browser: true, es2021: true, jest: true }, | ||
extends: [ | ||
'airbnb-base', | ||
'airbnb-typescript/base', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:prettier/recommended', | ||
'plugin:jest/recommended', | ||
], | ||
ignorePatterns: ['.eslintrc.js'], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 12, | ||
sourceType: 'module', | ||
project: ['./tsconfig.eslint.json'], | ||
}, | ||
plugins: ['@typescript-eslint', 'prettier', 'jest'], | ||
rules: { | ||
/**********/ | ||
/** Style */ | ||
/**********/ | ||
|
||
// Code spacing | ||
'prettier/prettier': 'error', | ||
'arrow-parens': ['error', 'as-needed'], | ||
'@typescript-eslint/indent': 'off', | ||
'padding-line-between-statements': [ | ||
'error', | ||
{ blankLine: 'always', prev: '*', next: 'return' }, | ||
{ blankLine: 'always', prev: '*', next: 'block-like' }, | ||
{ blankLine: 'always', prev: 'block-like', next: '*' }, | ||
], | ||
|
||
// Import order | ||
'sort-imports': ['error', { ignoreDeclarationSort: true }], | ||
'import/order': [ | ||
'error', | ||
{ | ||
groups: [ | ||
'type', | ||
['builtin', 'external'], | ||
['internal', 'sibling', 'parent', 'index', 'object'], | ||
], | ||
'newlines-between': 'always', | ||
alphabetize: { order: 'asc', caseInsensitive: true }, | ||
}, | ||
], | ||
|
||
/***********************************/ | ||
/* Stricter rules than airbnb-base */ | ||
/***********************************/ | ||
|
||
// No unused variables | ||
'@typescript-eslint/no-unused-vars': ['error'], | ||
|
||
// No reassigning function parameters | ||
'no-param-reassign': ['error', { props: false }], | ||
|
||
/**************************************/ | ||
/* Less strict rules than airbnb-base */ | ||
/**************************************/ | ||
|
||
// Allow `function (arg1, arg2) { void arg1; void arg2; }` to work around unused arguments | ||
'no-void': ['error', { allowAsStatement: true }], | ||
|
||
// Allow methods that do not use `this` (notably private methods) | ||
'class-methods-use-this': 'off', | ||
|
||
// Allow imports/exports to go over the max line length | ||
"max-len": [ | ||
"error", | ||
{ "code": 100, "ignorePattern": "^(import|export) .*", "ignoreUrls": true } | ||
], | ||
|
||
// Allow for-of loops | ||
'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'], | ||
|
||
// Allow properties in classes to not have emptry lines between them | ||
'@typescript-eslint/lines-between-class-members': [ | ||
'error', | ||
'always', | ||
{ exceptAfterSingleLine: true }, | ||
], | ||
|
||
// Allow using the console for logging warning, errors, etc. | ||
'no-console': ['error', { allow: ['debug', 'info', 'warn', 'error'] }], | ||
|
||
// Allow `this._id`, `this._name`, etc... (probably for MongoDB) | ||
'no-underscore-dangle': ['error', { allowAfterThis: true }], | ||
|
||
// Consistent return is enforced by typescript. Leaving this on causes double errors. | ||
'consistent-return': 'off', | ||
|
||
// We allow import cycles because they cause no issues for types. | ||
'import/no-cycle': 'off', | ||
}, | ||
overrides: [ | ||
...readdirSync(resolve(__dirname, 'packages')) | ||
.filter(pkg => pkg.substring(0, 1) !== '.') | ||
.map(pkg => ({ | ||
// Per-package configuration | ||
files: [`packages/${pkg}/**/*`], | ||
rules: { | ||
// Allow using dependencies from both the root package.json and the package's package.json | ||
// + only tests can import devDependencies | ||
'import/no-extraneous-dependencies': [ | ||
'error', | ||
{ | ||
packageDir: [__dirname, resolve(__dirname, 'packages', pkg)], | ||
devDependencies: ['**/test/**/*.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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Lint, Build, Test and Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
|
||
jobs: | ||
build: | ||
name: Installing & Building | ||
runs-on: ubuntu-latest | ||
if: "!contains(github.event.head_commit.message, '[skip ci]')" | ||
steps: | ||
- name: Cancel previous running workflows | ||
uses: fkirc/skip-duplicate-actions@master | ||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.14.0 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
node_modules | ||
packages/*/node_modules | ||
key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} | ||
- name: Install | ||
run: yarn | ||
- name: Lint, Test & Build | ||
run: npx nx affected -t lint test build | ||
- uses: actions/cache/save@v3 | ||
with: | ||
path: packages/*/dist | ||
key: ${{ runner.os }}-build-${{ github.sha }} |
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,24 @@ | ||
module.exports = { | ||
branches: [ | ||
'main', | ||
], | ||
plugins: [ | ||
[ | ||
'@semantic-release/commit-analyzer', | ||
{ | ||
preset: 'angular', | ||
releaseRules: [ | ||
// Example: `type(scope): subject [force release]` | ||
{ subject: '*\\[force release\\]*', release: 'patch' }, | ||
], | ||
}, | ||
], | ||
'@semantic-release/npm', | ||
[ | ||
'@semantic-release/git', | ||
{ | ||
message: 'chore(release): ${nextRelease.gitTag} [skip ci]\n\n${nextRelease.notes}', | ||
}, | ||
] | ||
], | ||
}; |
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,12 @@ | ||
import type { Config } from '@jest/types'; | ||
|
||
const config: Config.InitialOptions = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
collectCoverageFrom: [ | ||
'<rootDir>/packages/*/src/**/*.ts', | ||
], | ||
testMatch: ['<rootDir>/packages/*/test/**/*.test.ts'], | ||
setupFilesAfterEnv: ['jest-extended/all'], | ||
}; | ||
export default config; |
Oops, something went wrong.