-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: support cjs and esm both by tshy #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,6 @@ | ||
{ | ||
"extends": "airbnb-base/legacy", | ||
"env": { | ||
"node": true, | ||
"mocha": true | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 6 | ||
}, | ||
"rules": { | ||
// disabled - disagree with airbnb | ||
"func-names": [0], | ||
"space-before-function-paren": [0], | ||
"consistent-return": [0], | ||
|
||
// Disabled but may want to refactor code eventually | ||
"no-use-before-define": [2, "nofunc"], | ||
"no-underscore-dangle": [0], | ||
|
||
// IMHO, more sensible overrides to existing airbnb error definitions | ||
"max-len": [2, 100, 4, {"ignoreComments": true, "ignoreUrls": true}], | ||
"no-unused-expressions": [2, { "allowShortCircuit": true, "allowTernary": true }] | ||
} | ||
"extends": [ | ||
"eslint-config-egg/typescript", | ||
"eslint-config-egg/lib/rules/enforce-node-prefix" | ||
] | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
Job: | ||
name: Node.js | ||
uses: node-modules/github-actions/.github/workflows/node-test.yml@master | ||
with: | ||
version: '18.19.0, 18, 20, 22, 23' | ||
secrets: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Publish Any Commit | ||
on: [push, pull_request] | ||
fengmk2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
fengmk2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- run: corepack enable | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Build | ||
run: npm run prepublishOnly --if-present | ||
|
||
- run: npx pkg-pr-new publish |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
fengmk2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
jobs: | ||
release: | ||
name: Node.js | ||
uses: eggjs/github-actions/.github/workflows/node-release.yml@master | ||
secrets: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
GIT_TOKEN: ${{ secrets.GIT_TOKEN }} | ||
fengmk2 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,7 @@ coverage | |
# Files # | ||
################### | ||
*.log | ||
.tshy* | ||
.eslintcache | ||
dist | ||
coverage |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
(The MIT License) | ||
|
||
Copyright (c) 2014 TJ Holowaychuk <[email protected]> | ||
Copyright (c) 2024-present eggjs and the contributors. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,12 +1,26 @@ | ||||||||||||||||||||||||
# [SuperTest](https://ladjs.github.io/superagent/) | ||||||||||||||||||||||||
# @eggjs/supertest | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
[![NPM version][npm-image]][npm-url] | ||||||||||||||||||||||||
[![code coverage][coverage-badge]][coverage] | ||||||||||||||||||||||||
[![Build Status][travis-badge]][travis] | ||||||||||||||||||||||||
[![Dependencies][dependencies-badge]][dependencies] | ||||||||||||||||||||||||
[![PRs Welcome][prs-badge]][prs] | ||||||||||||||||||||||||
[![Node.js CI](https://github.com/eggjs/supertest/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/supertest/actions/workflows/nodejs.yml) | ||||||||||||||||||||||||
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com) | ||||||||||||||||||||||||
[![MIT License][license-badge]][license] | ||||||||||||||||||||||||
[![npm download][download-image]][download-url] | ||||||||||||||||||||||||
[![Node.js Version](https://img.shields.io/node/v/@eggjs/mock.svg?style=flat)](https://nodejs.org/en/download/) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
[npm-image]: https://img.shields.io/npm/v/@eggjs/supertest.svg?style=flat-square | ||||||||||||||||||||||||
[npm-url]: https://npmjs.org/package/@eggjs/supertest | ||||||||||||||||||||||||
[coverage-badge]: https://img.shields.io/codecov/c/github/eggjs/supertest.svg | ||||||||||||||||||||||||
[coverage]: https://codecov.io/gh/eggjs/supertest | ||||||||||||||||||||||||
[license-badge]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square | ||||||||||||||||||||||||
[license]: https://github.com/eggjs/supertest/blob/master/LICENSE | ||||||||||||||||||||||||
[download-image]: https://img.shields.io/npm/dm/@eggjs/supertest.svg?style=flat-square | ||||||||||||||||||||||||
[download-url]: https://npmjs.org/package/@eggjs/supertest | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
> HTTP assertions made easy via [superagent](http://github.com/ladjs/superagent). Maintained for [Forward Email](https://github.com/forwardemail) and [Lad](https://github.com/ladjs). | ||||||||||||||||||||||||
> Forked for TypeScript friendly | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
Comment on lines
20
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Document TypeScript and dual module format support While the "Forked for TypeScript friendly" note is present, consider adding more detailed information about:
Add a new section about TypeScript and module format support: > Forked for TypeScript friendly
+
+## TypeScript & Module Format Support
+
+This fork provides:
+- Full TypeScript support with type definitions
+- Dual module format support (CommonJS and ESM)
+- Requires Node.js >= 18.19.0 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||
Document see [SuperTest](https://ladjs.github.io/superagent/) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
## About | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
@@ -18,7 +32,7 @@ HTTP, while still allowing you to drop down to the [lower-level API](https://lad | |||||||||||||||||||||||
Install SuperTest as an npm module and save it to your package.json file as a development dependency: | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||
npm install supertest --save-dev | ||||||||||||||||||||||||
npm install @eggjs/supertest --save-dev | ||||||||||||||||||||||||
``` | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
Once installed it can now be referenced by simply calling ```require('supertest');``` | ||||||||||||||||||||||||
|
@@ -33,7 +47,7 @@ SuperTest works with any test framework, here is an example without using any | |||||||||||||||||||||||
test framework at all: | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
```js | ||||||||||||||||||||||||
const request = require('supertest'); | ||||||||||||||||||||||||
const { request } = require('@eggjs/supertest'); | ||||||||||||||||||||||||
const express = require('express'); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
const app = express(); | ||||||||||||||||||||||||
|
@@ -55,7 +69,7 @@ request(app) | |||||||||||||||||||||||
To enable http2 protocol, simply append an options to `request` or `request.agent`: | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
```js | ||||||||||||||||||||||||
const request = require('supertest'); | ||||||||||||||||||||||||
const { request } = require('@eggjs/supertest'); | ||||||||||||||||||||||||
const express = require('express'); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
const app = express(); | ||||||||||||||||||||||||
|
@@ -207,21 +221,21 @@ the same host you may simply re-assign the request variable with the | |||||||||||||||||||||||
initialization app or url, a new `Test` is created per `request.VERB()` call. | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
```js | ||||||||||||||||||||||||
request = request('http://localhost:5555'); | ||||||||||||||||||||||||
t = request('http://localhost:5555'); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
request.get('/').expect(200, function(err){ | ||||||||||||||||||||||||
t.get('/').expect(200, function(err){ | ||||||||||||||||||||||||
console.log(err); | ||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
request.get('/').expect('heya', function(err){ | ||||||||||||||||||||||||
t.get('/').expect('heya', function(err){ | ||||||||||||||||||||||||
console.log(err); | ||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
``` | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
Here's an example with mocha that shows how to persist a request and its cookies: | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
```js | ||||||||||||||||||||||||
const request = require('supertest'); | ||||||||||||||||||||||||
const { agent } = require('@eggjs/supertest'); | ||||||||||||||||||||||||
const should = require('should'); | ||||||||||||||||||||||||
const express = require('express'); | ||||||||||||||||||||||||
const cookieParser = require('cookie-parser'); | ||||||||||||||||||||||||
|
@@ -240,16 +254,16 @@ describe('request.agent(app)', function() { | |||||||||||||||||||||||
else res.send(':(') | ||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
const agent = request.agent(app); | ||||||||||||||||||||||||
const testAgent = agent(app); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
it('should save cookies', function(done) { | ||||||||||||||||||||||||
agent | ||||||||||||||||||||||||
testAgent | ||||||||||||||||||||||||
.get('/') | ||||||||||||||||||||||||
.expect('set-cookie', 'cookie=hey; Path=/', done); | ||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
it('should send cookies', function(done) { | ||||||||||||||||||||||||
agent | ||||||||||||||||||||||||
testAgent | ||||||||||||||||||||||||
.get('/return') | ||||||||||||||||||||||||
.expect('hey', done); | ||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
|
@@ -324,15 +338,10 @@ Inspired by [api-easy](https://github.com/flatiron/api-easy) minus vows coupling | |||||||||||||||||||||||
|
||||||||||||||||||||||||
## License | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
MIT | ||||||||||||||||||||||||
[MIT](LICENSE) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
[coverage-badge]: https://img.shields.io/codecov/c/github/ladjs/supertest.svg | ||||||||||||||||||||||||
[coverage]: https://codecov.io/gh/ladjs/supertest | ||||||||||||||||||||||||
[travis-badge]: https://travis-ci.org/ladjs/supertest.svg?branch=master | ||||||||||||||||||||||||
[travis]: https://travis-ci.org/ladjs/supertest | ||||||||||||||||||||||||
[dependencies-badge]: https://david-dm.org/ladjs/supertest/status.svg | ||||||||||||||||||||||||
[dependencies]: https://david-dm.org/ladjs/supertest | ||||||||||||||||||||||||
[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square | ||||||||||||||||||||||||
[prs]: http://makeapullrequest.com | ||||||||||||||||||||||||
[license-badge]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square | ||||||||||||||||||||||||
[license]: https://github.com/ladjs/supertest/blob/master/LICENSE | ||||||||||||||||||||||||
## Contributors | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
[![Contributors](https://contrib.rocks/image?repo=eggjs/supertest)](https://github.com/eggjs/supertest/graphs/contributors) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
Made with [contributors-img](https://contrib.rocks). |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Documentation needed for ESLint configuration and TypeScript coding standards
The repository lacks documentation about linting rules and TypeScript coding standards. The evidence shows:
Consider adding:
eslint-config-egg/typescript
andenforce-node-prefix
rule setsnpm run lint
)🔗 Analysis chain
Consider documenting the linting rules for contributors.
Since we're transitioning to a new ESLint configuration, it would be helpful to document the key linting rules and expectations in the project's contributing guidelines.
Let's check if documentation exists:
Let me check if there are any other potential documentation files or development guides in the repository.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 670
Script:
Length of output: 1116