@bemoje/eslint 2.1.7 → 2.1.8

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/lib/index.cjs CHANGED
@@ -198,3 +198,5 @@ exports.eslintPluginBemoje = eslintPluginBemoje;
198
198
  exports.noBlankLineBetweenCommentAndDeclaration = noBlankLineBetweenCommentAndDeclaration;
199
199
  exports.ruleForEslint = ruleForEslint;
200
200
  exports.splitImports = splitImports;
201
+ //# sourceMappingURL=index.cjs.map
202
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/createRule.ts","../../src/rules/noBlankLineBetweenCommentAndDeclaration.ts","../../src/lib/ruleForEslint.ts","../../src/rules/splitImports.ts","../../src/lib/bemojePlugin.ts","../../src/configs/enforceNoBlankLineBetweenCommentAndDeclaration.ts","../../src/configs/enforceSplitImports.ts","../../src/lib/eslintPluginBemoje.ts"],"names":["createRule","ESLintUtils","RuleCreator","name","noBlankLineBetweenCommentAndDeclaration","meta","fixable","docs","description","recommended","messages","type","schema","defaultOptions","create","context","Program","program","comments","forEach","comment","AST_TOKEN_TYPES","Block","Math","abs","loc","start","line","end","before","sourceCode","getTokenBefore","includeComments","nextToken","getTokenAfter","Line","actualNextTokenStartLine","expectedTokenStartLine","report","messageId","fix","fixer","gap","text","slice","range","lineBreak","includes","indentation","lastIndexOf","replaceTextRange","ruleForEslint","rule","splitImports","ImportDeclaration","node","specifiers","length","fromModule","getText","source","importClause","specifier","local","AST_NODE_TYPES","ImportDefaultSpecifier","ImportNamespaceSpecifier","imported","isTypeImport","importKind","ImportSpecifier","importStrings","map","join","hasCommentInside","getCommentsInside","replaceText","bemojePlugin","rules","enforceNoBlankLineBetweenCommentAndDeclaration","plugins","bemoje","enforceSplitImports","eslintPluginBemoje","configs","Object","fromEntries","keys","version"],"mappings":";;;;;;AAKO,IAAMA,aAAaC,iBAAAA,CAAYC,WAAAA,CAInC,CAACC,IAAAA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F,GAAA;AACF;AAvBgBK,MAAAA,CAAAA,kBAAAA,EAAAA,oBAAAA,CAAAA","file":"index.cjs","sourcesContent":["import { ESLintUtils } from '@typescript-eslint/utils'\n\n/**\n * Helper to create an ESLint rule with a consistent format.\n */\nexport const createRule = ESLintUtils.RuleCreator<{\n description: string\n recommended?: boolean\n requiresTypeChecking?: boolean\n}>((name) => `https://github.com/bemoje/mono/blob/dev/libs/eslint/README.md#${name}`)\n","import { AST_TOKEN_TYPES } from '@typescript-eslint/utils'\nimport { createRule } from '../lib/createRule.js'\n\n/**\n * Enforce no blank lines between block comments and the next declaration. A file's header, the comment that nothing\n * comes before, is left alone.\n */\nexport const noBlankLineBetweenCommentAndDeclaration = createRule({\n name: 'no-blank-line-between-comment-and-declaration',\n meta: {\n fixable: 'whitespace',\n docs: { description: 'Consistant whitespace ', recommended: true },\n messages: {\n 'no-blank-line-between-comment-and-declaration':\n 'Block comments for a declaration must not leave blank lines between them.',\n },\n type: 'problem',\n schema: [],\n },\n defaultOptions: ['error'],\n\n create(context) {\n return {\n Program(program) {\n program.comments?.forEach((comment) => {\n // ignore if not a block comment\n if (comment.type !== AST_TOKEN_TYPES.Block) {\n return\n }\n\n // ignore single line block comments\n if (Math.abs(comment.loc.start.line - comment.loc.end.line) < 2) {\n return\n }\n\n // A file's header is about the file, not about the first declaration: the comment that nothing comes before\n // (a shebang line aside) keeps its blank line, so the editor does not show it as that declaration's own.\n const before = context.sourceCode.getTokenBefore(comment, { includeComments: true })\n if (!before || (before.type as string) === 'Shebang') {\n return\n }\n\n // skip if comment is last thing in file\n const nextToken = context.sourceCode.getTokenAfter(comment, { includeComments: true })\n if (!nextToken) {\n return\n }\n\n // Only the comment right before the code is judged. A comment followed by another comment of any kind (a\n // file header before a doc comment, a license before a note) is not the comment of a declaration.\n if (nextToken.type === AST_TOKEN_TYPES.Block || nextToken.type === AST_TOKEN_TYPES.Line) {\n return\n }\n\n // end of comment should have no lines gap before the next token\n const actualNextTokenStartLine = nextToken.loc.start.line\n const expectedTokenStartLine = comment.loc.end.line + 1\n if (!(actualNextTokenStartLine > expectedTokenStartLine)) {\n return\n }\n\n return context.report({\n // Where the gap is: from the end of the comment to the start of the code after it\n loc: { start: comment.loc.end, end: nextToken.loc.start },\n messageId: 'no-blank-line-between-comment-and-declaration',\n fix(fixer) {\n // Between the comment and the code there is only whitespace: it becomes one line break, of the kind the\n // file uses, and the indentation the code's line had.\n const gap = context.sourceCode.text.slice(comment.range[1], nextToken.range[0])\n const lineBreak = gap.includes('\\r\\n') ? '\\r\\n' : '\\n'\n const indentation = gap.slice(gap.lastIndexOf('\\n') + 1)\n return fixer.replaceTextRange([comment.range[1], nextToken.range[0]], lineBreak + indentation)\n },\n })\n })\n },\n }\n },\n})\n","/**\n * The types this package's plugin and config entries are offered under. They say what ESLint's own config type\n * (`Linter.Config`) asks for and nothing more, so an entry goes into a typed config with no cast. A rule keeps its\n * full typescript-eslint type where it is declared: that type does not fit ESLint's, which is why presets written\n * with typescript-eslint usually need `as Linter.Config[]` where they are used. ESLint itself is not imported here,\n * so the package does not depend on a version of it.\n */\n\n/** A rule as ESLint's config type asks for it: what `create` is given, and what its listeners take, is ESLint's own. */\nexport interface RuleForEslint {\n meta?: object\n create: (context: never) => Record<string, ((...args: any[]) => void) | undefined>\n}\n\n/** A plugin as ESLint's config type asks for it. */\nexport interface PluginForEslint {\n meta: { name: string; version?: string }\n rules: Record<string, RuleForEslint>\n}\n\n/** One entry of a flat config that registers a plugin and turns rules of it on. */\nexport interface ConfigForEslint {\n name?: string\n plugins: Record<string, PluginForEslint>\n rules: Record<string, 'error'>\n}\n\n/**\n * A rule written with typescript-eslint, as the type ESLint's config asks for. The one cast of this package: the two\n * rule types differ only in the node types their listeners name (a listener of typescript-eslint takes its own node\n * types, and in 8.57 its catch-all listener takes `never`), never in what runs.\n */\nexport const ruleForEslint = (rule: { meta?: object; create: (context: never) => object }): RuleForEslint =>\n rule as unknown as RuleForEslint\n","import { AST_NODE_TYPES } from '@typescript-eslint/utils'\nimport type { TSESTree } from '@typescript-eslint/utils'\nimport { createRule } from '../lib/createRule'\n\n/**\n * Require one import declaration per imported name: `import { a, b } from 'mod'` becomes two declarations.\n */\nexport const splitImports = createRule({\n name: 'split-imports',\n meta: {\n docs: { description: 'Require one line per import, disallow multiple imports' },\n fixable: 'code',\n messages: { 'split-import': 'Split multi-import into seperate import declarations.' },\n type: 'suggestion',\n schema: [],\n },\n\n create(context) {\n return {\n ImportDeclaration(node) {\n if (node.specifiers.length > 1) {\n const sourceCode = context.sourceCode\n\n // What follows the imported names, as written: the module path in its own quotes, import attributes\n // (`with { type: 'json' }`) and the semicolon, if the declaration has them.\n const fromModule = sourceCode.getText(node).slice(node.source.range[0] - node.range[0])\n\n // What kind of import a specifier is comes from the syntax tree, never from its text: a name inside the\n // braces keeps its braces whether or not it carries the `type` keyword.\n const importClause = (specifier: TSESTree.ImportClause) => {\n const local = specifier.local.name\n\n if (specifier.type === AST_NODE_TYPES.ImportDefaultSpecifier) {\n return local\n }\n\n if (specifier.type === AST_NODE_TYPES.ImportNamespaceSpecifier) {\n return `* as ${local}`\n }\n\n const imported = sourceCode.getText(specifier.imported)\n\n return imported === local ? `{ ${local} }` : `{ ${imported} as ${local} }`\n }\n\n const isTypeImport = (specifier: TSESTree.ImportClause) =>\n node.importKind === 'type' ||\n (specifier.type === AST_NODE_TYPES.ImportSpecifier && specifier.importKind === 'type')\n\n const importStrings = node.specifiers.map((specifier) =>\n [isTypeImport(specifier) ? 'import type' : 'import', importClause(specifier), 'from', fromModule].join(\n ' '\n )\n )\n\n // A comment inside the declaration would be lost by the rewrite, so such a declaration is reported and\n // left for a person to split.\n const hasCommentInside = sourceCode.getCommentsInside(node).length > 0\n\n context.report({\n fix: hasCommentInside ? null : (fixer) => fixer.replaceText(node, importStrings.join('\\n')),\n messageId: 'split-import',\n node,\n })\n }\n },\n }\n },\n})\n","import type { PluginForEslint } from './ruleForEslint'\nimport { noBlankLineBetweenCommentAndDeclaration } from '../rules/noBlankLineBetweenCommentAndDeclaration'\nimport { ruleForEslint } from './ruleForEslint'\nimport { splitImports } from '../rules/splitImports'\n\n/**\n * The one plugin object that every ready-made config entry of this package registers, under the name `bemoje`.\n * ESLint accepts the same plugin name in several config entries only when it is the same object each time, so the\n * entries share this one. A rule's full name is `bemoje/<rule>`, for an `eslint-disable` comment.\n */\nexport const bemojePlugin: PluginForEslint = {\n meta: { name: '@bemoje/eslint' },\n rules: {\n 'no-blank-line-between-comment-and-declaration': ruleForEslint(noBlankLineBetweenCommentAndDeclaration),\n 'split-imports': ruleForEslint(splitImports),\n },\n}\n","import type { ConfigForEslint } from '../lib/ruleForEslint'\nimport { bemojePlugin } from '../lib/bemojePlugin'\n\n/**\n * A ready-made ESLint flat config entry that turns the rule `no-blank-line-between-comment-and-declaration` on as an\n * error: a block comment over several lines has no blank line between it and the code right after it. Put it in the\n * list a config file exports, with no plugin to register and no rule name to type.\n */\nexport const enforceNoBlankLineBetweenCommentAndDeclaration: ConfigForEslint = {\n name: '@bemoje/eslint/no-blank-line-between-comment-and-declaration',\n plugins: { bemoje: bemojePlugin },\n rules: { 'bemoje/no-blank-line-between-comment-and-declaration': 'error' },\n}\n","import type { ConfigForEslint } from '../lib/ruleForEslint'\nimport { bemojePlugin } from '../lib/bemojePlugin'\n\n/**\n * A ready-made ESLint flat config entry that turns the rule `split-imports` on as an error: one import declaration\n * per imported name. Put it in the list a config file exports, with no plugin to register and no rule name to type.\n */\nexport const enforceSplitImports: ConfigForEslint = {\n name: '@bemoje/eslint/split-imports',\n plugins: { bemoje: bemojePlugin },\n rules: { 'bemoje/split-imports': 'error' },\n}\n","import type { PluginForEslint } from './ruleForEslint'\nimport { bemojePlugin } from './bemojePlugin'\n\n/** What `eslintPluginBemoje()` returns: the plugin, and a config that registers it and turns every rule on. */\nexport interface EslintPluginBemoje extends PluginForEslint {\n configs: {\n recommended: {\n plugins: { 'eslint-plugin-bemoje': EslintPluginBemoje }\n rules: Record<string, 'error'>\n }\n }\n}\n\n/**\n * ESLint plugin for Bemoje projects.\n */\nexport function eslintPluginBemoje(): EslintPluginBemoje {\n const rules = bemojePlugin.rules\n\n const plugins = {\n get 'eslint-plugin-bemoje'() {\n return eslintPluginBemoje()\n },\n }\n\n return {\n configs: {\n get recommended() {\n return {\n plugins,\n rules: Object.fromEntries(\n Object.keys(rules).map((name) => [`eslint-plugin-bemoje/${name}`, 'error' as const])\n ),\n }\n },\n },\n meta: { name: 'eslint-plugin-bemoje', version: '2.1.2' },\n rules,\n }\n}\n"]}
package/lib/index.js CHANGED
@@ -189,3 +189,5 @@ function eslintPluginBemoje() {
189
189
  __name(eslintPluginBemoje, "eslintPluginBemoje");
190
190
 
191
191
  export { bemojePlugin, createRule, enforceNoBlankLineBetweenCommentAndDeclaration, enforceSplitImports, eslintPluginBemoje, noBlankLineBetweenCommentAndDeclaration, ruleForEslint, splitImports };
192
+ //# sourceMappingURL=index.js.map
193
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/createRule.ts","../../src/rules/noBlankLineBetweenCommentAndDeclaration.ts","../../src/lib/ruleForEslint.ts","../../src/rules/splitImports.ts","../../src/lib/bemojePlugin.ts","../../src/configs/enforceNoBlankLineBetweenCommentAndDeclaration.ts","../../src/configs/enforceSplitImports.ts","../../src/lib/eslintPluginBemoje.ts"],"names":["createRule","ESLintUtils","RuleCreator","name","noBlankLineBetweenCommentAndDeclaration","meta","fixable","docs","description","recommended","messages","type","schema","defaultOptions","create","context","Program","program","comments","forEach","comment","AST_TOKEN_TYPES","Block","Math","abs","loc","start","line","end","before","sourceCode","getTokenBefore","includeComments","nextToken","getTokenAfter","Line","actualNextTokenStartLine","expectedTokenStartLine","report","messageId","fix","fixer","gap","text","slice","range","lineBreak","includes","indentation","lastIndexOf","replaceTextRange","ruleForEslint","rule","splitImports","ImportDeclaration","node","specifiers","length","fromModule","getText","source","importClause","specifier","local","AST_NODE_TYPES","ImportDefaultSpecifier","ImportNamespaceSpecifier","imported","isTypeImport","importKind","ImportSpecifier","importStrings","map","join","hasCommentInside","getCommentsInside","replaceText","bemojePlugin","rules","enforceNoBlankLineBetweenCommentAndDeclaration","plugins","bemoje","enforceSplitImports","eslintPluginBemoje","configs","Object","fromEntries","keys","version"],"mappings":";;;;AAKO,IAAMA,aAAaC,WAAAA,CAAYC,WAAAA,CAInC,CAACC,IAAAA,KAAS,CAAA,8DAAA,EAAiEA,IAAAA,CAAAA,CAAM;;;ACF7E,IAAMC,0CAA0CJ,UAAAA,CAAW;EAChEG,IAAAA,EAAM,+CAAA;EACNE,IAAAA,EAAM;IACJC,OAAAA,EAAS,YAAA;IACTC,IAAAA,EAAM;MAAEC,WAAAA,EAAa,wBAAA;MAA0BC,WAAAA,EAAa;AAAK,KAAA;IACjEC,QAAAA,EAAU;MACR,+CAAA,EACE;AACJ,KAAA;IACAC,IAAAA,EAAM,SAAA;AACNC,IAAAA,MAAAA,EAAQ;AACV,GAAA;EACAC,cAAAA,EAAgB;AAAC,IAAA;;AAEjBC,EAAAA,MAAAA,CAAOC,OAAAA,EAAO;AACZ,IAAA,OAAO;AACLC,MAAAA,OAAAA,CAAQC,OAAAA,EAAO;AACbA,QAAAA,OAAAA,CAAQC,QAAAA,EAAUC,OAAAA,CAAQ,CAACC,OAAAA,KAAAA;AAEzB,UAAA,IAAIA,OAAAA,CAAQT,IAAAA,KAASU,eAAAA,CAAgBC,KAAAA,EAAO;AAC1C,YAAA;AACF,UAAA;AAGA,UAAA,IAAIC,IAAAA,CAAKC,GAAAA,CAAIJ,OAAAA,CAAQK,GAAAA,CAAIC,KAAAA,CAAMC,IAAAA,GAAOP,OAAAA,CAAQK,GAAAA,CAAIG,GAAAA,CAAID,IAAI,CAAA,GAAI,CAAA,EAAG;AAC/D,YAAA;AACF,UAAA;AAIA,UAAA,MAAME,MAAAA,GAASd,OAAAA,CAAQe,UAAAA,CAAWC,cAAAA,CAAeX,OAAAA,EAAS;YAAEY,eAAAA,EAAiB;WAAK,C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AACrE,IAAAA,KAAS;AAAC,YAAA,CAAA,qBAAA,EAAwBA,IAAAA,CAAAA,CAAAA;AAAQ,YAAA;WAAiB,CAAA;AAEvF,SAAA;AACF,MAAA;AACF,KAAA;IACAE,IAAAA,EAAM;MAAEF,IAAAA,EAAM,sBAAA;MAAwBqF,OAAAA,EAAS;AAAQ,KAAA;AACvDV,IAAAA;AACF,GAAA;AACF;AAvBgBK,MAAAA,CAAAA,kBAAAA,EAAAA,oBAAAA,CAAAA","file":"index.js","sourcesContent":["import { ESLintUtils } from '@typescript-eslint/utils'\n\n/**\n * Helper to create an ESLint rule with a consistent format.\n */\nexport const createRule = ESLintUtils.RuleCreator<{\n description: string\n recommended?: boolean\n requiresTypeChecking?: boolean\n}>((name) => `https://github.com/bemoje/mono/blob/dev/libs/eslint/README.md#${name}`)\n","import { AST_TOKEN_TYPES } from '@typescript-eslint/utils'\nimport { createRule } from '../lib/createRule.js'\n\n/**\n * Enforce no blank lines between block comments and the next declaration. A file's header, the comment that nothing\n * comes before, is left alone.\n */\nexport const noBlankLineBetweenCommentAndDeclaration = createRule({\n name: 'no-blank-line-between-comment-and-declaration',\n meta: {\n fixable: 'whitespace',\n docs: { description: 'Consistant whitespace ', recommended: true },\n messages: {\n 'no-blank-line-between-comment-and-declaration':\n 'Block comments for a declaration must not leave blank lines between them.',\n },\n type: 'problem',\n schema: [],\n },\n defaultOptions: ['error'],\n\n create(context) {\n return {\n Program(program) {\n program.comments?.forEach((comment) => {\n // ignore if not a block comment\n if (comment.type !== AST_TOKEN_TYPES.Block) {\n return\n }\n\n // ignore single line block comments\n if (Math.abs(comment.loc.start.line - comment.loc.end.line) < 2) {\n return\n }\n\n // A file's header is about the file, not about the first declaration: the comment that nothing comes before\n // (a shebang line aside) keeps its blank line, so the editor does not show it as that declaration's own.\n const before = context.sourceCode.getTokenBefore(comment, { includeComments: true })\n if (!before || (before.type as string) === 'Shebang') {\n return\n }\n\n // skip if comment is last thing in file\n const nextToken = context.sourceCode.getTokenAfter(comment, { includeComments: true })\n if (!nextToken) {\n return\n }\n\n // Only the comment right before the code is judged. A comment followed by another comment of any kind (a\n // file header before a doc comment, a license before a note) is not the comment of a declaration.\n if (nextToken.type === AST_TOKEN_TYPES.Block || nextToken.type === AST_TOKEN_TYPES.Line) {\n return\n }\n\n // end of comment should have no lines gap before the next token\n const actualNextTokenStartLine = nextToken.loc.start.line\n const expectedTokenStartLine = comment.loc.end.line + 1\n if (!(actualNextTokenStartLine > expectedTokenStartLine)) {\n return\n }\n\n return context.report({\n // Where the gap is: from the end of the comment to the start of the code after it\n loc: { start: comment.loc.end, end: nextToken.loc.start },\n messageId: 'no-blank-line-between-comment-and-declaration',\n fix(fixer) {\n // Between the comment and the code there is only whitespace: it becomes one line break, of the kind the\n // file uses, and the indentation the code's line had.\n const gap = context.sourceCode.text.slice(comment.range[1], nextToken.range[0])\n const lineBreak = gap.includes('\\r\\n') ? '\\r\\n' : '\\n'\n const indentation = gap.slice(gap.lastIndexOf('\\n') + 1)\n return fixer.replaceTextRange([comment.range[1], nextToken.range[0]], lineBreak + indentation)\n },\n })\n })\n },\n }\n },\n})\n","/**\n * The types this package's plugin and config entries are offered under. They say what ESLint's own config type\n * (`Linter.Config`) asks for and nothing more, so an entry goes into a typed config with no cast. A rule keeps its\n * full typescript-eslint type where it is declared: that type does not fit ESLint's, which is why presets written\n * with typescript-eslint usually need `as Linter.Config[]` where they are used. ESLint itself is not imported here,\n * so the package does not depend on a version of it.\n */\n\n/** A rule as ESLint's config type asks for it: what `create` is given, and what its listeners take, is ESLint's own. */\nexport interface RuleForEslint {\n meta?: object\n create: (context: never) => Record<string, ((...args: any[]) => void) | undefined>\n}\n\n/** A plugin as ESLint's config type asks for it. */\nexport interface PluginForEslint {\n meta: { name: string; version?: string }\n rules: Record<string, RuleForEslint>\n}\n\n/** One entry of a flat config that registers a plugin and turns rules of it on. */\nexport interface ConfigForEslint {\n name?: string\n plugins: Record<string, PluginForEslint>\n rules: Record<string, 'error'>\n}\n\n/**\n * A rule written with typescript-eslint, as the type ESLint's config asks for. The one cast of this package: the two\n * rule types differ only in the node types their listeners name (a listener of typescript-eslint takes its own node\n * types, and in 8.57 its catch-all listener takes `never`), never in what runs.\n */\nexport const ruleForEslint = (rule: { meta?: object; create: (context: never) => object }): RuleForEslint =>\n rule as unknown as RuleForEslint\n","import { AST_NODE_TYPES } from '@typescript-eslint/utils'\nimport type { TSESTree } from '@typescript-eslint/utils'\nimport { createRule } from '../lib/createRule'\n\n/**\n * Require one import declaration per imported name: `import { a, b } from 'mod'` becomes two declarations.\n */\nexport const splitImports = createRule({\n name: 'split-imports',\n meta: {\n docs: { description: 'Require one line per import, disallow multiple imports' },\n fixable: 'code',\n messages: { 'split-import': 'Split multi-import into seperate import declarations.' },\n type: 'suggestion',\n schema: [],\n },\n\n create(context) {\n return {\n ImportDeclaration(node) {\n if (node.specifiers.length > 1) {\n const sourceCode = context.sourceCode\n\n // What follows the imported names, as written: the module path in its own quotes, import attributes\n // (`with { type: 'json' }`) and the semicolon, if the declaration has them.\n const fromModule = sourceCode.getText(node).slice(node.source.range[0] - node.range[0])\n\n // What kind of import a specifier is comes from the syntax tree, never from its text: a name inside the\n // braces keeps its braces whether or not it carries the `type` keyword.\n const importClause = (specifier: TSESTree.ImportClause) => {\n const local = specifier.local.name\n\n if (specifier.type === AST_NODE_TYPES.ImportDefaultSpecifier) {\n return local\n }\n\n if (specifier.type === AST_NODE_TYPES.ImportNamespaceSpecifier) {\n return `* as ${local}`\n }\n\n const imported = sourceCode.getText(specifier.imported)\n\n return imported === local ? `{ ${local} }` : `{ ${imported} as ${local} }`\n }\n\n const isTypeImport = (specifier: TSESTree.ImportClause) =>\n node.importKind === 'type' ||\n (specifier.type === AST_NODE_TYPES.ImportSpecifier && specifier.importKind === 'type')\n\n const importStrings = node.specifiers.map((specifier) =>\n [isTypeImport(specifier) ? 'import type' : 'import', importClause(specifier), 'from', fromModule].join(\n ' '\n )\n )\n\n // A comment inside the declaration would be lost by the rewrite, so such a declaration is reported and\n // left for a person to split.\n const hasCommentInside = sourceCode.getCommentsInside(node).length > 0\n\n context.report({\n fix: hasCommentInside ? null : (fixer) => fixer.replaceText(node, importStrings.join('\\n')),\n messageId: 'split-import',\n node,\n })\n }\n },\n }\n },\n})\n","import type { PluginForEslint } from './ruleForEslint'\nimport { noBlankLineBetweenCommentAndDeclaration } from '../rules/noBlankLineBetweenCommentAndDeclaration'\nimport { ruleForEslint } from './ruleForEslint'\nimport { splitImports } from '../rules/splitImports'\n\n/**\n * The one plugin object that every ready-made config entry of this package registers, under the name `bemoje`.\n * ESLint accepts the same plugin name in several config entries only when it is the same object each time, so the\n * entries share this one. A rule's full name is `bemoje/<rule>`, for an `eslint-disable` comment.\n */\nexport const bemojePlugin: PluginForEslint = {\n meta: { name: '@bemoje/eslint' },\n rules: {\n 'no-blank-line-between-comment-and-declaration': ruleForEslint(noBlankLineBetweenCommentAndDeclaration),\n 'split-imports': ruleForEslint(splitImports),\n },\n}\n","import type { ConfigForEslint } from '../lib/ruleForEslint'\nimport { bemojePlugin } from '../lib/bemojePlugin'\n\n/**\n * A ready-made ESLint flat config entry that turns the rule `no-blank-line-between-comment-and-declaration` on as an\n * error: a block comment over several lines has no blank line between it and the code right after it. Put it in the\n * list a config file exports, with no plugin to register and no rule name to type.\n */\nexport const enforceNoBlankLineBetweenCommentAndDeclaration: ConfigForEslint = {\n name: '@bemoje/eslint/no-blank-line-between-comment-and-declaration',\n plugins: { bemoje: bemojePlugin },\n rules: { 'bemoje/no-blank-line-between-comment-and-declaration': 'error' },\n}\n","import type { ConfigForEslint } from '../lib/ruleForEslint'\nimport { bemojePlugin } from '../lib/bemojePlugin'\n\n/**\n * A ready-made ESLint flat config entry that turns the rule `split-imports` on as an error: one import declaration\n * per imported name. Put it in the list a config file exports, with no plugin to register and no rule name to type.\n */\nexport const enforceSplitImports: ConfigForEslint = {\n name: '@bemoje/eslint/split-imports',\n plugins: { bemoje: bemojePlugin },\n rules: { 'bemoje/split-imports': 'error' },\n}\n","import type { PluginForEslint } from './ruleForEslint'\nimport { bemojePlugin } from './bemojePlugin'\n\n/** What `eslintPluginBemoje()` returns: the plugin, and a config that registers it and turns every rule on. */\nexport interface EslintPluginBemoje extends PluginForEslint {\n configs: {\n recommended: {\n plugins: { 'eslint-plugin-bemoje': EslintPluginBemoje }\n rules: Record<string, 'error'>\n }\n }\n}\n\n/**\n * ESLint plugin for Bemoje projects.\n */\nexport function eslintPluginBemoje(): EslintPluginBemoje {\n const rules = bemojePlugin.rules\n\n const plugins = {\n get 'eslint-plugin-bemoje'() {\n return eslintPluginBemoje()\n },\n }\n\n return {\n configs: {\n get recommended() {\n return {\n plugins,\n rules: Object.fromEntries(\n Object.keys(rules).map((name) => [`eslint-plugin-bemoje/${name}`, 'error' as const])\n ),\n }\n },\n },\n meta: { name: 'eslint-plugin-bemoje', version: '2.1.2' },\n rules,\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemoje/eslint",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
4
4
  "description": "Custom ESLint plugin and rule utilities for consistent code style in TypeScript projects.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -30,7 +30,9 @@
30
30
  "./lib/index.js",
31
31
  "./lib/index.d.ts",
32
32
  "./lib/index.cjs",
33
- "./lib/index.d.cts"
33
+ "./lib/index.d.cts",
34
+ "./lib/index.js.map",
35
+ "./lib/index.cjs.map"
34
36
  ],
35
37
  "exports": {
36
38
  ".": {