@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.
@@ -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 }}
@@ -0,0 +1 @@
1
+ pnpm-lock.yaml
@@ -0,0 +1,5 @@
1
+ plugins:
2
+ - prettier-plugin-packagejson
3
+ - '@stzhu/prettier-plugin-tsconfig'
4
+ singleQuote: true
5
+ trailingComma: all
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`
@@ -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
@@ -0,0 +1,12 @@
1
+ {
2
+ "exclude": ["node_modules"],
3
+ "compilerOptions": {
4
+ "skipLibCheck": true,
5
+ "module": "Node16",
6
+ "moduleResolution": "Node16",
7
+ "noEmit": true,
8
+ "allowJs": true,
9
+ "checkJs": true,
10
+ "maxNodeModuleJsDepth": 0
11
+ }
12
+ }
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,2 @@
1
+ onlyBuiltDependencies:
2
+ - unrs-resolver
@@ -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
@@ -0,0 +1,7 @@
1
+ import expo from 'eslint-config-expo/flat.js';
2
+ import prettier from 'eslint-config-prettier';
3
+ import tseslint from 'typescript-eslint';
4
+
5
+ import importConfig from './configs/import.js';
6
+
7
+ export default tseslint.config(...expo, ...importConfig, prettier);
package/src/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import { config } from 'typescript-eslint';
2
+
3
+ export const defineConfig = config;
package/src/lingui.js ADDED
@@ -0,0 +1,4 @@
1
+ import pluginLingui from 'eslint-plugin-lingui';
2
+ import tseslint from 'typescript-eslint';
3
+
4
+ export default tseslint.config(pluginLingui.configs['flat/recommended']);
package/src/node.js ADDED
@@ -0,0 +1,10 @@
1
+ import globals from 'globals';
2
+ import tseslint from 'typescript-eslint';
3
+
4
+ import baseConfig from './ts.js';
5
+
6
+ export default tseslint.config(...baseConfig, {
7
+ languageOptions: {
8
+ globals: globals.node,
9
+ },
10
+ });
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
+ );
@@ -0,0 +1,4 @@
1
+ import storybook from 'eslint-plugin-storybook';
2
+ import tseslint from 'typescript-eslint';
3
+
4
+ export default tseslint.config(...storybook.configs['flat/recommended']);
@@ -0,0 +1,4 @@
1
+ import tailwind from 'eslint-plugin-tailwindcss';
2
+ import tseslint from 'typescript-eslint';
3
+
4
+ export default tseslint.config(...tailwind.configs['flat/recommended']);
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
+ );