Skip to content

Commit

Permalink
change!(stylistic): @stylistic/{js,ts,jsx} -> @stylistic/ (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
taiyme authored Mar 6, 2025
1 parent 81af1a5 commit a8a705b
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 204 deletions.
20 changes: 0 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,6 @@ taiyのためのESLint共有設定です。
pnpm add -D eslint jiti globals @typescript-eslint/parser eslint-config-flat-gitignore @taiyme/eslint-config
```

### ピア依存関係の修正

peerDependenciesに関する警告を解消するには、`package.json``pnpm.overrides` フィールドを追加します。

```jsonc
{
"pnpm": {
"overrides": {
"eslint": "$eslint"
}
}
}
```

依存関係を再インストールします。

```sh
pnpm install
```

## 使い方

### `eslint.config.ts` の設定
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
},
"dependencies": {
"@eslint/js": "9.21.0",
"@stylistic/eslint-plugin-js": "4.2.0",
"@stylistic/eslint-plugin-jsx": "4.2.0",
"@stylistic/eslint-plugin-ts": "4.2.0",
"@stylistic/eslint-plugin": "4.2.0",
"eslint-plugin-jsx-a11y": "6.10.2",
"eslint-plugin-react": "7.37.4",
"eslint-plugin-react-hooks": "5.2.0",
Expand Down
71 changes: 19 additions & 52 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pnpm-workspace.yaml

This file was deleted.

11 changes: 7 additions & 4 deletions src/configs/react/recommended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
import reactPlugin from 'eslint-plugin-react';
import hooksPlugin from 'eslint-plugin-react-hooks';

import { excludeLegacyRules } from '../../utils/exclude-legacy-rules.js';
import { reactSharedSetup } from './shared.js';

export const reactRecommendedPlugins = {
Expand All @@ -12,10 +13,12 @@ export const reactRecommendedPlugins = {
} as const satisfies Record<string, ESLint.Plugin>;

export const reactRecommendedRules = {
...reactPlugin.configs.flat.recommended?.rules,
...reactPlugin.configs.flat['jsx-runtime']?.rules,
...hooksPlugin.configs['recommended-latest'].rules,
...jsxA11yPlugin.flatConfigs.recommended.rules,
...excludeLegacyRules({
...reactPlugin.configs.flat.recommended?.rules,
...reactPlugin.configs.flat['jsx-runtime']?.rules,
...hooksPlugin.configs['recommended-latest'].rules,
...jsxA11yPlugin.flatConfigs.recommended.rules,
}),

//#region React
'react/prop-types': 'off',
Expand Down
42 changes: 18 additions & 24 deletions src/configs/react/stylistic.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
import stylisticJsx from '@stylistic/eslint-plugin-jsx';
import stylistic from '@stylistic/eslint-plugin';
import type { ESLint, Linter } from 'eslint';
import reactPlugin from 'eslint-plugin-react';

import { reactSharedSetup } from './shared.js';

export const reactStylisticPlugins = {
react: reactPlugin as ESLint.Plugin,
'@stylistic/jsx': stylisticJsx as ESLint.Plugin,
'@stylistic': stylistic as ESLint.Plugin,
} as const satisfies Record<string, ESLint.Plugin>;

export const reactStylisticRules = {
...stylisticJsx.configs['disable-legacy'].rules,

//#region JSX (Stylistic)
'@stylistic/jsx/jsx-child-element-spacing': 'warn',
'@stylistic/jsx/jsx-closing-bracket-location': ['warn', 'tag-aligned'],
'@stylistic/jsx/jsx-closing-tag-location': 'warn',
'@stylistic/jsx/jsx-curly-brace-presence': ['warn', {
'@stylistic/jsx-child-element-spacing': 'warn',
'@stylistic/jsx-closing-bracket-location': ['warn', 'tag-aligned'],
'@stylistic/jsx-closing-tag-location': 'warn',
'@stylistic/jsx-curly-brace-presence': ['warn', {
props: 'never',
children: 'ignore',
propElementValues: 'always',
}],
'@stylistic/jsx/jsx-curly-newline': ['warn', {
'@stylistic/jsx-curly-newline': ['warn', {
multiline: 'consistent',
singleline: 'consistent',
}],
'@stylistic/jsx/jsx-curly-spacing': ['warn', {
'@stylistic/jsx-curly-spacing': ['warn', {
when: 'never',
attributes: {
allowMultiline: true,
Expand All @@ -35,26 +30,26 @@ export const reactStylisticRules = {
objectLiterals: 'never',
},
}],
'@stylistic/jsx/jsx-equals-spacing': ['warn', 'never'],
'@stylistic/jsx/jsx-first-prop-new-line': ['warn', 'multiline-multiprop'],
'@stylistic/jsx/jsx-function-call-newline': ['warn', 'multiline'],
'@stylistic/jsx/jsx-indent-props': ['warn', 2],
'@stylistic/jsx/jsx-max-props-per-line': ['warn', {
'@stylistic/jsx-equals-spacing': ['warn', 'never'],
'@stylistic/jsx-first-prop-new-line': ['warn', 'multiline-multiprop'],
'@stylistic/jsx-function-call-newline': ['warn', 'multiline'],
'@stylistic/jsx-indent-props': ['warn', 2],
'@stylistic/jsx-max-props-per-line': ['warn', {
maximum: {
single: 3,
multi: 1,
},
}],
'@stylistic/jsx/jsx-pascal-case': 'warn',
'@stylistic/jsx/jsx-props-no-multi-spaces': 'warn',
'@stylistic/jsx/jsx-self-closing-comp': 'warn',
'@stylistic/jsx/jsx-tag-spacing': ['warn', {
'@stylistic/jsx-pascal-case': 'warn',
'@stylistic/jsx-props-no-multi-spaces': 'warn',
'@stylistic/jsx-self-closing-comp': 'warn',
'@stylistic/jsx-tag-spacing': ['warn', {
closingSlash: 'never',
beforeSelfClosing: 'always',
afterOpening: 'never',
beforeClosing: 'never',
}],
'@stylistic/jsx/jsx-wrap-multilines': ['warn', {
'@stylistic/jsx-wrap-multilines': ['warn', {
declaration: 'parens-new-line',
assignment: 'parens-new-line',
return: 'parens-new-line',
Expand All @@ -64,7 +59,6 @@ export const reactStylisticRules = {
prop: 'parens-new-line',
propertyValue: 'parens-new-line',
}],
//#endregion JSX (Stylistic)
} as const satisfies Linter.RulesRecord as Linter.RulesRecord; // satisfies T as T は型安全かつ型制限するため

export const reactStylisticConfigs = [
Expand Down
9 changes: 6 additions & 3 deletions src/configs/typescript/recommended.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import eslint from '@eslint/js';
import eslintJs from '@eslint/js';
import type { ESLint, Linter } from 'eslint';
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
import unusedImportsPlugin from 'eslint-plugin-unused-imports';
import tsEslint from 'typescript-eslint';

import { excludeLegacyRules } from '../../utils/exclude-legacy-rules.js';
import { typescriptSharedSetup } from './shared.js';

export const typescriptRecommendedPlugins = {
Expand All @@ -13,8 +14,10 @@ export const typescriptRecommendedPlugins = {
} as const satisfies Record<string, ESLint.Plugin>;

export const typescriptRecommendedRules = {
...eslint.configs.recommended.rules,
...(Object.assign({}, ...tsEslint.configs.recommended.map((config) => config.rules))),
...excludeLegacyRules({
...eslintJs.configs.recommended.rules,
...(Object.assign({}, ...tsEslint.configs.recommended.map((config) => config.rules))),
}),

//#region JavaScript
eqeqeq: ['error', 'always', {
Expand Down
Loading

0 comments on commit a8a705b

Please sign in to comment.