Skip to content

Commit

Permalink
Merge a2ec5b0 into eef13eb
Browse files Browse the repository at this point in the history
  • Loading branch information
milosbugarinovic committed May 22, 2023
2 parents eef13eb + a2ec5b0 commit e5b6f69
Show file tree
Hide file tree
Showing 34 changed files with 18,110 additions and 15,047 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/.idea
/!.idea/runConfigurations
/.base-frame-tmp
/coverage
/node_modules
/packages
/test/node_modules
11 changes: 8 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
root = true

[*]
indent_style = space
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
Expand All @@ -15,8 +15,13 @@ trim_trailing_whitespace = false

[{*.ts, *.js}]
ij_visual_guides = 130
ij_typescript_use_double_quotes = false
ij_javascript_force_semicolon_style = false
ij_typescript_import_prefer_absolute_path = true
ij_typescript_use_path_mapping = always
ij_typescript_force_semicolon_style = false
ij_typescript_force_quote_style = true
ij_typescript_enforce_trailing_comma = whenmultiline
ij_typescript_use_double_quotes = false
ij_typescript_use_semicolon_after_statement = false
ij_typescript_spaces_within_imports = true

ij_typescript_import_prefer_absolute_path = true
5 changes: 4 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/.base-frame-tmp
/.idea
/.semaphore
/coverage
/lib
/node_modules
/resource
.eslintrc.js
/packages
.*.js
/jest*.config.js
237 changes: 130 additions & 107 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,117 +1,140 @@
const namingConvention = () => {
const helper = (selector, format, types) => {
return [
{ selector, format, types, modifiers: ['public'], leadingUnderscore: 'forbid' }, // filter: filterIgnoreUnderscores },
{ selector, format, types, modifiers: ['protected'], leadingUnderscore: 'require' },
{ selector, format, types, modifiers: ['private'], prefix: ['__'] },
]
}
return [
// prettier-ignore
return [
{ selector: ['default'], format: null, modifiers: ['public'], leadingUnderscore: 'forbid' },
{ selector: ['default'], format: ['camelCase'], modifiers: ['protected'], leadingUnderscore: 'require' },
{ selector: ['default'], format: ['camelCase'], modifiers: ['private'], prefix: ['__'] },
...helper(['accessor'], ['camelCase']),
{ selector: ['accessor'], format: ['camelCase'], modifiers: ['public'], leadingUnderscore: 'forbid' },
{ selector: ['accessor'], format: ['camelCase'], modifiers: ['protected'], leadingUnderscore: 'require' },
{ selector: ['accessor'], format: ['camelCase'], modifiers: ['private'], prefix: ['__'] },
{ selector: ['enum'], format: ['PascalCase'] },
{ selector: ['enumMember'], format: ['UPPER_CASE'] },
{ selector: ['classMethod', 'accessor'], modifiers: ['public', 'static'], format: ['PascalCase'] },
{ selector: ['classProperty'], modifiers: ['public', 'static'], format: ['UPPER_CASE'] },
{ selector: ['classMethod', 'accessor'], format: ['PascalCase'], modifiers: ['public', 'static'] },
{ selector: ['classProperty'], format: ['UPPER_CASE'], modifiers: ['public', 'static'] },
]
}

const config = {
root: true,
settings: {
'import/ignore': ['react-native'],
'import/resolver': {
node: {
paths: ['./'],
},
},
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'prettier',
],
env: {
es6: true,
node: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
plugins: ['@typescript-eslint', 'eslint-plugin-import', 'import', 'no-only-tests', 'prettier', 'no-loops'],
rules: {
curly: 'error',
'no-loops/no-loops': 'error',
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: '*', next: 'return' },
{ blankLine: 'always', prev: '*', next: ['cjs-export', 'export'] },
],
'no-only-tests/no-only-tests': 'error',
'prettier/prettier': 'error',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['**/index'],
message: 'Please use `.../something` instead of ``.../something/index`',
},
],
},
],
'@typescript-eslint/ban-ts-comment': ['warn'],
'@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
'@typescript-eslint/naming-convention': ['error', ...namingConvention()],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
'arrow-parens': 'error',
'import/namespace': [
'error',
{
allowComputed: true,
},
],
'import/newline-after-import': 'error',
'import/no-unresolved': 'off',
'import/order': [
'error',
{
alphabetize: {
caseInsensitive: false,
order: 'asc',
},
groups: [['index', 'sibling', 'parent', 'internal', 'external', 'builtin', 'object']],
'newlines-between': 'always',
},
],
'no-console': 'error',
'no-duplicate-imports': 'error',
'prefer-template': 'error',
quotes: [
'error',
'single',
{
avoidEscape: true,
allowTemplateLiterals: true,
},
],
semi: ['error', 'never'],
'sort-imports': [
'error',
{
ignoreDeclarationSort: true,
},
],
},
module.exports = {
root: true,
env: {
es6: true,
'jest/globals': true,
node: true,
},
settings: {
'import/resolver': {
node: {
paths: ['./'],
},
},
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/strict',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:prettier/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'ESNext',
project: './tsconfig-eslint.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'eslint-plugin-import', 'import', 'no-only-tests', 'no-loops', 'jest', 'sort-keys-fix'],
rules: {
// ESLINT
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['**/index'],
message: 'Please use `.../something` instead of ``.../something/index`',
},
],
},
],

