@stzhu/eslint-config 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +24 -0
- package/.github/workflows/publish.yml +24 -0
- package/.prettierignore +1 -0
- package/.prettierrc.yaml +5 -0
- package/LICENSE +21 -0
- package/README.md +35 -0
- package/eslint.config.js +13 -0
- package/jsconfig.json +12 -0
- package/package.json +72 -0
- package/pnpm-workspace.yaml +2 -0
- package/src/configs/import.js +27 -0
- package/src/configs/typescript.js +61 -0
- package/src/expo.js +7 -0
- package/src/index.js +3 -0
- package/src/lingui.js +4 -0
- package/src/node.js +10 -0
- package/src/react.js +46 -0
- package/src/storybook.js +4 -0
- package/src/tailwind.js +4 -0
- package/src/ts.js +28 -0
- package/src/vitest.js +31 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [main]
|
|
5
|
+
pull_request:
|
|
6
|
+
branches: [main]
|
|
7
|
+
types: [opened, synchronize]
|
|
8
|
+
jobs:
|
|
9
|
+
checks:
|
|
10
|
+
name: Checks
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
node-version: [18.x, 20.x, 22.x]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: pnpm/action-setup@v4
|
|
18
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
19
|
+
uses: actions/setup-node@v4
|
|
20
|
+
with:
|
|
21
|
+
node-version: ${{ matrix.node-version }}
|
|
22
|
+
cache: 'pnpm'
|
|
23
|
+
- run: pnpm install
|
|
24
|
+
- run: pnpm run lint
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
on:
|
|
3
|
+
release:
|
|
4
|
+
types: [published]
|
|
5
|
+
jobs:
|
|
6
|
+
build-and-publish:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
id-token: write
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- uses: pnpm/action-setup@v4
|
|
14
|
+
- name: Setup Node.js
|
|
15
|
+
uses: actions/setup-node@v4
|
|
16
|
+
with:
|
|
17
|
+
node-version-file: package.json
|
|
18
|
+
cache: pnpm
|
|
19
|
+
registry-url: https://registry.npmjs.org
|
|
20
|
+
- run: pnpm install
|
|
21
|
+
- run: pnpm run lint
|
|
22
|
+
- run: pnpm publish --provenance --access public --no-git-checks
|
|
23
|
+
env:
|
|
24
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/.prettierignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pnpm-lock.yaml
|
package/.prettierrc.yaml
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Steve Zhu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @stzhu/eslint-config
|
|
2
|
+
|
|
3
|
+
## Usage
|
|
4
|
+
|
|
5
|
+
Install:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
pnpm i -D @stzhu/eslint-config
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Create a `eslint.config.js` with the following config:
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
// @ts-check
|
|
15
|
+
|
|
16
|
+
import { defineConfig } from '@internal/eslint-config';
|
|
17
|
+
import tsConfig from '@internal/eslint-config/ts';
|
|
18
|
+
|
|
19
|
+
export default defineConfig(
|
|
20
|
+
// select from one of the configs below
|
|
21
|
+
...tsConfig,
|
|
22
|
+
);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Shareable Configs
|
|
26
|
+
|
|
27
|
+
Import one of the following required main configs depending on the project type.
|
|
28
|
+
|
|
29
|
+
- `@internal/eslint-config/ts`: Typescript Project
|
|
30
|
+
- `@internal/eslint-config/react`: React Project
|
|
31
|
+
|
|
32
|
+
Import any of the following optional configs depending on usage.
|
|
33
|
+
|
|
34
|
+
- `@internal/eslint-config/vitest`
|
|
35
|
+
- `@internal/eslint-config/storybook`
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import js from '@eslint/js';
|
|
4
|
+
import prettier from 'eslint-config-prettier';
|
|
5
|
+
import tseslint from 'typescript-eslint';
|
|
6
|
+
|
|
7
|
+
import importConfig from './src/configs/import.js';
|
|
8
|
+
|
|
9
|
+
export default tseslint.config(
|
|
10
|
+
js.configs.recommended,
|
|
11
|
+
...importConfig,
|
|
12
|
+
prettier,
|
|
13
|
+
);
|
package/jsconfig.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stzhu/eslint-config",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared config for ESLint",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"eslint"
|
|
7
|
+
],
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/stevezhu/eslint-config.git"
|
|
11
|
+
},
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "Steve Zhu <4130171+stevezhu@users.noreply.github.com>",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./src/index.js",
|
|
17
|
+
"./ts": "./src/ts.js",
|
|
18
|
+
"./react": "./src/react.js",
|
|
19
|
+
"./node": "./src/node.js",
|
|
20
|
+
"./expo": "./src/expo.js",
|
|
21
|
+
"./storybook": "./src/storybook.js",
|
|
22
|
+
"./vitest": "./src/vitest.js",
|
|
23
|
+
"./tailwind": "./src/tailwind.js",
|
|
24
|
+
"./lingui": "./src/lingui.js"
|
|
25
|
+
},
|
|
26
|
+
"bin": {
|
|
27
|
+
"eslint": "./node_modules/eslint/bin/eslint.js"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@eslint/js": "^9.28.0",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "^8.33.1",
|
|
32
|
+
"@typescript-eslint/parser": "^8.33.1",
|
|
33
|
+
"@vitest/eslint-plugin": "^1.2.1",
|
|
34
|
+
"eslint": "^9.28.0",
|
|
35
|
+
"eslint-config-expo": "^9.2.0",
|
|
36
|
+
"eslint-config-prettier": "^10.1.5",
|
|
37
|
+
"eslint-config-turbo": "^2.5.4",
|
|
38
|
+
"eslint-plugin-expo": "^0.1.4",
|
|
39
|
+
"eslint-plugin-import": "^2.31.0",
|
|
40
|
+
"eslint-plugin-lingui": "^0.10.1",
|
|
41
|
+
"eslint-plugin-react": "^7.37.5",
|
|
42
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
43
|
+
"eslint-plugin-react-refresh": "^0.4.20",
|
|
44
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
45
|
+
"eslint-plugin-storybook": "^0.12.0",
|
|
46
|
+
"eslint-plugin-tailwindcss": "^3.18.0",
|
|
47
|
+
"eslint-plugin-turbo": "^2.5.4",
|
|
48
|
+
"globals": "^16.2.0",
|
|
49
|
+
"postcss": "^8.5.4",
|
|
50
|
+
"tailwindcss": "^4.1.8",
|
|
51
|
+
"typescript": "^5.8.3",
|
|
52
|
+
"typescript-eslint": "^8.33.1"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@stzhu/prettier-plugin-tsconfig": "^0.5.0",
|
|
56
|
+
"@stzhu/tsconfig": "^0.1.0",
|
|
57
|
+
"@types/eslint-config-prettier": "^6.11.3",
|
|
58
|
+
"eslint-plugin-import-x": "^4.15.1",
|
|
59
|
+
"prettier": "^3.5.3",
|
|
60
|
+
"prettier-plugin-packagejson": "^2.5.15"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"postcss": "^8",
|
|
64
|
+
"tailwindcss": "^4",
|
|
65
|
+
"typescript": "^5"
|
|
66
|
+
},
|
|
67
|
+
"scripts": {
|
|
68
|
+
"format": "prettier -w .",
|
|
69
|
+
"lint": "prettier -c . && eslint .",
|
|
70
|
+
"test": "tsc --noEmit -p jsconfig.json"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import importX from 'eslint-plugin-import-x';
|
|
2
|
+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
|
|
3
|
+
import tseslint from 'typescript-eslint';
|
|
4
|
+
|
|
5
|
+
export default tseslint.config(
|
|
6
|
+
{
|
|
7
|
+
name: 'import/custom',
|
|
8
|
+
plugins: {
|
|
9
|
+
'import-x': importX,
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
'import-x/first': 'error',
|
|
13
|
+
'import-x/newline-after-import': 'error',
|
|
14
|
+
'import-x/no-duplicates': 'error',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'simple-import-sort/custom',
|
|
19
|
+
plugins: {
|
|
20
|
+
'simple-import-sort': simpleImportSort,
|
|
21
|
+
},
|
|
22
|
+
rules: {
|
|
23
|
+
'simple-import-sort/imports': 'error',
|
|
24
|
+
'simple-import-sort/exports': 'error',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import tseslint from 'typescript-eslint';
|
|
2
|
+
|
|
3
|
+
export default tseslint.config(
|
|
4
|
+
...tseslint.configs.strictTypeChecked,
|
|
5
|
+
{
|
|
6
|
+
name: 'typescript/languageOptions',
|
|
7
|
+
languageOptions: {
|
|
8
|
+
parserOptions: {
|
|
9
|
+
project: true,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'typescript/custom',
|
|
15
|
+
rules: {
|
|
16
|
+
'@typescript-eslint/consistent-type-definitions': 'off',
|
|
17
|
+
'@typescript-eslint/no-misused-promises': [
|
|
18
|
+
'error',
|
|
19
|
+
{
|
|
20
|
+
checksVoidReturn: {
|
|
21
|
+
attributes: false,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
'@typescript-eslint/no-unused-vars': [
|
|
26
|
+
'error',
|
|
27
|
+
{
|
|
28
|
+
args: 'all',
|
|
29
|
+
argsIgnorePattern: '^_',
|
|
30
|
+
caughtErrors: 'all',
|
|
31
|
+
caughtErrorsIgnorePattern: '^_',
|
|
32
|
+
destructuredArrayIgnorePattern: '^_',
|
|
33
|
+
varsIgnorePattern: '^_',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
'@typescript-eslint/restrict-template-expressions': [
|
|
37
|
+
'error',
|
|
38
|
+
{
|
|
39
|
+
allowNumber: true,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
// https://tanstack.com/router/v1/docs/framework/react/api/router/redirectFunction
|
|
43
|
+
'@typescript-eslint/only-throw-error': [
|
|
44
|
+
'warn',
|
|
45
|
+
{
|
|
46
|
+
allow: [
|
|
47
|
+
{
|
|
48
|
+
from: 'package',
|
|
49
|
+
name: 'Redirect',
|
|
50
|
+
package: '@tanstack/router-core',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
files: ['**/*.{cjs,js}'],
|
|
59
|
+
extends: [tseslint.configs.disableTypeChecked],
|
|
60
|
+
},
|
|
61
|
+
);
|
package/src/expo.js
ADDED
package/src/index.js
ADDED
package/src/lingui.js
ADDED
package/src/node.js
ADDED
package/src/react.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import prettier from 'eslint-config-prettier';
|
|
2
|
+
import react from 'eslint-plugin-react';
|
|
3
|
+
import reactHooks from 'eslint-plugin-react-hooks';
|
|
4
|
+
import reactRefresh from 'eslint-plugin-react-refresh';
|
|
5
|
+
import globals from 'globals';
|
|
6
|
+
import tseslint from 'typescript-eslint';
|
|
7
|
+
|
|
8
|
+
import baseConfig from './ts.js';
|
|
9
|
+
|
|
10
|
+
export default tseslint.config(
|
|
11
|
+
...baseConfig,
|
|
12
|
+
{
|
|
13
|
+
name: 'react/src-browser-globals',
|
|
14
|
+
files: ['src/**/*.{ts,tsx}'],
|
|
15
|
+
languageOptions: {
|
|
16
|
+
globals: globals.browser,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
react.configs.flat['recommended'],
|
|
20
|
+
react.configs.flat['jsx-runtime'],
|
|
21
|
+
{
|
|
22
|
+
name: 'react/custom',
|
|
23
|
+
settings: {
|
|
24
|
+
react: {
|
|
25
|
+
version: 'detect',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
rules: {
|
|
29
|
+
'react/function-component-definition': [
|
|
30
|
+
'error',
|
|
31
|
+
{ namedComponents: 'function-declaration' },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
reactHooks.configs['recommended-latest'],
|
|
36
|
+
{
|
|
37
|
+
name: 'react-refresh/custom',
|
|
38
|
+
plugins: {
|
|
39
|
+
'react-refresh': reactRefresh,
|
|
40
|
+
},
|
|
41
|
+
rules: {
|
|
42
|
+
'react-refresh/only-export-components': 'warn',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
prettier,
|
|
46
|
+
);
|
package/src/storybook.js
ADDED
package/src/tailwind.js
ADDED
package/src/ts.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import prettier from 'eslint-config-prettier';
|
|
3
|
+
import turbo from 'eslint-plugin-turbo';
|
|
4
|
+
import globals from 'globals';
|
|
5
|
+
import tseslint from 'typescript-eslint';
|
|
6
|
+
|
|
7
|
+
import importConfig from './configs/import.js';
|
|
8
|
+
import typescriptConfig from './configs/typescript.js';
|
|
9
|
+
|
|
10
|
+
export default tseslint.config(
|
|
11
|
+
{
|
|
12
|
+
// TODO: can't name this because ignores needs to be the only entry in order to be global
|
|
13
|
+
// name: 'ts/ignores',
|
|
14
|
+
ignores: ['dist/', '.wrangler/'],
|
|
15
|
+
},
|
|
16
|
+
turbo.configs['flat/recommended'],
|
|
17
|
+
Object.assign({ name: '@eslint/js/recommended' }, js.configs.recommended),
|
|
18
|
+
...importConfig,
|
|
19
|
+
{
|
|
20
|
+
name: 'ts/config-file-globals',
|
|
21
|
+
files: ['*.config.{cjs,js,ts}'],
|
|
22
|
+
languageOptions: {
|
|
23
|
+
globals: globals.node,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
...typescriptConfig,
|
|
27
|
+
prettier,
|
|
28
|
+
);
|
package/src/vitest.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import vitest from '@vitest/eslint-plugin';
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
3
|
+
|
|
4
|
+
export default tseslint.config(
|
|
5
|
+
Object.assign({ name: 'vitest/recommended' }, vitest.configs.recommended),
|
|
6
|
+
{
|
|
7
|
+
name: 'custom/vitest',
|
|
8
|
+
files: ['**/*.test.{ts,tsx}'],
|
|
9
|
+
rules: {
|
|
10
|
+
'vitest/consistent-test-it': [
|
|
11
|
+
'error',
|
|
12
|
+
{
|
|
13
|
+
fn: 'test',
|
|
14
|
+
withinDescribe: 'test',
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
'vitest/no-focused-tests': 'error',
|
|
18
|
+
'vitest/no-disabled-tests': 'error',
|
|
19
|
+
'vitest/prefer-lowercase-title': [
|
|
20
|
+
'warn',
|
|
21
|
+
{
|
|
22
|
+
ignoreTopLevelDescribe: true,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
'vitest/valid-expect': 'off',
|
|
26
|
+
// Disable certain strict typescript eslint rules for tests
|
|
27
|
+
// https://github.com/vitest-dev/vitest/issues/4543#issuecomment-1824881253
|
|
28
|
+
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
);
|