diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..73270f08 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,5 @@ +dist +/docs +examples +node_modules +types/demo diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..47ca2e38 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,42 @@ +{ + "extends": ["prettier", "eslint:recommended"], + "settings": { + "import/extensions": ["", ".js", ".ejs", ".json", ".yml", ".jsx"], + "import/ignore": [".ejs$", ".yml$", ".jsx", "node_modules"] + }, + "rules": { + "no-console": "off", + "import/no-unresolved": "off", + "no-param-reassign": "off", + "filenames/match-regex": "off", + "lines-between-class-members": "off", + "global-require": "off" + }, + "globals": { + "window": true, + "$": true + }, + "parserOptions": { + "ecmaVersion": 13, + "requireConfigFile": false, + "sourceType": "module" + }, + "env": { + "node": true, + "es6": true + }, + "overrides": [ + { + "files": ["**/*.ts"], + "parser": "@typescript-eslint/parser", + "plugins": ["@typescript-eslint"], + "parserOptions": { + "ecmaVersion": 2022, + "sourceType": "module" + }, + "rules": { + "no-undef": "off" + } + } + ] +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6cfd794c..8a01aadc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/setup-node@v7 with: node-version: 24 - - run: EASYPOST_TEST_API_KEY=123 EASYPOST_PROD_API_KEY=123 just install install-styleguide build test + - run: EASYPOST_TEST_API_KEY=123 EASYPOST_PROD_API_KEY=123 just install build test # node-compatibility checks that the build version of the app can be imported # and used on older versions of node node-compatibility: @@ -30,7 +30,7 @@ jobs: - uses: actions/setup-node@v7 with: node-version: 24 - - run: EASYPOST_TEST_API_KEY=123 EASYPOST_PROD_API_KEY=123 just install install-styleguide build + - run: EASYPOST_TEST_API_KEY=123 EASYPOST_PROD_API_KEY=123 just install build - uses: actions/setup-node@v7 with: node-version: ${{ matrix.node-version }} @@ -48,7 +48,7 @@ jobs: cd types/demo npm install cd ../../ - just install install-styleguide typescript + just install typescript lint: runs-on: ubuntu-latest steps: @@ -57,7 +57,7 @@ jobs: - uses: actions/setup-node@v7 with: node-version: 24 - - run: just install install-styleguide build lint + - run: just install build lint coverage: runs-on: ubuntu-latest steps: @@ -66,7 +66,7 @@ jobs: - uses: actions/setup-node@v7 with: node-version: 24 - - run: just install install-styleguide build + - run: just install build - run: EASYPOST_TEST_API_KEY=123 EASYPOST_PROD_API_KEY=123 just coverage - name: Coverage if: github.ref == 'refs/heads/master' diff --git a/.gitignore b/.gitignore index 8092032e..d3c7971d 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,6 @@ docs Icon node_modules npm-debug.log -/.eslintrc /.eslintignore /.prettierrc.yml /.prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..07356dd8 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,15 @@ +.golangci.yml +.mypy_cache +.nyc_output +cassettes +composer.json +composer.lock +coverage +dist/ +/docs +examples +official/fixtures/ +package-lock.json +style_guides/ +vendor/ +venv/ diff --git a/.prettierrc.yml b/.prettierrc.yml new file mode 100644 index 00000000..72620da5 --- /dev/null +++ b/.prettierrc.yml @@ -0,0 +1,3 @@ +trailingComma: all +singleQuote: true +printWidth: 100 diff --git a/audit-ci.jsonc b/audit-ci.jsonc index 3621ba8d..009d4335 100644 --- a/audit-ci.jsonc +++ b/audit-ci.jsonc @@ -9,5 +9,7 @@ "GHSA-7r86-cg39-jmmj", "GHSA-mh99-v99m-4gvg", "GHSA-rgw5-rvv9-x895", + "GHSA-5p4m-2wfm-xmqj", + "GHSA-7p8r-x3mc-p8w7", ], } diff --git a/package.json b/package.json index 14ba2f5d..0134f858 100644 --- a/package.json +++ b/package.json @@ -29,13 +29,15 @@ "docs": "jsdoc src/models src/services src/errors src/utils -d docs", "format": "prettier --write .", "formatCheck": "prettier --check .", - "lint": "eslint --ext .js,.ts .", - "lintFix": "eslint --ext .js,.ts --fix .", + "lint": "eslint --ext .js,.ts --ignore-pattern 'examples/**' .", + "lintFix": "eslint --ext .js,.ts --ignore-pattern 'examples/**' --fix .", "prepublishOnly": "npm run clean && npm run build && npm run test && npm run lint && npm run formatCheck", "scan": "npx audit-ci -m --config ./audit-ci.jsonc", "test": "cross-env NODE_ENV=test vitest run", "test:node-compatibility": "cross-env NODE_ENV=test node ./test/node_compatibility", - "typescript": "npx tsc", + "typescript": "npm run typescript:declarations && npm run typescript:source", + "typescript:declarations": "npx tsc -p tsconfig.json", + "typescript:source": "npx tsc -p tsconfig.build.json", "watch": "vite build --watch" }, "dependencies": { diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 00000000..a62fb87a --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "nodenext", + "strict": true, + "ignoreDeprecations": "5.0", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true + } +} diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 00000000..e301a68b --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "allowJs": true, + "checkJs": false, + "declaration": true, + "noEmit": true + }, + "include": ["src/**/*.js", "src/**/*.ts", "test/**/*.js", "test/**/*.ts"], + "exclude": ["dist/**", "docs/**", "coverage/**", "node_modules/**"] +} diff --git a/tsconfig.json b/tsconfig.json index f0fc974b..1f0f4c7e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,11 +1,7 @@ { + "extends": "./tsconfig.base.json", "compilerOptions": { - "target": "es5", - "module": "nodenext", - "strict": true, - "noEmit": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true + "noEmit": true }, "include": ["types"] }