Skip to content

Commit

Permalink
feat: add support for importing as esm
Browse files Browse the repository at this point in the history
Breaking Change: this changes the import paths for Dyngoose

Fixes #710
  • Loading branch information
benhutchins committed Aug 29, 2024
1 parent ed6e7cd commit ccef67a
Show file tree
Hide file tree
Showing 139 changed files with 4,343 additions and 3,168 deletions.
206 changes: 0 additions & 206 deletions .eslintrc.js

This file was deleted.

4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ jobs:
- name: Lint
run: npm run lint
- name: Test
run: npm test
run: npm run test:ci
env:
DYNAMO_ENDPOINT: http://localhost:8000
- name: Test ESM
run: npm run test:esm
- name: Publish
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
# npm will not execute `prepublisnOnly` lifecycle hook if user is root.
Expand Down
23 changes: 0 additions & 23 deletions .vscode/launch.json

This file was deleted.

4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"editor.codeActionsOnSave": {
"source.organizeImports": "never",
"source.fixAll.eslint": "explicit"
},
"cSpell.words": [
"dyngoose"
]
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

services:
dynamodb:
image: amazon/dynamodb-local
Expand Down
56 changes: 56 additions & 0 deletions eslint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const love = require('eslint-config-love')
const simpleImportSort = require('eslint-plugin-simple-import-sort')
const importPlugin = require('eslint-plugin-import')

module.exports = [
{
...love,
files: ['**/*.js', '**/*.ts'],
plugins: {
...love.plugins ?? {},
'simple-import-sort': simpleImportSort,
'import': importPlugin,
},
rules: {
...love.rules,
// disable the eslint rule as it can report incorrectly
// 'space-before-function-paren': 'off',

// sort imports!
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",

// we use a few labeled for loops
'no-labels': 'off',

'@typescript-eslint/no-non-null-assertion': 'off',

// we want to use strict === false to avoid truthy logic
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off',

// uninitialized variables are assumed as undefined
'@typescript-eslint/init-declarations': 'off',

// we use any
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',

// we use delete
'@typescript-eslint/no-dynamic-delete': 'off',

// attribute classes do not all use this in toDynamo, fromDynamo, toJSON, etc
'@typescript-eslint/class-methods-use-this': 'off',

// allow throwing of caught errors (unknowns)
'@typescript-eslint/only-throw-error': ['error', {
allowThrowingUnknown: true,
}],

// we need to rely on require at times
'@typescript-eslint/no-require-imports': 'off',
}
}
]
Loading

0 comments on commit ccef67a

Please sign in to comment.