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

refactor!: es modules and commonjs build #1

Merged
merged 26 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
69b5552
refactor!: es modules and commonjs build
milosbugarinovic Jul 19, 2023
fc97ff0
chore: remove esm support
milosbugarinovic Jul 27, 2023
21169fe
chore: revert to commonJs
milosbugarinovic Aug 26, 2023
59ac320
chore: esm and cjs build
milosbugarinovic Dec 3, 2023
20bd826
chore: jest fix
milosbugarinovic Mar 6, 2024
bf98fc8
test: fix tests
milosbugarinovic Mar 11, 2024
2ce6a0e
chore: update packages
milosbugarinovic Mar 12, 2024
8a1872c
chore: fix build scripts
milosbugarinovic Mar 12, 2024
8b83fb6
chore: remove cjs build
milosbugarinovic Mar 15, 2024
65fa104
chore: fix eslint
milosbugarinovic Mar 15, 2024
006103d
fix: jest to use esmodule
milosbugarinovic Mar 16, 2024
491a90f
chore: fix jest esmodule tests
milosbugarinovic Mar 18, 2024
c2c05a5
chore: add jasmine
milosbugarinovic Mar 19, 2024
645731f
test: fix jest esmodule import
milosbugarinovic Mar 20, 2024
16c109e
chore: fix imports/exports
milosbugarinovic Mar 20, 2024
dd0bc78
chore: fix tests
milosbugarinovic Mar 21, 2024
1a0689e
chore: fix tests
milosbugarinovic Mar 21, 2024
c117c8e
chore: lint fix and update package.json
milosbugarinovic Mar 21, 2024
28b7096
chore: add package-lock.json files, cleanup
milosbugarinovic Mar 22, 2024
aab3c37
chore: fix build script and docker image
milosbugarinovic Mar 22, 2024
f64884d
chore: updated build process cjs vs esm
milosbugarinovic Apr 5, 2024
6a1ac30
chore: fix dual build cjs and esm
milosbugarinovic Apr 6, 2024
4a896b7
chore: update package-lock.json
milosbugarinovic Apr 6, 2024
05cbddf
chore: update jest config
milosbugarinovic Apr 6, 2024
9f6df8d
fix: esmodule build output alias path to relative
milosbugarinovic Apr 7, 2024
8e6e1b6
chore: add gh actions lint-test script
milosbugarinovic Apr 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/.idea
/!.idea/runConfigurations
/.base-frame-tmp
/coverage
/dist
/lib
/node_modules
/packages
/test/node_modules
/test/dist
*.tsbuildinfo
26 changes: 25 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,26 @@
root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
max_line_length = 130
indent_size = 2
insert_final_newline = true
tab_width = 2

[*.md]
trim_trailing_whitespace = false

[{*.ts, *.js}]
ij_typescript_import_prefer_absolute_path = false
ij_visual_guides = 130
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
24 changes: 15 additions & 9 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
.base-frame-tmp
.idea
.nyc_output
.semaphore
coverage
lib
node_modules
resource
unit.test.js
/.base-frame-tmp
/.idea
/.semaphore
/coverage
/dist
/lib
/node_modules
/resource
/packages
.*.js
.*.json
package-lock.json
tsconfig*.json
typedoc.json
jest.config*.ts
145 changes: 145 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
const namingConvention = () => {
// 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: ['__'] },
{ 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'], format: ['PascalCase'], modifiers: ['public', 'static'] },
{ selector: ['classProperty'], format: ['UPPER_CASE'], modifiers: ['public', 'static'] },

]
}

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: './resource/tsconfig/eslint.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'eslint-plugin-import', 'import', 'no-only-tests', 'no-loops', 'jest', 'sort-keys-fix'],
rules: {
// TODO TEMP DISABLE
'@typescript-eslint/no-explicit-any':'warn',
// ESLINT
// 'no-restricted-imports': [
// 'error',
// {
// patterns: [
// {
// group: ['**/index'],
// message: 'Please use `.../something` instead of ``.../something/index`',
// },
// ],
// },
// ],
'@typescript-eslint/prefer-ts-expect-error': 'off',
'prefer-arrow-callback': 'error',
'no-confusing-arrow': 'error',
'no-constant-condition': 'error',

'no-ternary': 'warn', // TODO temp warn, revert to error
'@typescript-eslint/no-var-requires': 'warn', // TODO temp warn, remove and use default value

'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': ['warn', ...namingConvention()], // TODO temp warn, revert to error

// 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',
},
}
106 changes: 0 additions & 106 deletions .eslintrc.json

This file was deleted.

2 changes: 2 additions & 0 deletions .git-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pull]
rebase = true
24 changes: 24 additions & 0 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Lint-Test

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

jobs:
lint-test:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: "npm"
- run: npm ci
- run: npm run lint
- run: npm run test:unit
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.base-frame-tmp
.vscode
.nyc_output
coverage
node_modules
/.idea
/!.idea/runConfigurations
/.base-frame-tmp
/coverage
/node_modules
/packages
/test/node_modules
/test/dist
*.tsbuildinfo
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit "$1"
4 changes: 2 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
. "$(dirname "$0")/_/husky.sh"

npm run lint
npx lint-staged
5 changes: 5 additions & 0 deletions .ncurc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"reject": [
"semantic-release"
]
}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.11.1
Loading
Loading