Skip to content

Commit

Permalink
feat(setup): init project
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine ZANARDI committed Feb 27, 2023
1 parent 4ff4478 commit b483e56
Show file tree
Hide file tree
Showing 33 changed files with 13,365 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = false
indent_style = space
indent_size = 2
max_line_length = 150
34 changes: 34 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { importRules } = require("./config/eslint/rules/import");
const { configFilesOverride } = require("./config/eslint/rules/overrides/config-files");
const { eslintConfigFilesOverride } = require("./config/eslint/rules/overrides/eslint-config-files");
const { testFilesOverride } = require("./config/eslint/rules/overrides/test-files");
const { standardRules } = require("./config/eslint/rules/standard");
const { typescriptRules } = require("./config/eslint/rules/typescript");

module.exports = {
root: true,
env: {
node: true,
jest: true,
},
parser: "@typescript-eslint/parser",
extends: ["plugin:@typescript-eslint/recommended"],
plugins: ["@typescript-eslint", "import"],
ignorePatterns: ["node_modules/", "dist/"],
parserOptions: {
parser: "@typescript-eslint/parser",
ecmaVersion: 2022,
project: "./tsconfig.json",
sourceType: "module",
},
rules: {
...standardRules,
...typescriptRules,
...importRules,
},
overrides: [
eslintConfigFilesOverride,
configFilesOverride,
testFilesOverride,
],
};
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Werewolves Assistant API Build Workflow
on:
pull_request:
branches:
- 'main'
- 'develop'
push:
branches:
- 'main'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Setup GitHub repository 🔧
uses: actions/checkout@v3
- name: Setup NodeJS v18 ✨
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install project dependencies 📦
run: npm ci
- name: Build app ✨
run: npm run build
- name: Check and lint code 🔍
run: npm run lint
- name: Test 💯
run: npm run test:cov
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# compiled output
/dist
/node_modules

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
tests/coverage
tests/**/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx commitlint -g config/commitlint/.commitlintrc.json --edit $1
6 changes: 6 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install validate-branch-name;
npm run lint:staged;
npm test;
4 changes: 4 additions & 0 deletions .validate-branch-namerc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"pattern": "^(main|develop){1}$|^(feat|fix)\/.+$",
"errorMsg": "Your branch name doesn't respect the established convention. Please respect the following format : (feat|fix)/[FEATURE_NAME]\nYou can change the name of your branch with the command `git branch -m NEW_NAME`"
}
5 changes: 5 additions & 0 deletions config/commitlint/.commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"@commitlint/config-conventional"
]
}
42 changes: 42 additions & 0 deletions config/eslint/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const MAX_LENGTH = 180;
const MAX_NESTED_CALLBACK = 5;
const MAX_PARAMS = 6;
const INDENT_SPACE_COUNT = 2;
const ERROR = "error";
const WARNING = "warn";
const OFF = "off";
const MAX_LENGTH_DEFAULT_CONFIG = {
code: MAX_LENGTH,
ignoreTemplateLiterals: true,
ignorePattern: "d=\"([\\s\\S]*?)\"",
};
const BOOLEAN_PREFIXES = ["is", "was", "should", "has", "can", "does"];
const NAMING_CONVENTION_DEFAULT_CONFIG = [
{
selector: ["enum", "enumMember"],
format: ["UPPER_CASE"],
}, {
selector: ["class", "interface", "typeParameter"],
format: ["PascalCase"],
}, {
selector: ["function", "classProperty", "classMethod", "accessor"],
format: ["camelCase"],
}, {
selector: ["variable", "classProperty"],
types: ["boolean"],
format: ["PascalCase"],
prefix: BOOLEAN_PREFIXES,
},
];

module.exports = {
MAX_LENGTH,
MAX_NESTED_CALLBACK,
MAX_PARAMS,
INDENT_SPACE_COUNT,
ERROR,
WARNING,
OFF,
MAX_LENGTH_DEFAULT_CONFIG,
NAMING_CONVENTION_DEFAULT_CONFIG,
};
103 changes: 103 additions & 0 deletions config/eslint/rules/import.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
const { OFF, ERROR } = require("../constants");

const importRules = Object.freeze({
// ---- ESLint Import Rules -----
// - Static analysis (https://github.com/import-js/eslint-plugin-import#static-analysis)
// TODO: Modify webpack for this
"import/no-unresolved": OFF,
// TODO: Need to check config of this rule
"import/default": ERROR,
"import/named": OFF,
"import/namespace": ERROR,
"import/no-restricted-paths": ERROR,
"import/no-absolute-path": ERROR,
// TODO: Need to check config of this rule
"import/no-dynamic-require": ERROR,
// TODO: Need to check config of this rule
"import/no-internal-modules": ERROR,
"import/no-webpack-loader-syntax": ERROR,
"import/no-self-import": ERROR,
"import/no-cycle": ERROR,
"import/no-useless-path-segments": ERROR,
"import/no-relative-parent-imports": ERROR,
"import/no-relative-packages": ERROR,
// - Helpful warnings (https://github.com/import-js/eslint-plugin-import#helpful-warnings)
"import/export": ERROR,
"import/no-named-as-default": ERROR,
"import/no-named-as-default-member": ERROR,
"import/no-deprecated": ERROR,
"import/no-extraneous-dependencies": ERROR,
"import/no-mutable-exports": ERROR,
"import/no-unused-modules": [ERROR, { unusedExports: true }],
// - Module systems (https://github.com/import-js/eslint-plugin-import#module-systems)
"import/unambiguous": OFF,
"import/no-commonjs": OFF,
"import/no-amd": ERROR,
"import/no-nodejs-modules": ERROR,
"import/no-import-module-exports": ERROR,
// - Style guide (https://github.com/import-js/eslint-plugin-import#style-guide)
"import/first": ERROR,
"import/exports-last": ERROR,
"import/no-duplicates": ERROR,
"import/no-namespace": ERROR,
// TODO: Check this rule config
"import/extensions": OFF,
"import/order": [
ERROR, {
warnOnUnassignedImports: true,
alphabetize: {
order: "asc",
caseInsensitive: true,
},
pathGroups: [
{
pattern: "@+([a-z])/**",
group: "external",
position: "before",
}, {
pattern: "@/models/**",
group: "internal",
position: "after",
}, {
pattern: "@/store/**",
group: "internal",
position: "after",
}, {
pattern: "@/services/**",
group: "internal",
position: "after",
}, {
pattern: "@/components/**",
group: "internal",
position: "after",
}, {
pattern: "@/composables/**",
group: "internal",
position: "after",
}, {
pattern: "@/utils/**",
group: "internal",
position: "after",
},
],
},
],
"import/newline-after-import": ERROR,
"import/prefer-default-export": OFF,
"import/max-dependencies": [
ERROR, {
max: 20,
ignoreTypeImports: true,
},
],
"import/no-unassigned-import": [ERROR, { allow: ["**/*.css"] }],
"import/no-named-default": ERROR,
"import/no-default-export": ERROR,
"import/no-named-export": OFF,
"import/no-anonymous-default-export": OFF,
"import/group-exports": ERROR,
// TODO: Check this rule
"import/dynamic-import-chunkname": OFF,
});

