Skip to content

Commit

Permalink
Merge pull request #5 from MiracleUFO/release-v1.0
Browse files Browse the repository at this point in the history
Release v1.0
  • Loading branch information
MiracleUFO authored Sep 4, 2023
2 parents 2100c62 + 96f2a2e commit ef390a0
Show file tree
Hide file tree
Showing 22 changed files with 16,734 additions and 5,116 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["react", "es2015", "stage-0"],
}
43 changes: 43 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
moduleDirectory: ['node_modules', 'src/'],
},
alias: {
map: [['~', './src/']],
extensions: ['.ts', '.js', '.tsx'],
},
},
},
extends: [
'plugin:react/recommended',
'airbnb',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: [
'react',
'@typescript-eslint',
],
rules: {
"react/function-component-definition": [
2,
{
namedComponents: "arrow-function" | "function-expression" | "function-declaration",
unnamedComponents: "arrow-function" | "function-expression" | "function-declaration",
},
],
},
};
31 changes: 31 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

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

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
6 changes: 6 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ jobs:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- name: Install mocha
run: npm install -g mocha
- name: Install dependencies
run: npm install
- name: "Run Test"
run: mocha tests/translate-component.spec.tsx
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
Expand Down
2 changes: 1 addition & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"extension": [
"ts"
],
"spec": "./**/*.spec.ts",
"spec": ["./**/*.spec.ts", "./**/*.spec.tsx"],
"require": "ts-node/register"
}
7 changes: 7 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"useTabs": false,
"trailingComma": "all"
}
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ or with yarn
## Usage

### To translate whole component:
```jsx
```jsx (index.jsx)
import Translator from 'react-auto-translate';

return (
<Translator
from='en'
to='es'
>
<Component>
...
</Component>
<App />
</Translator>
);
```
Expand Down Expand Up @@ -144,7 +142,7 @@ Overrides `to` prop in all <Translator> and <Translate> components within the ap
- [`to`](#props) *required*
### Hook `translate(text, from, to)` ###
### Method `translate(text, from, to)` ###
Translates text and returns translation.
*Type:* Function
Expand All @@ -153,5 +151,5 @@ Translates text and returns translation.
*Params:*
- `text`: *Type string*, *required*
- [`from`](#props)
- [`to`](#props)
- [`from`](#props) *required*
- [`to`](#props) *required*
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
isTestEnv && require('@babel/preset-typescript').default
3 changes: 2 additions & 1 deletion configs/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"allowJs": true,
"declaration": true,
"declarationMap": true,
"allowSyntheticDefaultImports": true
"allowSyntheticDefaultImports": true,
"jsx": "react",
},
"files": ["../src/index.ts"]
}
3 changes: 2 additions & 1 deletion configs/tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"module": "CommonJS",
"moduleResolution": "Node",
"outDir": "../lib/cjs",
"declarationDir": "../lib/cjs/types"
"declarationDir": "../lib/cjs/types",
"jsx": "react",
}
}
3 changes: 2 additions & 1 deletion configs/tsconfig.esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"module": "ESNext",
"moduleResolution": "NodeNext",
"outDir": "../lib/esm",
"declarationDir": "../lib/esm/types"
"declarationDir": "../lib/esm/types",
"jsx": "react",
}
}
Loading

0 comments on commit ef390a0

Please sign in to comment.