Skip to content

Commit

Permalink
Merge 8960f4b into 2380c1e
Browse files Browse the repository at this point in the history
  • Loading branch information
ndaidong committed Jan 11, 2023
2 parents 2380c1e + 8960f4b commit 543a631
Show file tree
Hide file tree
Showing 24 changed files with 409 additions and 231 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
120 changes: 120 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"env": {
"es6": true,
"node": true,
"jest": true
},
"globals": {
"globalThis": true
},
"plugins": [],
"overrides": [],
"extends": ["eslint:recommended"],
"rules": {
"arrow-spacing": ["error", { "before": true, "after": true }],
"block-spacing": ["error", "always"],
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"camelcase": ["error", {
"allow": ["^UNSAFE_"],
"properties": "never",
"ignoreGlobals": true
}],
"comma-dangle": ["error", {
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "never",
"exports": "never",
"functions": "never"
}],
"comma-spacing": ["error", { "before": false, "after": true }],
"eol-last": "error",
"eqeqeq": ["error", "always", { "null": "ignore" }],
"func-call-spacing": ["error", "never"],
"indent": [
"error",
2,
{
"MemberExpression": 1,
"FunctionDeclaration": {
"body": 1,
"parameters": 2
},
"SwitchCase": 1
}
],
"key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
"keyword-spacing": ["error", { "before": true, "after": true }],
"lines-between-class-members": ["error", "always", { "exceptAfterSingleLine": true }],
"max-len": [
"error",
{
"code": 120,
"ignoreTrailingComments": true,
"ignoreComments": true,
"ignoreUrls": true
}
],
"max-lines": [
"error",
{
"max": 360,
"skipBlankLines": true,
"skipComments": false
}
],
"max-lines-per-function": [
"error",
{
"max": 150,
"skipBlankLines": true
}
],
"max-params": ["error", 3],
"no-array-constructor": "error",
"no-mixed-spaces-and-tabs": "error",
"no-multi-spaces": "error",
"no-multi-str": "error",
"no-multiple-empty-lines": [
"error",
{
"max": 1,
"maxEOF": 0
}
],
"no-restricted-syntax": [
"error",
"WithStatement",
"BinaryExpression[operator='in']"
],
"no-trailing-spaces": "error",
"no-use-before-define": [
"error",
{
"functions": true,
"classes": true,
"variables": false
}
],
"no-var": "warn",
"object-curly-spacing": ["error", "always"],
"padded-blocks": [
"error",
{
"blocks": "never",
"switches": "never",
"classes": "never"
}
],
"quotes": ["error", "single"],
"space-before-blocks": ["error", "always"],
"space-before-function-paren": ["error", "always"],
"space-infix-ops": "error",
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
"space-in-parens": ["error", "never"],
"semi": ["error", "never"]
}
}
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
coverage
.github
pnpm-lock.yaml
examples
test-data
src/utils/providers.orginal.json
src/utils/providers.prev.js
18 changes: 0 additions & 18 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,6 @@ Collaborations and pull requests are always welcomed, though larger proposals sh

As an OSS, it's better to follow the Unix philosophy: "do one thing and do it well".


## What you can contribute?

We are planing to re-write this tool in TypeScript and make it Deno-first library.
If you are interested, please join our team.

Besides that, you can also:

- Test and report bugs
- Fix unresolved issues
- Improve performance
- Write better documentation
- Create examples or build demos
- Feedback on software design and APIs


## Third-party libraries

Please avoid using libaries other than those available in the standard library, unless necessary.
Expand All @@ -31,8 +15,6 @@ This library needs to be simple and flexible to run on multiple platforms such a

## Coding convention

Please follow [standardjs](https://standardjs.com/) style guide.

Make sure your code lints before opening a pull request.


Expand Down
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Extract oEmbed content from given URL.
[![CI test](https://github.com/extractus/oembed-extractor/workflows/ci-test/badge.svg)](https://github.com/extractus/oembed-extractor/actions)
[![Coverage Status](https://coveralls.io/repos/github/extractus/oembed-extractor/badge.svg)](https://coveralls.io/github/extractus/oembed-extractor)
![CodeQL](https://github.com/extractus/oembed-extractor/workflows/CodeQL/badge.svg)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![CodeFactor](https://www.codefactor.io/repository/github/extractus/oembed-extractor/badge)](https://www.codefactor.io/repository/github/extractus/oembed-extractor)

## Intro

Expand Down Expand Up @@ -80,13 +80,6 @@ import { extract } from 'https://unpkg.com/@extractus/oembed-extractor@latest/di
Please check [the examples](examples) for reference.


### Deta cloud

For [Deta](https://www.deta.sh/) devs please refer [the source code and guideline here](https://github.com/ndaidong/oembed-parser-deta) or simply click the button below.

[![Deploy](https://button.deta.dev/1/svg)](https://go.deta.dev/deploy?repo=https://github.com/ndaidong/oembed-parser-deta)


## APIs

### `.extract()`
Expand Down Expand Up @@ -224,13 +217,24 @@ npm run eval https://www.instagram.com/tv/CVlR5GFqF68/
```


## Quick evaluation
## Test

```bash
git clone https://github.com/extractus/oembed-extractor.git
cd oembed-extractor
npm i
npm test
```

![oembed-extractor unit test](https://i.imgur.com/Nr5BgUx.png)


## Quick evaluation

```bash
git clone https://github.com/extractus/oembed-extractor.git
cd oembed-extractor
npm i
npm run eval {URL_TO_PARSE_OEMBED}
```

Expand Down
16 changes: 8 additions & 8 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ const pkg = JSON.parse(readFileSync('./package.json', { encoding: 'utf-8' }))

rmSync('dist', {
force: true,
recursive: true
recursive: true,
})
mkdirSync('dist')

const buildTime = (new Date()).toISOString()
const comment = [
`// ${pkg.name}@${pkg.version}, by ${pkg.author}`,
`built with esbuild at ${buildTime}`,
`published under ${pkg.license} license`
`published under ${pkg.license} license`,
].join(' - ')

const baseOpt = {
Expand All @@ -31,7 +31,7 @@ const baseOpt = {
legalComments: 'none',
minify: false,
sourcemap: false,
write: true
write: true,
}

const esmVersion = {
Expand All @@ -41,8 +41,8 @@ const esmVersion = {
mainFields: ['module'],
outfile: 'dist/oembed-extractor.esm.js',
banner: {
js: comment
}
js: comment,
},
}
buildSync(esmVersion)

Expand All @@ -53,15 +53,15 @@ const cjsVersion = {
mainFields: ['main'],
outfile: 'dist/cjs/oembed-extractor.js',
banner: {
js: comment
}
js: comment,
},
}
buildSync(cjsVersion)

const cjspkg = {
name: pkg.name,
version: pkg.version,
main: `./${pkg.name}.js`
main: `./${pkg.name}.js`,
}

writeFileSync(
Expand Down
Loading

0 comments on commit 543a631

Please sign in to comment.