Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use pnpm #132

Merged
merged 4 commits into from
Sep 14, 2024
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
15 changes: 9 additions & 6 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 18.x]
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v1
- uses: pnpm/action-setup@v2
with:
version: 8.13.1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
cache: pnpm
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
- name: build and test
run: |
npm ci
npm run build --if-present
npm test
pnpm i --frozen-lockfile
pnpm test
env:
CI: true
14 changes: 9 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2
with:
version: 8.13.1
- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 12.*
node-version: 20.*
cache: pnpm
- name: Configure committer
run: |
git config --global user.name ${GITHUB_ACTOR}
git config --global user.email ${GITHUB_ACTOR}@users.noreply.github.com
- name: npm install, build, and release
run: |
npm ci
npx standard-version
git push --follow-tags
pnpm i --frozen-lockfile
pnpx standard-version
npm publish
git push --follow-tags
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
CI: true
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
node_modules/
.*
!.github
25 changes: 10 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,22 @@ npm install eslint-plugin-i18next --save-dev

## Usage

Add `i18next` to the plugins section of your `.eslintrc` configuration file.
For ESLint 9 flat configuration,

```json
{
"plugins": ["i18next"]
}
```

Then configure the rules you want to use under the rules section.
```js
// eslint.config.mjs
import i18next from 'eslint-plugin-i18next';

```json
{
"rules": {
"i18next/no-literal-string": 2
}
}
export default [
// your other configs
i18next.configs['flat/recommended'],
];
```

or
For ESLint 8 and below,

```json
// .eslintrc
{
"extends": ["plugin:i18next/recommended"]
}
Expand Down
21 changes: 21 additions & 0 deletions examples/app-with-eslint7/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require('@rushstack/eslint-patch/modern-module-resolution');

module.exports = {
root: true,
env: {
browser: true,
es6: true,
},
extends: ['plugin:i18next/recommended'],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
rules: {
'i18next/no-literal-string': ['error', { mode: 'all' }],
},
};
2 changes: 2 additions & 0 deletions examples/app-with-eslint7/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const a = 'hello';
console.log(a);
21 changes: 21 additions & 0 deletions examples/app-with-eslint7/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "app-with-eslint7",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"lint": "node test.mjs"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"eslint-plugin-i18next": "workspace:*",
"zx": "^8.1.6"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.10.4",
"eslint": "^7.0.0",
"globals": "^15.8.0"
}
}
9 changes: 9 additions & 0 deletions examples/app-with-eslint7/test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { $ } from 'zx';
import assert from 'assert';

(async () => {
await $({})`eslint index.js -f json`.catch(e => {
const [error] = JSON.parse(e.stdout);
assert(error.errorCount === 1, 'expect to have one lint error');
});
})();
11 changes: 6 additions & 5 deletions examples/app-with-eslint9/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import pluginJs from '@eslint/js';
import i18next from 'eslint-plugin-i18next';

export default [
{ languageOptions: { globals: globals.browser } },
{
languageOptions: { globals: globals.browser },
linterOptions: { reportUnusedDisableDirectives: 'error' },
},
pluginJs.configs.recommended,
i18next.configs['flat/recommended'],
{
plugins: { i18next },
rules: {
'i18next/no-literal-string': ['error', { mode: 'all' }],
},
rules: { 'i18next/no-literal-string': ['error', { mode: 'all' }] },
},
];
3 changes: 3 additions & 0 deletions examples/app-with-eslint9/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
// if it doesn't break the rule no-literal-string, it will report unused disable directive

// eslint-disable-next-line i18next/no-literal-string
const a = 'hello';
console.log(a);
2 changes: 1 addition & 1 deletion examples/app-with-eslint9/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"eslint-plugin-i18next": "link:/Users/edward/workspace/github/eslint-plugin-i18next"
"eslint-plugin-i18next": "workspace:*"
},
"devDependencies": {
"@eslint/js": "^9.6.0",
Expand Down
Loading
Loading