'prefer-arrow-callback': 'error',
'no-confusing-arrow': 'error',
'no-constant-condition': 'error',

'no-ternary': 'error',
'padding-line-between-statements': [
'error',
{ blankLine: 'always', next: 'return', prev: '*' },
{ blankLine: 'always', next: ['cjs-export', 'export'], prev: '*' },
],
'prefer-template': 'error',
'sort-imports': [
'error',
{
ignoreDeclarationSort: true,
},
],

// NO_LOOPS
'no-loops/no-loops': 'error',

// DISABLE STRICT
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
'@typescript-eslint/naming-convention': ['error', ...namingConvention()],

// TYPESCRIPT
'@typescript-eslint/ban-ts-comment': ['warn', { 'ts-expect-error': 'allow-with-description' }],
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{ argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_', destructuredArrayIgnorePattern: '^_', varsIgnorePattern: '^_' },
],

// IMPORT
'import/namespace': [
'error',
{
allowComputed: true,
},
],
'import/newline-after-import': 'error',
'import/no-unresolved': 'off',
'import/order': [
'error',
{
alphabetize: {
caseInsensitive: false,
order: 'asc',
},
groups: [['index', 'sibling', 'parent', 'internal', 'external', 'builtin', 'object']],
'newlines-between': 'always',
},
],

// JEST
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error',
'no-console': 'error',
'no-duplicate-imports': 'error',

//NO_ONLY_TESTS
'no-only-tests/no-only-tests': 'error',

// SORT_KEYS_FIX
'sort-keys-fix/sort-keys-fix': ['error', 'asc', { caseSensitive: false, natural: true }],

// PRETTIER
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
curly: 'error',
'no-mixed-spaces-and-tabs': 'error',
},
}
module.exports = config
25 changes: 25 additions & 0 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Lint-Test

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
lint-test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set Node.js version
run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- run: npm ci
- run: npm run lint
- run: npm run test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/.idea
/!.idea/runConfigurations
/.base-frame-tmp
/coverage
/node_modules
/packages
/test/node_modules
/test/dist
5 changes: 2 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
# npm run lint
4 changes: 3 additions & 1 deletion .ncurc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"reject": []
"reject": [
"typescript"
]
}
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
/lib
/node_modules
/resource
package.json
/packages
package-lock.json
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false
"useTabs": true
}
6 changes: 6 additions & 0 deletions jest-int.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const sharedConfig = require('./jest.config.js')

module.exports = {
...sharedConfig,
testMatch: ['<rootDir>/src/**/__tests__/*.test.ts'],
}
6 changes: 6 additions & 0 deletions jest-unit.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const sharedConfig = require('./jest.config.js')

module.exports = {
...sharedConfig,
testPathIgnorePatterns: [...sharedConfig.testPathIgnorePatterns, '/__tests__/'],
}
16 changes: 16 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
collectCoverage: false,
collectCoverageFrom: ['src/**/*.ts', '!src/index.ts', '!src/**/*.{contract,d}.ts'],
coveragePathIgnorePatterns: ['/node_modules/', '/__tests__/', '/__mocks__/', '/__snapshots__/'],
maxConcurrency: 1,
moduleNameMapper: {
'^src/(.*)$': '<rootDir>/src/$1',
},
moduleFileExtensions: ['js', 'ts'],
preset: 'ts-jest',
roots: ['<rootDir>/src'],
setupFilesAfterEnv: ['jest-extended/all'],
testEnvironment: 'node',
testMatch: ['<rootDir>/src/**/*.test.ts'],
testPathIgnorePatterns: ['/node_modules/'],
}

0 comments on commit e5b6f69

Please sign in to comment.