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

[Major version] Update packages, rewrite tests, fix code #17

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.eslintrc.cjs
node_modules/
project.d.ts
dist/
103 changes: 103 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
ecmaVersion: 2020,
sourceType: 'module',
},
extends: ['prettier'],
plugins: ['@typescript-eslint', 'unused-imports'],
rules: {
'unused-imports/no-unused-imports': 'error',
'array-callback-return': ['error'],
'getter-return': ['error'],
'no-async-promise-executor': ['error'],
'no-class-assign': ['error'],
'no-cond-assign': ['error'],
'no-constant-binary-expression': ['error'],
'no-constant-condition': ['error'],
'no-constructor-return': ['error'],
'no-debugger': ['error'],
'no-dupe-args': ['error'],
'no-dupe-class-members': ['error'],
'no-dupe-else-if': ['error'],
'no-dupe-keys': ['error'],
'no-duplicate-case': ['error'],
'no-duplicate-imports': ['error'],
'no-empty-pattern': ['error'],
'no-ex-assign': ['error'],
'no-fallthrough': ['error'],
'no-func-assign': ['error'],
'no-import-assign': ['error'],
'no-inner-declarations': ['error'],
'no-invalid-regexp': ['error'],
'no-irregular-whitespace': ['error'],
'no-obj-calls': ['error'],
'no-promise-executor-return': ['error'],
'no-self-assign': ['error'],
'no-self-compare': ['error'],
'no-setter-return': ['error'],
'no-template-curly-in-string': ['error'],
'no-unexpected-multiline': ['error'],
'no-unmodified-loop-condition': ['error'],
'no-unreachable': ['error'],
'no-unreachable-loop': ['error'],
'no-unsafe-finally': ['error'],
'no-unsafe-negation': ['error'],
'no-unsafe-optional-chaining': ['error'],
'no-unused-private-class-members': ['error'],
'require-atomic-updates': ['error'],
'use-isnan': ['error'],
'valid-typeof': ['error'],
'no-eval': ['error'],
'no-implied-eval': ['error'],
'no-multi-assign': ['error'],
'no-useless-return': ['error'],
'prefer-const': ['error'],

'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/consistent-type-assertions': [
'error',
{
assertionStyle: 'as',
objectLiteralTypeAssertions: 'allow',
},
],
'@typescript-eslint/member-delimiter-style': ['error'],
'@typescript-eslint/no-confusing-void-expression': ['error', { ignoreArrowShorthand: true }],
'@typescript-eslint/no-extra-non-null-assertion': ['error'],
'@typescript-eslint/no-extraneous-class': ['error'],
'@typescript-eslint/no-inferrable-types': ['error'],
'@typescript-eslint/no-invalid-void-type': ['error'],
'@typescript-eslint/no-misused-new': ['error'],
'@typescript-eslint/no-unnecessary-type-arguments': ['error'],
'@typescript-eslint/no-unnecessary-type-assertion': ['error'],
'@typescript-eslint/no-unnecessary-type-constraint': ['error'],
'@typescript-eslint/no-var-requires': ['error'],
'@typescript-eslint/prefer-for-of': ['error'],
'@typescript-eslint/prefer-includes': ['error'],
'@typescript-eslint/prefer-nullish-coalescing': ['error'],
'@typescript-eslint/prefer-readonly': ['error'],
'@typescript-eslint/prefer-string-starts-ends-with': ['error'],
'@typescript-eslint/prefer-ts-expect-error': ['error'],
'@typescript-eslint/require-array-sort-compare': ['error', { ignoreStringArrays: true }],
'@typescript-eslint/restrict-plus-operands': ['error'],
'@typescript-eslint/switch-exhaustiveness-check': ['error'],
'@typescript-eslint/no-invalid-this': ['error'],
'@typescript-eslint/no-shadow': ['error'],
'@typescript-eslint/no-unused-expressions': ['error'],
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-use-before-define': [
'error',
{ functions: false, classes: false, variables: true },
],
'@typescript-eslint/no-useless-constructor': ['error'],
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': ['error'],
},
};
31 changes: 31 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Unit tests, static analysis, code style

on:
workflow_dispatch:
push:

jobs:
checkPr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'

- name: Install packages
run: yarn install --prefer-offline --frozen-lockfile

- name: Run lint
run:
yarn lint

- name: Run typecheck
run:
yarn typecheck

- name: Run unit tests
run:
yarn test
58 changes: 58 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,60 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

.idea/

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.eslintrc.cjs
node_modules/
project.d.ts
dist/
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"jsxSingleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"arrowParens": "always"
}
23 changes: 23 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { SimpleTranslation, ContextualTranslation, PluralTranslation, PluralContextualTranslation } from './src/types';
import { TranslationController } from './src/controller';
export { TranslationController } from './src/controller';
export declare const _tGen: (ctrl: TranslationController) => SimpleTranslation;
export declare const _ptGen: (ctrl: TranslationController) => ContextualTranslation;
export declare const _ntGen: (ctrl: TranslationController) => PluralTranslation;
export declare const _nptGen: (ctrl: TranslationController) => PluralContextualTranslation;
export declare const _ggGen: (ctrl: TranslationController) => SimpleTranslation;
export declare const _pggGen: (ctrl: TranslationController) => ContextualTranslation;
export declare const _nggGen: (ctrl: TranslationController) => PluralTranslation;
export declare const _npggGen: (ctrl: TranslationController) => PluralContextualTranslation;
export declare class TranslationProvider {
private readonly ctrl;
constructor(ctrl: TranslationController);
_t: SimpleTranslation;
_pt: ContextualTranslation;
_nt: PluralTranslation;
_npt: PluralContextualTranslation;
_gg: SimpleTranslation;
_pgg: ContextualTranslation;
_ngg: PluralTranslation;
_npgg: PluralContextualTranslation;
}
64 changes: 37 additions & 27 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading