Skip to content

Commit

Permalink
chore: Add workspace config from Query (#45)
Browse files Browse the repository at this point in the history
* Update eslint config

* Add sherif and knip

* Update nx.json

* Enable method-signature-style
  • Loading branch information
lachlancollins committed Feb 17, 2024
1 parent d81cf5a commit 5235213
Show file tree
Hide file tree
Showing 21 changed files with 1,070 additions and 173 deletions.
52 changes: 42 additions & 10 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
/** @type {import('eslint').Linter.Config} */
const config = {
root: true,
reportUnusedDisableDirectives: true,
ignorePatterns: ['**/build', '**/coverage', '**/dist'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'compat', 'import'],
plugins: ['@typescript-eslint', 'import'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:compat/recommended',
'plugin:@typescript-eslint/stylistic',
'plugin:import/recommended',
'plugin:import/typescript',
'prettier',
Expand All @@ -19,7 +21,7 @@ const config = {
},
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
project: true,
sourceType: 'module',
ecmaVersion: 2020,
},
Expand All @@ -35,26 +37,56 @@ const config = {
},
},
rules: {
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports' },
],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/method-signature-style': 'error',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-inferrable-types': [
'error',
{
ignoreParameters: true,
},
{ ignoreParameters: true },
],
'no-shadow': 'error',
'@typescript-eslint/prefer-for-of': 'off',
'import/default': 'off',
'import/export': 'off',
'import/namespace': 'off',
'import/newline-after-import': 'error',
'import/no-cycle': 'error',
'import/no-duplicates': 'off',
'import/no-named-as-default-member': 'off',
'import/no-unresolved': ['error', { ignore: ['^@tanstack/'] }],
'import/no-unused-modules': ['off', { unusedExports: true }],
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
'type',
],
},
],
'no-async-promise-executor': 'off',
'no-empty': 'off',
'no-redeclare': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'no-shadow': 'error',
'no-undef': 'off',
'sort-imports': ['error', { ignoreDeclarationSort: true }],
},
overrides: [
{
Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
* text=auto eol=lf
17 changes: 3 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,9 @@ package-lock.json
yarn.lock

# builds
types
build
*/build
dist
lib
es
artifacts
.rpt2_cache
coverage
*.tgz
dist

# misc
.DS_Store
Expand All @@ -38,15 +31,11 @@ stats.html
.vscode/settings.json

*.log
.DS_Store
.cache
.pnpm-store
dist
.idea

nx-cloud.env

.nx/cache
.pnpm-store
.tsup

vite.config.js.timestamp-*
vite.config.ts.timestamp-*
11 changes: 11 additions & 0 deletions knip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/knip@4/schema.json",
"workspaces": {
"packages/angular-store": {
"ignoreDependencies": ["@angular/compiler-cli"]
},
"packages/vue-store": {
"ignoreDependencies": ["vue2", "vue2.7"]
}
}
}
8 changes: 8 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,17 @@
"inputs": ["^public"],
"cache": true
},
"test:knip": {
"cache": true,
"inputs": ["{workspaceRoot}/**/*"]
},
"test:format": {
"cache": true,
"inputs": ["{workspaceRoot}/**/*"]
},
"test:sherif": {
"cache": true,
"inputs": ["{workspaceRoot}/**/*"]
}
}
}
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
"test:ci": "nx run-many --targets=test:format,test:eslint,test:lib,test:types,test:build,build",
"test:eslint": "nx affected --target=test:eslint",
"test:format": "pnpm run prettier --check",
"test:sherif": "sherif",
"test:lib": "nx affected --target=test:lib --exclude=examples/**",
"test:lib:dev": "pnpm run test:lib && nx watch --all -- pnpm run test:lib",
"test:build": "nx affected --target=test:build --exclude=examples/**",
"test:types": "nx affected --target=test:types --exclude=examples/**",
"test:knip": "knip",
"build": "nx affected --target=build --exclude=examples/**",
"build:all": "nx run-many --target=build --exclude=examples/**",
"watch": "pnpm run build:all && nx watch --all -- pnpm run build:all",
Expand All @@ -28,7 +30,9 @@
},
"nx": {
"includedScripts": [
"test:format"
"test:format",
"test:knip",
"test:sherif"
]
},
"namespace": "@tanstack",
Expand All @@ -39,28 +43,29 @@
"@testing-library/react": "^14.1.2",
"@testing-library/user-event": "^14.4.3",
"@testing-library/vue": "^7.0.0",
"@types/eslint": "^8.56.0",
"@types/eslint": "^8.56.2",
"@types/jest": "^26.0.4",
"@types/node": "^18.19.3",
"@types/react": "^18.2.45",
"@types/react-dom": "^18.0.5",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vitest/coverage-istanbul": "^1.2.2",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-compat": "^4.2.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"jsdom": "^23.0.1",
"knip": "^4.6.0",
"nx": "^17.2.8",
"prettier": "^4.0.0-alpha.8",
"publint": "^0.2.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^5.0.5",
"sherif": "^0.7.0",
"solid-js": "^1.7.8",
"typescript": "^5.2.2",
"typescript49": "npm:typescript@4.9",
Expand Down
7 changes: 1 addition & 6 deletions packages/angular-store/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
},
}
const config = {}

module.exports = config
2 changes: 1 addition & 1 deletion packages/angular-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
},
"devDependencies": {
"@analogjs/vite-plugin-angular": "^0.2.32",
"@angular/core": "^17.1.2",
"@angular/common": "^17.1.2",
"@angular/compiler": "^17.1.2",
"@angular/compiler-cli": "^17.1.2",
"@angular/core": "^17.1.2",
"@angular/platform-browser": "^17.1.2",
"@angular/platform-browser-dynamic": "^17.1.2",
"zone.js": "^0.14.3"
Expand Down
6 changes: 3 additions & 3 deletions packages/angular-store/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
effect,
signal,
type CreateSignalOptions,
Injector,
assertInInjectionContext,
effect,
inject,
runInInjectionContext,
signal,
} from '@angular/core'
import type { AnyUpdater, Store } from '@tanstack/store'
import type { CreateSignalOptions } from '@angular/core'

type NoInfer<T> = [T][T extends any ? 0 : never]

Expand Down
4 changes: 0 additions & 4 deletions packages/react-store/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
/** @type {import('eslint').Linter.Config} */
const config = {
extends: ['plugin:react/recommended', 'plugin:react-hooks/recommended'],
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
},
rules: {
'react/jsx-key': ['error', { checkFragmentShorthand: true }],
'react-hooks/exhaustive-deps': 'error',
Expand Down
2 changes: 1 addition & 1 deletion packages/react-store/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AnyUpdater, Store } from '@tanstack/store'
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js'
import type { AnyUpdater, Store } from '@tanstack/store'

export * from '@tanstack/store'

Expand Down
2 changes: 1 addition & 1 deletion packages/react-store/src/tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { render, waitFor } from '@testing-library/react'
import '@testing-library/jest-dom'
import * as React from 'react'
import { Store } from '@tanstack/store'
import { useStore, shallow } from '../index'
import { useState } from 'react'
import userEvent from '@testing-library/user-event'
import { shallow, useStore } from '../index'

const user = userEvent.setup()

Expand Down
10 changes: 1 addition & 9 deletions packages/solid-store/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
},
rules: {
'no-unused-vars': 'off',
},
}
const config = {}

module.exports = config
4 changes: 2 additions & 2 deletions packages/solid-store/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { AnyUpdater, Store } from '@tanstack/store'
import type { Accessor } from 'solid-js'
import { onCleanup } from 'solid-js'
import { createStore, reconcile } from 'solid-js/store'
import type { AnyUpdater, Store } from '@tanstack/store'
import type { Accessor } from 'solid-js'

export * from '@tanstack/store'

Expand Down
7 changes: 1 addition & 6 deletions packages/store/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
},
}
const config = {}

module.exports = config
2 changes: 1 addition & 1 deletion packages/store/src/tests/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, test, expect, vi } from 'vitest'
import { describe, expect, test, vi } from 'vitest'
import { Store } from '../index'

describe('store', () => {
Expand Down
10 changes: 1 addition & 9 deletions packages/vue-store/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
},
rules: {
'no-unused-vars': 'off',
},
}
const config = {}

module.exports = config
3 changes: 2 additions & 1 deletion packages/vue-store/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { readonly, ref, toRaw, watch } from 'vue-demi'
import type { AnyUpdater, Store } from '@tanstack/store'
import { readonly, type Ref, ref, toRaw, watch } from 'vue-demi'
import type { Ref } from 'vue-demi'

export * from '@tanstack/store'

Expand Down
4 changes: 2 additions & 2 deletions packages/vue-store/src/tests/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// We need to import `h` as it's part of Vue's JSX transform
// @ts-expect-error
import { h, defineComponent } from 'vue-demi'
import { defineComponent, h } from 'vue-demi'
import { render, waitFor } from '@testing-library/vue'
import '@testing-library/jest-dom'
import { Store } from '@tanstack/store'
import { useStore, shallow } from '../index'
import userEvent from '@testing-library/user-event'
import { shallow, useStore } from '../index'

const user = userEvent.setup()

Expand Down
Loading

0 comments on commit 5235213

Please sign in to comment.