@neos21/neos-eslint-plugin
v0.0.4
Published
Neo's ESLint Plugins
Readme
Neo's ESLint Plugin
オレオレ ESLint プラグイン集。
使い方
$ npm install --save-dev @neos21/neos-eslint-pluginESLint v9 以降の Flat Config を前提としています。
eslint.config.ts(or ESM) : 使用したいルールだけをrulesに記載し、warnまたはerrorを指定します
import neosEslintPlugin from '@neos21/neos-eslint-plugin';
export default [
{
files: ['src/**/*.{js,jsx,ts,tsx}'],
plugins: {
'neos-eslint-plugin': neosEslintPlugin
},
rules: {
'neos-eslint-plugin/blank-line-indent' : 'error',
'neos-eslint-plugin/comment-colon-spacing' : 'error',
'neos-eslint-plugin/comment-paren-spacing' : 'error',
'neos-eslint-plugin/doc-comment-blank-lines' : 'error',
'neos-eslint-plugin/doc-comment-format' : 'error',
'neos-eslint-plugin/newline-before-statement': 'error',
'neos-eslint-plugin/no-space-before-paren' : 'error'
}
}
];全ルールを推奨設定を利用する場合は以下のように書けます。
import neosEslintPlugin from '@neos21/neos-eslint-plugin';
export default [
{ files: ['src/**/*.{js,jsx,ts,tsx}'] },
neosEslintPlugin.configs.recommended
];全ルールをエラーレベルではなくワーニングレベルで出力する場合は以下を使用できます。
import neosEslintPlugin from '@neos21/neos-eslint-plugin';
export default [
{ files: ['src/**/*.{js,jsx,ts,tsx}'] },
neosEslintPlugin.configs.warn
];CommonJS での利用時は .default を付けて require() してください。後の書き方は同じです。
const neosEslintPlugin = require('@neos21/neos-eslint-plugin').default;
module.exports = [...];ルール一覧
blank-line-indent: 空行にその行が属するブロックのインデント深さに合わせたスペースを入れる … Auto Fix 対応comment-colon-spacing: 全角コロンを禁止し、半角コロンの前後にスペースを付与する … Auto Fix 対応comment-paren-spacing: 全角カッコを禁止し、半角カッコの前後にスペースを付与する … Auto Fix 対応doc-comment-blank-lines: ドキュメンテーションコメントが1行で済む場合は1行で書き、複数行ある場合の2行目と@paramなどのかたまりの直前には空行を入れる … Auto Fix 対応doc-comment-format: ドキュメンテーションコメントの空行の末尾にスペースを入れる … Auto Fix 対応newline-before-statement:else・else if・catch・finally・whileの直前に改行を入れる … Auto Fix 対応no-space-before-paren:if・else if・catch・for・switch・whileの直後のカッコとの間にスペースを開けない … Auto Fix 対応
開発
package.jsonmain: CommonJS のエントリポイントmodule: ESM のエントリポイントtypes: TypeScript 向け型定義.d.tsのエントリポイントexports: Node.js v12 以降向けのエントリポイント定義require: CommonJSimport: ESMtypes: TypeScript
files:npm publish時に同梱されるファイル・ディレクトリpeerDependencies: Flat Config 前提のため ESLint v9 以降を対象とするよう指定した
.npmignore:package.jsonのfilesと併せて除外するファイル・ディレクトリを定義する・ビルド後の資材だけ含まれる用に設定した
