Skip to content

Commit

Permalink
Formatted project (#2025)
Browse files Browse the repository at this point in the history
* Formatted project

Formatted project, added .editorconfig file and prettier.config.js

* Installed prettier as dev-dep

* Solved conflict with ESLint

Used the official `prettier` docs: https://prettier.io/docs/en/install.html#eslint-and-other-linters

Co-authored-by: Sébastien Vanvelthem <[email protected]>
  • Loading branch information
BenjaminIsMyName and belgattitude authored Nov 28, 2022
1 parent d59a86a commit d91d8ff
Show file tree
Hide file tree
Showing 76 changed files with 1,398 additions and 1,026 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true


# see docs: https://editorconfig.org/
# see example from a project on GitHub: https://github.com/tailwindlabs/tailwindcss/blob/master/.editorconfig
82 changes: 13 additions & 69 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"plugin:jest/style",
"plugin:typescript-sort-keys/recommended"
"plugin:typescript-sort-keys/recommended",
"prettier"
],
"ignorePatterns": [
"**/node_modules/*",
Expand All @@ -21,60 +22,21 @@
"**/*package.json"
],
"rules": {
"comma-dangle": [
"error",
"always-multiline"
],
"eol-last": ["error", "always"],
"indent": ["error", 2],
"jest/no-conditional-expect": 0,
"no-console": 2,
"no-trailing-spaces": 2,
"max-len": ["error", {
"code": 80,
"comments": 80,
"ignorePattern": "^import\\s.+\\sfrom\\s.+$",
"ignoreStrings": true,
"ignoreTemplateLiterals": true
}],
"multiline-comment-style": ["error", "separate-lines"],
"no-multiple-empty-lines": "error",
"no-multi-spaces": ["error", { "exceptions": { "Property": false } }],
"no-return-await": 2,
"arrow-body-style": ["error", "as-needed"],
"import/no-amd": 2,
"import/no-commonjs": 2,
// "import/no-default-export": 2,
"import/no-namespace": 2,
"import/no-nodejs-modules": 0,
"keyword-spacing": ["error", { "overrides": {} }],
"react/prefer-stateless-function": 2,
"react/prop-types": 0,
"react/jsx-wrap-multilines": ["error", {
"declaration": "parens-new-line",
"assignment": "parens-new-line",
"return": "parens-new-line",
"arrow": "parens-new-line",
"condition": "parens-new-line",
"logical": "parens-new-line",
"prop": "parens-new-line"
}
],
"semi": ["error", "never"],
"sort-keys": 1,
"space-before-blocks": 2,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/member-delimiter-style": ["error", {
"multiline": {
"delimiter": "none",
"requireLast": false
},
"singleline": {
"delimiter": "comma",
"requireLast": false
}
}],
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-unused-vars": [
2,
Expand All @@ -91,27 +53,21 @@
"classPropertiesAllowed": false
}
],
"prefer-destructuring": ["error", {"object": true, "array": true}],
"quotes": ["error", "single"],
"quote-props": ["error", "as-needed"],
"jsx-quotes": ["error", "prefer-single"]
"prefer-destructuring": [
"error",
{ "object": true, "array": true }
]
},
"overrides": [
{
"files": [
"./src/createClient"
],
"files": ["./src/createClient"],
"rules": {
"import/no-default-export": 0
}
},
{
"files": [
"cypress/**/*"
],
"plugins": [
"cypress"
],
"files": ["cypress/**/*"],
"plugins": ["cypress"],
"env": {
"cypress/globals": true
},
Expand All @@ -121,31 +77,19 @@
}
},
{
"files": [
"examples/**/*"
],
"files": ["examples/**/*"],
"rules": {
"react/react-in-jsx-scope": 0,
"max-len": ["error", {
"code": 120,
"comments": 120,
"ignoreStrings": true,
"ignoreTemplateLiterals": true
}]
"react/react-in-jsx-scope": 0
}
},
{
"files": [
"examples/**/pages/**/*"
],
"files": ["examples/**/pages/**/*"],
"rules": {
"import/no-default-export": 0
}
},
{
"files": [
"**/*.config.js"
],
"files": ["**/*.config.js"],
"rules": {
"import/no-commonjs": 0,
"no-undef": 0
Expand Down
42 changes: 21 additions & 21 deletions .size-limit.cjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// @ts-check

const fullEsmMaxSize = "5KB";
const fullEsmMaxSize = '5KB'
// Recent Nextjs version have some optimizations for commonjs that
// aren't available on bare-bone webpack. don't worry about threshold
// difference here for cjs. We can keep this till cjs is supported.
const fullCjsMaxSize = "29KB";
const fullCjsMaxSize = '29KB'

const getSimpleExamplePageLimits = () => {
const dir = './examples/simple/.next'
let manifest;
let manifest
try {
manifest = require(`${dir}/build-manifest.json`);
manifest = require(`${dir}/build-manifest.json`)
} catch (e) {
throw new Error(
'Cannot find a NextJs build folder, did you forget to run build:examples ?'
);
'Cannot find a NextJs build folder, did you forget to run build:examples ?'
)
}
const limitCfg = {
defaultSize: '90kb',
Expand All @@ -23,24 +23,24 @@ const getSimpleExamplePageLimits = () => {
'/404': '90kb',
'/_app': '100kb',
'/_error': '80Kb',
'/second-page': '85Kb'
'/second-page': '85Kb',
},
};
let pageLimits = [];
}
let pageLimits = []
for (const [uri, paths] of Object.entries(manifest.pages)) {
pageLimits.push({
name: `Example app: page '${uri}'`,
limit: limitCfg.pages?.[uri] ?? limitCfg.defaultSize,
webpack: false,
path: paths.map(p => `${dir}/${p}`)
});
path: paths.map(p => `${dir}/${p}`),
})
}
return pageLimits;
return pageLimits
}

