Skip to content
Merged
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
16 changes: 0 additions & 16 deletions .eslintrc.js

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run lint -- --fix
- run: npm run build
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 🤖 linting with autofix
branch: ${{ github.head_ref }}
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run build
- run: npm test
17 changes: 17 additions & 0 deletions __tests__/text.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { utf8Encode } from '../src/text'

describe('text', () => {
describe('utf8Encode', () => {
test('encodes "a" properly', () => {
expect(utf8Encode('a')).toEqual('a')
})

test('encodes "\\a" properly', () => {
expect(utf8Encode('\\a')).toEqual('\\a')
})

test('encodes blank string properly', () => {
expect(utf8Encode('')).toEqual('')
})
})
})
11 changes: 9 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* https://jestjs.io/docs/configuration
*/

import { pathsToModuleNameMapper } from 'ts-jest'
import { compilerOptions } from './tsconfig.json'

export default {
// All imported modules in your tests should be mocked automatically
// automock: false,
Expand All @@ -13,8 +16,12 @@ export default {
// The directory where Jest should store its cached dependency information
// cacheDirectory: "/private/var/folders/39/wx5hr2ps64d83gpwscpz2jg80000gn/T/jest_dx",

preset: 'ts-jest',
testEnvironment: 'node',

moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' }),
// Automatically clear mock calls, instances, contexts and results before every test
clearMocks: true,
clearMocks: true

// Indicates whether the coverage information should be collected while executing the test
// collectCoverage: false,
Expand Down Expand Up @@ -192,4 +199,4 @@ export default {

// Whether to use watchman for file crawling
// watchman: true,
};
}
119 changes: 119 additions & 0 deletions package-lock.json

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

24 changes: 23 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"description": "A JavaScript client for communicating with PlanetScale Edge API.",
"main": "dist/index.js",
"types": "dist/index.d.js",
"files": [
"dist"
],
"engines": {
"node": ">=16"
},
"type": "module",
"prettier": {
"semi": false,
Expand All @@ -18,7 +24,7 @@
"clean": "rm -rf dist/",
"prebuild": "npm run clean",
"build": "tsc",
"lint": "eslint .",
"lint": "eslint src/ __tests__/",
"test": "jest"
},
"repository": {
Expand Down Expand Up @@ -50,7 +56,23 @@
"eslint-plugin-prettier": "^4.2.1",
"jest": "^28.1.3",
"prettier": "^2.7.1",
"ts-jest": "^28.0.7",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
},
"eslintConfig": {
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"rules": {
"prettier/prettier": ["error", {}, { "usePrettierrc": true }],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-function": "off", "@typescript-eslint/ban-ts-comment": "off"
},
"root": true,
"env": {
"browser": true,
"node": true
}
}
}
8 changes: 6 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"outDir": "dist",
"removeComments": true,
"allowJs": true,
"moduleResolution": "node"
}
"moduleResolution": "node",
"paths": {},
"esModuleInterop": true,
"resolveJsonModule": true
},
"files": ["src/index.ts"]
}