module.exports = { importRules };
8 changes: 8 additions & 0 deletions config/eslint/rules/overrides/config-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { OFF } = require("../../constants");

const configFilesOverride = Object.freeze({
files: ["./config/**/*.ts"],
rules: { "import/no-default-export": OFF },
});

module.exports = { configFilesOverride };
14 changes: 14 additions & 0 deletions config/eslint/rules/overrides/eslint-config-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { OFF } = require("../../constants");

const eslintConfigFilesOverride = Object.freeze({
files: [".eslintrc.js", "config/eslint/**/*.js"],
rules: {
"max-len": OFF,
"@typescript-eslint/no-require-imports": OFF,
"@typescript-eslint/no-var-requires": OFF,
"import/no-commonjs": OFF,
"import/no-internal-modules": OFF,
},
});

module.exports = { eslintConfigFilesOverride };
68 changes: 68 additions & 0 deletions config/eslint/rules/overrides/test-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const { OFF, ERROR } = require("../../constants");

const testFilesOverride = Object.freeze({
files: ["*.e2e-spec.ts", "*.spec.ts"],
plugins: ["jest"],
extends: ["plugin:jest/recommended"],
rules: {
"@typescript-eslint/init-declarations": OFF,
"@typescript-eslint/no-magic-numbers": OFF,
"import/no-namespace": OFF,
// ---- Test Rules -----
// - Supported Rules (https://github.com/jest-community/eslint-plugin-jest#rules)
"jest/consistent-test-it": ERROR,
"jest/expect-expect": ERROR,
"jest/max-expects": ERROR,
"jest/max-nested-describe": ERROR,
"jest/no-alias-methods": ERROR,
"jest/no-commented-out-tests": ERROR,
"jest/no-conditional-expect": ERROR,
"jest/no-deprecated-functions": ERROR,
"jest/no-disabled-tests": ERROR,
"jest/no-done-callback": ERROR,
"jest/no-duplicate-hooks": ERROR,
"jest/no-export": ERROR,
"jest/no-focused-tests": ERROR,
"jest/no-hooks": OFF,
"jest/no-identical-title": ERROR,
// rule below is deprecated
"jest/no-if": OFF,
"jest/no-interpolation-in-snapshots": ERROR,
"jest/no-jasmine-globals": ERROR,
"jest/no-large-snapshots": ERROR,
"jest/no-mocks-import": ERROR,
"jest/no-restricted-jest-methods": OFF,
"jest/no-restricted-matchers": ERROR,
"jest/no-standalone-expect": ERROR,
"jest/no-test-prefixes": ERROR,
"jest/no-test-return-statement": ERROR,
"jest/no-untyped-mock-factory": ERROR,
"jest/prefer-called-with": ERROR,
"jest/prefer-comparison-matcher": ERROR,
"jest/prefer-each": ERROR,
"jest/prefer-equality-matcher": ERROR,
"jest/prefer-expect-assertions": OFF,
"jest/prefer-expect-resolves": ERROR,
"jest/prefer-hooks-in-order": ERROR,
"jest/prefer-hooks-on-top": ERROR,
"jest/prefer-lowercase-title": [ERROR, { ignore: ["describe", "test"] }],
"jest/prefer-mock-promise-shorthand": ERROR,
"jest/prefer-snapshot-hint": ERROR,
"jest/prefer-spy-on": ERROR,
"jest/prefer-strict-equal": ERROR,
"jest/prefer-to-be": ERROR,
"jest/prefer-to-contain": ERROR,
"jest/prefer-to-have-length": ERROR,
"jest/prefer-todo": ERROR,
"jest/require-hook": OFF,
"jest/require-to-throw-message": ERROR,
"jest/require-top-level-describe": ERROR,
"jest/valid-describe-callback": ERROR,
"jest/valid-expect": ERROR,
"jest/valid-expect-in-promise": ERROR,
"jest/valid-title": [ERROR, { mustMatch: { it: new RegExp(/^should .+ when .+\S\.$/u, "u").source } }],
"jest/unbound-method": ERROR,
},
});

module.exports = { testFilesOverride };

0 comments on commit b483e56

Please sign in to comment.