Skip to content

Commit

Permalink
fix(#9): Module error when using Javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
m-t-a97 committed Jan 15, 2025
1 parent e06e529 commit e9a2f73
Show file tree
Hide file tree
Showing 16 changed files with 3,803 additions and 2,504 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ python/venv
### Javascript
javascript/gradle.properties
javascript/node_modules/*
dist/
1 change: 1 addition & 0 deletions javascript/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/jod
9 changes: 9 additions & 0 deletions javascript/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"bracketSameLine": false,
"bracketSpacing": true,
"printWidth": 120,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5"
}
50 changes: 50 additions & 0 deletions javascript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Kestra JavaScript Libs

This project includes the following tools:

- [Prettier](https://prettier.io/): Formatting
- [Eslint](https://eslint.org/): Linting
- [Vitest](https://vitest.dev/): Testing
- [Rollup](https://rollupjs.org/): Bundling

---

### Development

```bash
# Install dependencies
$ npm i
```

---

### Testing

```bash
# Runs vitest
$ npm run test

# Runs vitest with GUI
$ npm run test:ui
```

You can test this library using npm symlinks before publishing to npm.

This can be done using the following steps:

```bash
# Create a symlink for this project to global node_modules
$ npm link

# Lists all global symlinks. You can also use this command to check if your symlink worked.
$ npm ls -g --depth=0 --link=true

# Navigate to a different project and symlink this project. NOTE: that project must also be using npm as a package manager.
$ npm link @kestra-io/libs

# Once you are done with testing, you can remove the symlink. NOTE: this will also remove the dependency in package.json so you will need to reinstall the package again.
$ npm unlink @kestra-io/libs

# Unlink the package globally to remove the symlink
$ npm unlink --global @kestra-io/libs
```
69 changes: 69 additions & 0 deletions javascript/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import prettier from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import pluginJs from '@eslint/js';

export default [
{
ignores: ['.pnpm-store/**', 'coverage/**', '**/dist/**', '**/*.d.ts', 'node_modules/**'],
},
{
languageOptions: {
globals: {
...globals.node,
...globals.browser,
...globals.jest,
...globals.es2015,
},
parserOptions: {
parser: tseslint.parser,
},
},
},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
prettier,
{
files: ['src/**/*.ts'],
ignores: ['**/*.spec.ts'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
'no-implicit-coercion': 'error',
'no-warning-comments': [
'warn',
{
terms: ['TODO', 'FIXME', 'XXX', 'BUG'],
location: 'anywhere',
},
],
curly: ['error', 'all'],
eqeqeq: ['error', 'always', { null: 'ignore' }],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/no-require-imports': 'warn',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'warn',
'@typescript-eslint/no-inferrable-types': 'warn',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/naming-convention': [
'error',
{ selector: 'variable', format: ['camelCase', 'UPPER_CASE', 'PascalCase'], leadingUnderscore: 'allow' },
{ selector: 'function', format: ['camelCase', 'PascalCase'] },
{ selector: 'interface', format: ['PascalCase'] },
{ selector: 'typeAlias', format: ['PascalCase'] },
],
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true, caughtErrors: 'none' }],
},
},
];
Loading

0 comments on commit e9a2f73

Please sign in to comment.