const modifyWebpackConfig = config => {
config.resolve = {};
config.resolve.fallback = { "path": false, "fs": false };
config.resolve = {}
config.resolve.fallback = { path: false, fs: false }
}

/**
Expand All @@ -54,9 +54,9 @@ module.exports = [
// Dist ESM full bundle
// ###################################################
{
name: "ESM (import everything *)",
path: ["dist/esm/index.js"],
import: "*",
name: 'ESM (import everything *)',
path: ['dist/esm/index.js'],
import: '*',
limit: fullEsmMaxSize,
modifyWebpackConfig,
},
Expand All @@ -66,9 +66,9 @@ module.exports = [
// cjs very well. This explains threshold differences
// ###################################################
{
name: "CJS (require everything *)",
path: ["dist/commonjs/index.js"],
import: "*",
name: 'CJS (require everything *)',
path: ['dist/commonjs/index.js'],
import: '*',
webpack: true,
limit: fullCjsMaxSize,
modifyWebpackConfig,
Expand All @@ -77,4 +77,4 @@ module.exports = [
// Example apps
// ###################################################
...getSimpleExamplePageLimits(),
];
]
25 changes: 12 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
## 13.0.0

The v13.0.0 release is a major version to improve stability and general experience.
The v13.0.0 release is a major version to improve stability and general experience.
It comes with 2 easy changes related to installation. Existing code shouldn't be impacted.
Details can be found in the [UPGRADING.md](https://github.com/i18next/next-i18next/blob/master/UPGRADING.md#version-1300) document.

### Breaking changes

- [react-i18next](https://github.com/i18next/react-i18next) and [i18next](https://github.com/i18next/i18next)
- [react-i18next](https://github.com/i18next/react-i18next) and [i18next](https://github.com/i18next/i18next)
have been moved to peer-dependencies. They must be installed
in your app ([#1966](https://github.com/i18next/next-i18next/pull/1966))

```bash
# Add react-i18next > 12.0.0 and i18next > 22.0.4 to your app dependencies
# Add react-i18next > 12.0.0 and i18next > 22.0.4 to your app dependencies
npm install react-i18next i18next --save # NPM
yarn add react-i18next i18next # Yarn
pnpm add react-i18next i18next --save # PNPM
```

This might solve issues with duplicates and multiple i18n context instances.
If you encounter any issue, please read the [Troubleshoot](https://github.com/i18next/next-i18next/blob/master/TROUBLESHOOT.md) doc
before posting an issue.



- Types augmentations are now handled by i18next instead of react-i18next ([#1997](https://github.com/i18next/next-i18next/pull/1997)).
See the upgrade [document here](https://github.com/i18next/next-i18next/blob/master/UPGRADING.md#keys-typings).

### New

- Support for NextJs 13 (excluding new experimental layout / rsc)
- Upgrade to [i18next v22](https://github.com/i18next/i18next/releases) and react-i18next v12, see [#1966](https://github.com/i18next/next-i18next/pull/1966)
- Support for node 18 lts [#2017](https://github.com/i18next/next-i18next/pull/2017)
- Support for node 18 lts [#2017](https://github.com/i18next/next-i18next/pull/2017)

### Fix

- Fix types for appWithTranslation [#1987](https://github.com/i18next/next-i18next/pull/1987)
- Fix types for appWithTranslation [#1987](https://github.com/i18next/next-i18next/pull/1987)

### New minimum versions

We've dropped support for nextjs < 12.0.0 / react < 17.0.2 ([#1983](https://github.com/i18next/next-i18next/pull/1983))
and node < 14 ([#1974](https://github.com/i18next/next-i18next/pull/1974)).
and node < 14 ([#1974](https://github.com/i18next/next-i18next/pull/1974)).

## 12.1.0

- fix: appWithTranslation re-renders _app when the locale is changed (#1954)
- fix: appWithTranslation re-renders \_app when the locale is changed (#1954)
- feat: introduce onPreInitI18next option (#1960)

## 12.0.1
Expand All @@ -57,7 +56,6 @@ The following changes could lead to more languages being loaded, which could inc
- feat: improve fallback language handling (#1927)
- feat: add support for nonExplicitSupportedLngs (#1930)


## 11.3.0

- feat: introduce extraLocales (#1916)
Expand Down Expand Up @@ -85,11 +83,12 @@ The following changes could lead to more languages being loaded, which could inc
- update docs and example
- feat: support default locale by ignoring it (#1679)


## 11.0.0

**Features:**

- Allow client side translation loading (8132efd)

**Documentation:**

- Link to `react-i18next` config options (422a0f3)
26 changes: 13 additions & 13 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Expand Down
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
Run npm install

```bash
npm install
npm install
```

Useful commands:

| Name | Description |
|--------------------------|------------------------------------------------------------------------|
| ------------------------ | ---------------------------------------------------------------------- |
| `npm run lint` | Run eslint over the codebase. |
| `npm run typecheck` | Run typescript typechecking. |
| `npm run test` | Run unit tests. |
Expand Down Expand Up @@ -44,7 +44,7 @@ npm run test:e2e

## Working on examples

Examples nextjs apps live in the `examples/` folder.
Examples nextjs apps live in the `examples/` folder.

```bash
npm run install:examples
Expand All @@ -55,6 +55,6 @@ npm run build:examples

All PRs must pass all checks before they will be considered for review.

## Notes
## Notes

Please be sure to comply with our [Developer's Certificate of Origin](https://github.com/i18next/i18next/blob/master/CONTRIBUTING.md)
Please be sure to comply with our [Developer's Certificate of Origin](https://github.com/i18next/i18next/blob/master/CONTRIBUTING.md)
Loading

0 comments on commit d91d8ff

Please sign in to comment.