-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from 20minutes/feature/add-functions
Add `unaccentize` & `toContentSlug`
- Loading branch information
Showing
14 changed files
with
4,337 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint"], | ||
"extends": [ | ||
"@20minutes", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"rules": { | ||
"no-console": [ | ||
"error", | ||
{ | ||
"allow": ["warn", "error", "info"] | ||
} | ||
], | ||
"import/extensions": [ | ||
"error", | ||
"ignorePackages", | ||
{ | ||
"js": "never", | ||
"jsx": "never", | ||
"ts": "never", | ||
"tsx": "never" | ||
} | ||
], | ||
"@typescript-eslint/no-non-null-assertion": "off" | ||
}, | ||
"settings": { | ||
"import/resolver": { | ||
"typescript": { | ||
"alwaysTryTypes": true | ||
}, | ||
"node": { | ||
"extensions": [".js", ".jsx", ".ts", ".tsx"] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: "CodeQL" | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
schedule: | ||
- cron: '0 8 * * 1' | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: [ 'javascript' ] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
# Initializes the CodeQL tools for scanning. | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
languages: ${{ matrix.language }} | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages | ||
|
||
name: Node.js Package | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
- run: npm ci | ||
- run: npm test | ||
|
||
publish-npm: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm ci | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.npm_token}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
env: | ||
CI: true | ||
TZ: 'Europe/Paris' | ||
NODE_ENV: 'test' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.x] | ||
|
||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: use node ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'yarn' | ||
|
||
- name: install | ||
run: yarn install | ||
|
||
- name: lint | ||
run: yarn lint | ||
|
||
- name: test | ||
run: yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
coverage | ||
node_modules | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
src | ||
tests | ||
.eslintrc | ||
jestconfig.json | ||
tsconfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# @20minutes/content-slug | ||
|
||
[![Build status](https://github.com/20minutes/content-slug/actions/workflows/tests.yml/badge.svg)](https://github.com/20minutes/content-slug/actions/workflows/tests.yml) | ||
[![NPM](https://img.shields.io/npm/v/@20minutes/content-slug)](https://www.npmjs.com/package/@20minutes/content-slug) | ||
|
||
URL slugification used by 20 Minutes for content URL. | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install @20minutes/content-slug | ||
``` | ||
|
||
## Usage | ||
|
||
```javascript | ||
import { toContentSlug, unaccentize} from '@20minutes/content-slug' | ||
|
||
toContentSlug('j'ai mangé des pommes et des poires et c'était bon !') | ||
// mange-pommes-poires-bon | ||
|
||
unaccentize('mangé') | ||
// mange | ||
``` | ||
|
||
## License | ||
|
||
[The MIT License](./LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Config } from '@jest/types' | ||
|
||
// Sync object | ||
const config: Config.InitialOptions = { | ||
verbose: true, | ||
transform: { | ||
'^.+\\.tsx?$': 'ts-jest', | ||
}, | ||
testEnvironment: 'node', | ||
collectCoverage: true, | ||
collectCoverageFrom: ['<rootDir>/src/**/*.ts', '!tests/*'], | ||
coverageDirectory: './coverage', | ||
coverageReporters: ['html', 'text-summary'], | ||
// because TS generate some files in `.build` and jest might take them without that option | ||
roots: ['<rootDir>/src/', '<rootDir>/tests/'], | ||
} | ||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"name": "@20minutes/content-slug", | ||
"version": "1.0.0", | ||
"description": "Content slugification for 20 Minutes", | ||
"license": "MIT", | ||
"repository": "20minutes/content-slug", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"files": [ | ||
"lib/**/*" | ||
], | ||
"scripts": { | ||
"build": "tsc", | ||
"prepare" : "yarn build", | ||
"test": "jest --silent false", | ||
"lint": "eslint src/* tests/* *.ts" | ||
}, | ||
"devDependencies": { | ||
"@20minutes/eslint-config": "^1.2.4", | ||
"@babel/core": "^7.16.0", | ||
"@babel/eslint-parser": "^7.16.3", | ||
"@types/jest": "^29.1.1", | ||
"@typescript-eslint/eslint-plugin": "^5.39.0", | ||
"@typescript-eslint/parser": "^5.39.0", | ||
"eslint": "^8.24.0", | ||
"eslint-config-airbnb": "^19.0.4", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-import-resolver-typescript": "^3.5.1", | ||
"eslint-plugin-babel": "^5.0", | ||
"eslint-plugin-import": "^2.25.3", | ||
"eslint-plugin-jsx-a11y": "^6.5.1", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-react": "^7.27.0", | ||
"eslint-plugin-react-hooks": "^4.3.0", | ||
"jest": "^29.1.2", | ||
"prettier": "^2.4.1", | ||
"ts-jest": "^29.0.3", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.8.4" | ||
}, | ||
"dependencies": { | ||
"url-slug": "^3.0.4" | ||
} | ||
} |
Oops, something went wrong.