From c8facf4f68ac2d89a622962c26a2339a15dd7e25 Mon Sep 17 00:00:00 2001 From: Marko Kajzer Date: Sat, 21 Mar 2026 12:49:21 +0100 Subject: [PATCH 1/5] Linter: Implement `erb-space-indentation` rule --- .../packages/linter/docs/rules/README.md | 1 + .../docs/rules/erb-space-indentation.md | 29 +++++++++++ javascript/packages/linter/src/rules.ts | 2 + .../linter/src/rules/erb-space-indentation.ts | 50 +++++++++++++++++++ javascript/packages/linter/src/rules/index.ts | 1 + .../test/__snapshots__/cli.test.ts.snap | 6 +-- .../test/rules/erb-space-indentation.test.ts | 46 +++++++++++++++++ 7 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 javascript/packages/linter/docs/rules/erb-space-indentation.md create mode 100644 javascript/packages/linter/src/rules/erb-space-indentation.ts create mode 100644 javascript/packages/linter/test/rules/erb-space-indentation.test.ts diff --git a/javascript/packages/linter/docs/rules/README.md b/javascript/packages/linter/docs/rules/README.md index 063337b0b..f9a3969e7 100644 --- a/javascript/packages/linter/docs/rules/README.md +++ b/javascript/packages/linter/docs/rules/README.md @@ -34,6 +34,7 @@ This page contains documentation for all Herb Linter rules. - [`erb-require-trailing-newline`](./erb-require-trailing-newline.md) - Enforces that all HTML+ERB template files end with exactly one trailing newline character. - [`erb-require-whitespace-inside-tags`](./erb-require-whitespace-inside-tags.md) - Requires whitespace around ERB tags - [`erb-right-trim`](./erb-right-trim.md) - Enforce consistent right-trimming syntax. +- [`erb-space-indentation`](./erb-space-indentation.md) - Indent with spaces instead of tabs. - [`erb-strict-locals-comment-syntax`](./erb-strict-locals-comment-syntax.md) - Enforce strict locals comment syntax. - [`herb-disable-comment-malformed`](./herb-disable-comment-malformed.md) - Detect malformed `herb:disable` comments. - [`herb-disable-comment-missing-rules`](./herb-disable-comment-missing-rules.md) - Require rule names in `herb:disable` comments. diff --git a/javascript/packages/linter/docs/rules/erb-space-indentation.md b/javascript/packages/linter/docs/rules/erb-space-indentation.md new file mode 100644 index 000000000..3f025dbaa --- /dev/null +++ b/javascript/packages/linter/docs/rules/erb-space-indentation.md @@ -0,0 +1,29 @@ +# Linter Rule: Space Indentation + +**Rule:** `erb-space-indentation` + +## Description + +Detects indentation with tabs. Consistent use of spaces for indentation improves readability and avoids alignment issues across editors and tools. + +## Examples + +### ✅ Good + +```erb +
+

Hello

+
+``` + +### ❌ Bad + +```erb +
+

Hello

+
+``` + +## References + +- [Shopify/erb_lint - `SpaceIndentation`](https://github.com/Shopify/erb_lint/blob/main/lib/erb_lint/linters/space_indentation.rb) diff --git a/javascript/packages/linter/src/rules.ts b/javascript/packages/linter/src/rules.ts index 267fadb7e..8af184811 100644 --- a/javascript/packages/linter/src/rules.ts +++ b/javascript/packages/linter/src/rules.ts @@ -32,6 +32,7 @@ import { ERBPreferImageTagHelperRule } from "./rules/erb-prefer-image-tag-helper import { ERBRequireTrailingNewlineRule } from "./rules/erb-require-trailing-newline.js" import { ERBRequireWhitespaceRule } from "./rules/erb-require-whitespace-inside-tags.js" import { ERBRightTrimRule } from "./rules/erb-right-trim.js" +import { ERBSpaceIndentationRule } from "./rules/erb-space-indentation.js" import { ERBStrictLocalsCommentSyntaxRule } from "./rules/erb-strict-locals-comment-syntax.js" import { ERBStrictLocalsRequiredRule } from "./rules/erb-strict-locals-required.js" @@ -117,6 +118,7 @@ export const rules: RuleClass[] = [ ERBNoUnsafeScriptInterpolationRule, ERBPreferImageTagHelperRule, ERBRequireTrailingNewlineRule, + ERBSpaceIndentationRule, ERBRequireWhitespaceRule, ERBRightTrimRule, ERBStrictLocalsCommentSyntaxRule, diff --git a/javascript/packages/linter/src/rules/erb-space-indentation.ts b/javascript/packages/linter/src/rules/erb-space-indentation.ts new file mode 100644 index 000000000..4e19f50d2 --- /dev/null +++ b/javascript/packages/linter/src/rules/erb-space-indentation.ts @@ -0,0 +1,50 @@ +import { Location } from "@herb-tools/core" + +import { BaseSourceRuleVisitor, positionFromOffset } from "./rule-utils.js" +import { SourceRule } from "../types.js" +import type { UnboundLintOffense, LintContext, FullRuleConfig } from "../types.js" + +const START_BLANKS = /^[^\S\n]*\t[^\S\n]*/ + +class ERBSpaceIndentationVisitor extends BaseSourceRuleVisitor { + protected visitSource(source: string): void { + const lines = source.split("\n") + let offset = 0 + + lines.forEach((line) => { + const match = line.match(START_BLANKS) + + if (match) { + const start = positionFromOffset(source, offset) + const end = positionFromOffset(source, offset + match[0].length) + const location = new Location(start, end) + + this.addOffense( + "Indent with spaces instead of tabs.", + location, + ) + } + + offset += line.length + 1 + }) + } +} + +export class ERBSpaceIndentationRule extends SourceRule { + static ruleName = "erb-space-indentation" + + get defaultConfig(): FullRuleConfig { + return { + enabled: true, + severity: "error" + } + } + + check(source: string, context?: Partial): UnboundLintOffense[] { + const visitor = new ERBSpaceIndentationVisitor(this.ruleName, context) + + visitor.visit(source) + + return visitor.offenses + } +} diff --git a/javascript/packages/linter/src/rules/index.ts b/javascript/packages/linter/src/rules/index.ts index 7efdc83a1..595c6712f 100644 --- a/javascript/packages/linter/src/rules/index.ts +++ b/javascript/packages/linter/src/rules/index.ts @@ -33,6 +33,7 @@ export * from "./erb-prefer-image-tag-helper.js" export * from "./erb-require-trailing-newline.js" export * from "./erb-require-whitespace-inside-tags.js" export * from "./erb-right-trim.js" +export * from "./erb-space-indentation.js" export * from "./erb-strict-locals-comment-syntax.js" export * from "./erb-strict-locals-required.js" diff --git a/javascript/packages/linter/test/__snapshots__/cli.test.ts.snap b/javascript/packages/linter/test/__snapshots__/cli.test.ts.snap index 7dee671f6..2d3bbec72 100644 --- a/javascript/packages/linter/test/__snapshots__/cli.test.ts.snap +++ b/javascript/packages/linter/test/__snapshots__/cli.test.ts.snap @@ -787,7 +787,7 @@ exports[`CLI Output Formatting > formats JSON output correctly for bad file 1`] "summary": { "filesChecked": 1, "filesWithOffenses": 1, - "ruleCount": 73, + "ruleCount": 74, "totalErrors": 2, "totalHints": 0, "totalIgnored": 0, @@ -808,7 +808,7 @@ exports[`CLI Output Formatting > formats JSON output correctly for clean file 1` "summary": { "filesChecked": 1, "filesWithOffenses": 0, - "ruleCount": 73, + "ruleCount": 74, "totalErrors": 0, "totalHints": 0, "totalIgnored": 0, @@ -881,7 +881,7 @@ exports[`CLI Output Formatting > formats JSON output correctly for file with err "summary": { "filesChecked": 1, "filesWithOffenses": 1, - "ruleCount": 73, + "ruleCount": 74, "totalErrors": 2, "totalHints": 0, "totalIgnored": 0, diff --git a/javascript/packages/linter/test/rules/erb-space-indentation.test.ts b/javascript/packages/linter/test/rules/erb-space-indentation.test.ts new file mode 100644 index 000000000..c88e23287 --- /dev/null +++ b/javascript/packages/linter/test/rules/erb-space-indentation.test.ts @@ -0,0 +1,46 @@ +import { describe, test } from "vitest" + +import { ERBSpaceIndentationRule } from "../../src/rules/erb-space-indentation.js" +import { createLinterTest } from "../helpers/linter-test-helper.js" + +const { expectNoOffenses, expectError, assertOffenses } = createLinterTest(ERBSpaceIndentationRule) + +describe("ERBSpaceIndentationRule", () => { + test("no indentation present", () => { + expectNoOffenses("this is a line") + }) + + test("space indentation present", () => { + expectNoOffenses(" this is a line\n another line\n") + }) + + test("tab indentation", () => { + expectError("Indent with spaces instead of tabs.", [1]) + expectError("Indent with spaces instead of tabs.", [2]) + assertOffenses("\t\tthis is a line\n\t\tanother line\n") + }) + + test("tab and spaces indentation", () => { + expectError("Indent with spaces instead of tabs.", [1]) + expectError("Indent with spaces instead of tabs.", [2]) + assertOffenses(" \t this is a line\n \t another line\n") + }) + + test("mixed content with tabs", () => { + expectError("Indent with spaces instead of tabs.", [2]) + assertOffenses("
\n\t

hello

\n
\n") + }) + + test("tabs only at start of line", () => { + expectNoOffenses("hello\tworld\n") + }) + + test("empty lines are fine", () => { + expectNoOffenses("\n\n\n") + }) + + test("ERB content with tab indentation", () => { + expectError("Indent with spaces instead of tabs.", [2]) + assertOffenses("
\n\t<%= hello %>\n
\n") + }) +}) From 4eb4ce00a9dac4301371b6871e6c22bbbb5ceff7 Mon Sep 17 00:00:00 2001 From: Marko Kajzer Date: Sat, 21 Mar 2026 12:52:36 +0100 Subject: [PATCH 2/5] add autofix --- .../docs/rules/erb-space-indentation.md | 4 + javascript/packages/linter/src/linter.ts | 9 +- .../linter/src/rules/erb-space-indentation.ts | 20 ++- javascript/packages/linter/src/types.ts | 4 +- .../erb-space-indentation.autofix.test.ts | 124 ++++++++++++++++++ .../test/rules/erb-space-indentation.test.ts | 28 ++-- 6 files changed, 172 insertions(+), 17 deletions(-) create mode 100644 javascript/packages/linter/test/autofix/erb-space-indentation.autofix.test.ts diff --git a/javascript/packages/linter/docs/rules/erb-space-indentation.md b/javascript/packages/linter/docs/rules/erb-space-indentation.md index 3f025dbaa..f2242677d 100644 --- a/javascript/packages/linter/docs/rules/erb-space-indentation.md +++ b/javascript/packages/linter/docs/rules/erb-space-indentation.md @@ -24,6 +24,10 @@ Detects indentation with tabs. Consistent use of spaces for indentation improves ``` +## Autofix + +This rule is autocorrectable. Each tab character in leading whitespace is replaced with spaces based on the configured `indentWidth` (default: 2). + ## References - [Shopify/erb_lint - `SpaceIndentation`](https://github.com/Shopify/erb_lint/blob/main/lib/erb_lint/linters/space_indentation.rb) diff --git a/javascript/packages/linter/src/linter.ts b/javascript/packages/linter/src/linter.ts index 210aea3e5..9b92d2a8d 100644 --- a/javascript/packages/linter/src/linter.ts +++ b/javascript/packages/linter/src/linter.ts @@ -368,7 +368,8 @@ export class Linter { context = { ...context, validRuleNames: this.getAvailableRules().map(ruleClass => ruleClass.ruleName), - ignoredOffensesByLine + ignoredOffensesByLine, + indentWidth: context?.indentWidth ?? this.config?.formatter?.indentWidth } const regularRules = this.rules.filter(ruleClass => ruleClass.ruleName !== "herb-disable-comment-unnecessary") @@ -481,6 +482,12 @@ export class Linter { */ autofix(source: string, context?: Partial, offensesToFix?: LintOffense[], options?: { includeUnsafe?: boolean }): AutofixResult { const includeUnsafe = options?.includeUnsafe ?? false + + context = { + ...context, + indentWidth: context?.indentWidth ?? this.config?.formatter?.indentWidth + } + const lintResult = offensesToFix ? { offenses: offensesToFix } : this.lint(source, context) const parserOffenses: LintOffense[] = [] diff --git a/javascript/packages/linter/src/rules/erb-space-indentation.ts b/javascript/packages/linter/src/rules/erb-space-indentation.ts index 4e19f50d2..88bac5186 100644 --- a/javascript/packages/linter/src/rules/erb-space-indentation.ts +++ b/javascript/packages/linter/src/rules/erb-space-indentation.ts @@ -2,7 +2,7 @@ import { Location } from "@herb-tools/core" import { BaseSourceRuleVisitor, positionFromOffset } from "./rule-utils.js" import { SourceRule } from "../types.js" -import type { UnboundLintOffense, LintContext, FullRuleConfig } from "../types.js" +import type { UnboundLintOffense, LintOffense, LintContext, FullRuleConfig } from "../types.js" const START_BLANKS = /^[^\S\n]*\t[^\S\n]*/ @@ -31,6 +31,7 @@ class ERBSpaceIndentationVisitor extends BaseSourceRuleVisitor { } export class ERBSpaceIndentationRule extends SourceRule { + static autocorrectable = true static ruleName = "erb-space-indentation" get defaultConfig(): FullRuleConfig { @@ -47,4 +48,21 @@ export class ERBSpaceIndentationRule extends SourceRule { return visitor.offenses } + + autofix(_offense: LintOffense, source: string, context?: Partial): string | null { + const indentWidth = context?.indentWidth ?? 2 + const lines = source.split("\n") + const result = lines.map((line) => { + const match = line.match(START_BLANKS) + + if (match) { + const replaced = match[0].replace(/\t/g, " ".repeat(indentWidth)) + return replaced + line.substring(match[0].length) + } + + return line + }) + + return result.join("\n") + } } diff --git a/javascript/packages/linter/src/types.ts b/javascript/packages/linter/src/types.ts index 09c341766..7541b2eaa 100644 --- a/javascript/packages/linter/src/types.ts +++ b/javascript/packages/linter/src/types.ts @@ -216,6 +216,7 @@ export interface LintContext { validRuleNames: string[] | undefined ignoredOffensesByLine: Map> | undefined ignoreDisableComments: boolean | undefined + indentWidth: number | undefined } /** @@ -225,7 +226,8 @@ export const DEFAULT_LINT_CONTEXT: LintContext = { fileName: undefined, validRuleNames: undefined, ignoredOffensesByLine: undefined, - ignoreDisableComments: undefined + ignoreDisableComments: undefined, + indentWidth: undefined } as const export abstract class SourceRule { diff --git a/javascript/packages/linter/test/autofix/erb-space-indentation.autofix.test.ts b/javascript/packages/linter/test/autofix/erb-space-indentation.autofix.test.ts new file mode 100644 index 000000000..7248529c6 --- /dev/null +++ b/javascript/packages/linter/test/autofix/erb-space-indentation.autofix.test.ts @@ -0,0 +1,124 @@ +import { describe, test, expect, beforeAll } from "vitest" + +import { Herb } from "@herb-tools/node-wasm" +import { Config } from "@herb-tools/config" +import { Linter } from "../../src/linter.js" + +import { ERBSpaceIndentationRule } from "../../src/rules/erb-space-indentation.js" + +describe("erb-space-indentation autofix", () => { + beforeAll(async () => { + await Herb.load() + }) + + test("replaces tab indentation with spaces", () => { + const input = "\tthis is a line\n\tanother line\n" + const expected = " this is a line\n another line\n" + + const linter = new Linter(Herb, [ERBSpaceIndentationRule]) + const result = linter.autofix(input) + + expect(result.source).toBe(expected) + expect(result.fixed).toHaveLength(2) + expect(result.unfixed).toHaveLength(0) + }) + + test("replaces multiple tab indentation with spaces", () => { + const input = "\t\tthis is a line\n" + const expected = " this is a line\n" + + const linter = new Linter(Herb, [ERBSpaceIndentationRule]) + const result = linter.autofix(input) + + expect(result.source).toBe(expected) + expect(result.fixed).toHaveLength(1) + expect(result.unfixed).toHaveLength(0) + }) + + test("replaces tabs in mixed indentation", () => { + const input = " \t this is a line\n \t another line\n" + const expected = " this is a line\n another line\n" + + const linter = new Linter(Herb, [ERBSpaceIndentationRule]) + const result = linter.autofix(input) + + expect(result.source).toBe(expected) + expect(result.fixed).toHaveLength(2) + expect(result.unfixed).toHaveLength(0) + }) + + test("ignores space-only indentation", () => { + const input = " this is a line\n another line\n" + + const linter = new Linter(Herb, [ERBSpaceIndentationRule]) + const result = linter.autofix(input) + + expect(result.source).toBe(input) + expect(result.fixed).toHaveLength(0) + expect(result.unfixed).toHaveLength(0) + }) + + test("ignores lines without indentation", () => { + const input = "this is a line\n" + + const linter = new Linter(Herb, [ERBSpaceIndentationRule]) + const result = linter.autofix(input) + + expect(result.source).toBe(input) + expect(result.fixed).toHaveLength(0) + expect(result.unfixed).toHaveLength(0) + }) + + test("ignores tabs in the middle of a line", () => { + const input = "hello\tworld\n" + + const linter = new Linter(Herb, [ERBSpaceIndentationRule]) + const result = linter.autofix(input) + + expect(result.source).toBe(input) + expect(result.fixed).toHaveLength(0) + expect(result.unfixed).toHaveLength(0) + }) + + test("handles HTML content with tab indentation", () => { + const input = "
\n\t

hello

\n
\n" + const expected = "
\n

hello

\n
\n" + + const linter = new Linter(Herb, [ERBSpaceIndentationRule]) + const result = linter.autofix(input) + + expect(result.source).toBe(expected) + expect(result.fixed).toHaveLength(1) + expect(result.unfixed).toHaveLength(0) + }) + + test("uses custom indentWidth from autofix context", () => { + const input = "\tthis is a line\n\t\tindented twice\n" + const expected = " this is a line\n indented twice\n" + + const linter = new Linter(Herb, [ERBSpaceIndentationRule]) + const result = linter.autofix(input, { indentWidth: 4 }) + + expect(result.source).toBe(expected) + expect(result.fixed).toHaveLength(2) + expect(result.unfixed).toHaveLength(0) + }) + + test("defaults to indentWidth from formatter config", () => { + const input = "\tthis is a line\n\t\tindented twice\n" + const expected = " this is a line\n indented twice\n" + + const config = Config.fromObject({ + formatter: { + indentWidth: 4 + } + }) + + const linter = Linter.from(Herb, config) + const result = linter.autofix(input) + + expect(result.source).toBe(expected) + expect(result.fixed).toHaveLength(2) + expect(result.unfixed).toHaveLength(0) + }) +}) diff --git a/javascript/packages/linter/test/rules/erb-space-indentation.test.ts b/javascript/packages/linter/test/rules/erb-space-indentation.test.ts index c88e23287..c81587d1a 100644 --- a/javascript/packages/linter/test/rules/erb-space-indentation.test.ts +++ b/javascript/packages/linter/test/rules/erb-space-indentation.test.ts @@ -6,41 +6,41 @@ import { createLinterTest } from "../helpers/linter-test-helper.js" const { expectNoOffenses, expectError, assertOffenses } = createLinterTest(ERBSpaceIndentationRule) describe("ERBSpaceIndentationRule", () => { - test("no indentation present", () => { + test("ignores empty lines", () => { + expectNoOffenses("\n\n\n") + }) + + test("passes when no indentation", () => { expectNoOffenses("this is a line") }) - test("space indentation present", () => { + test("passes when space indentation", () => { expectNoOffenses(" this is a line\n another line\n") }) - test("tab indentation", () => { + test("fails with tab indentation", () => { expectError("Indent with spaces instead of tabs.", [1]) expectError("Indent with spaces instead of tabs.", [2]) + assertOffenses("\t\tthis is a line\n\t\tanother line\n") }) - test("tab and spaces indentation", () => { + test("handles mixed indentation", () => { expectError("Indent with spaces instead of tabs.", [1]) expectError("Indent with spaces instead of tabs.", [2]) + assertOffenses(" \t this is a line\n \t another line\n") }) - test("mixed content with tabs", () => { + test("handles html template with tabs", () => { expectError("Indent with spaces instead of tabs.", [2]) - assertOffenses("
\n\t

hello

\n
\n") - }) - - test("tabs only at start of line", () => { - expectNoOffenses("hello\tworld\n") - }) - test("empty lines are fine", () => { - expectNoOffenses("\n\n\n") + assertOffenses("
\n\t

hello

\n
\n") }) - test("ERB content with tab indentation", () => { + test("fails ERB content with tab indentation", () => { expectError("Indent with spaces instead of tabs.", [2]) + assertOffenses("
\n\t<%= hello %>\n
\n") }) }) From b82dcfd7177902e379c277b145de57b612f01a7a Mon Sep 17 00:00:00 2001 From: Marco Roth Date: Sun, 22 Mar 2026 22:31:32 +0100 Subject: [PATCH 3/5] Rename to `source-*` --- .../packages/linter/docs/rules/README.md | 2 +- .../docs/rules/erb-space-indentation.md | 33 --------- .../docs/rules/source-space-indentation.md | 33 +++++++++ javascript/packages/linter/src/rules.ts | 6 +- javascript/packages/linter/src/rules/index.ts | 3 +- ...ntation.ts => source-space-indentation.ts} | 9 +-- .../test/__snapshots__/cli.test.ts.snap | 69 ++++++++++++------- ... source-space-indentation.autofix.test.ts} | 25 ++++--- ...st.ts => source-space-indentation.test.ts} | 6 +- 9 files changed, 108 insertions(+), 78 deletions(-) delete mode 100644 javascript/packages/linter/docs/rules/erb-space-indentation.md create mode 100644 javascript/packages/linter/docs/rules/source-space-indentation.md rename javascript/packages/linter/src/rules/{erb-space-indentation.ts => source-space-indentation.ts} (84%) rename javascript/packages/linter/test/autofix/{erb-space-indentation.autofix.test.ts => source-space-indentation.autofix.test.ts} (80%) rename javascript/packages/linter/test/rules/{erb-space-indentation.test.ts => source-space-indentation.test.ts} (87%) diff --git a/javascript/packages/linter/docs/rules/README.md b/javascript/packages/linter/docs/rules/README.md index 9a0acd78b..1bb17a81c 100644 --- a/javascript/packages/linter/docs/rules/README.md +++ b/javascript/packages/linter/docs/rules/README.md @@ -35,7 +35,6 @@ This page contains documentation for all Herb Linter rules. - [`erb-require-trailing-newline`](./erb-require-trailing-newline.md) - Enforces that all HTML+ERB template files end with exactly one trailing newline character. - [`erb-require-whitespace-inside-tags`](./erb-require-whitespace-inside-tags.md) - Requires whitespace around ERB tags - [`erb-right-trim`](./erb-right-trim.md) - Enforce consistent right-trimming syntax. -- [`erb-space-indentation`](./erb-space-indentation.md) - Indent with spaces instead of tabs. - [`erb-strict-locals-comment-syntax`](./erb-strict-locals-comment-syntax.md) - Enforce strict locals comment syntax. - [`herb-disable-comment-malformed`](./herb-disable-comment-malformed.md) - Detect malformed `herb:disable` comments. - [`herb-disable-comment-missing-rules`](./herb-disable-comment-missing-rules.md) - Require rule names in `herb:disable` comments. @@ -79,6 +78,7 @@ This page contains documentation for all Herb Linter rules. - [`html-require-script-nonce`](./html-require-script-nonce.md) - Require `nonce` attribute on script tags and helpers - [`html-tag-name-lowercase`](./html-tag-name-lowercase.md) - Enforces lowercase tag names in HTML - [`parser-no-errors`](./parser-no-errors.md) - Disallow parser errors in HTML+ERB documents +- [`source-space-indentation`](./source-space-indentation.md) - Indent with spaces instead of tabs. - [`svg-tag-name-capitalization`](./svg-tag-name-capitalization.md) - Enforces proper camelCase capitalization for SVG elements - [`turbo-permanent-require-id`](./turbo-permanent-require-id.md) - Require `id` attribute on elements with `data-turbo-permanent` diff --git a/javascript/packages/linter/docs/rules/erb-space-indentation.md b/javascript/packages/linter/docs/rules/erb-space-indentation.md deleted file mode 100644 index f2242677d..000000000 --- a/javascript/packages/linter/docs/rules/erb-space-indentation.md +++ /dev/null @@ -1,33 +0,0 @@ -# Linter Rule: Space Indentation - -**Rule:** `erb-space-indentation` - -## Description - -Detects indentation with tabs. Consistent use of spaces for indentation improves readability and avoids alignment issues across editors and tools. - -## Examples - -### ✅ Good - -```erb -
-

Hello

-
-``` - -### ❌ Bad - -```erb -
-

Hello

-
-``` - -## Autofix - -This rule is autocorrectable. Each tab character in leading whitespace is replaced with spaces based on the configured `indentWidth` (default: 2). - -## References - -- [Shopify/erb_lint - `SpaceIndentation`](https://github.com/Shopify/erb_lint/blob/main/lib/erb_lint/linters/space_indentation.rb) diff --git a/javascript/packages/linter/docs/rules/source-space-indentation.md b/javascript/packages/linter/docs/rules/source-space-indentation.md new file mode 100644 index 000000000..bc4d3d357 --- /dev/null +++ b/javascript/packages/linter/docs/rules/source-space-indentation.md @@ -0,0 +1,33 @@ +# Linter Rule: Space Indentation + +**Rule:** `source-space-indentation` + +## Description + +Detects indentation with tabs. Consistent use of spaces for indentation improves readability and avoids alignment issues across editors and tools. + +## Rationale + +Mixing tabs and spaces for indentation causes inconsistent visual formatting across different editors, tools, and environments. Tabs render at different widths depending on the viewer's settings, which can make code appear misaligned or harder to read. Standardizing on space indentation ensures that code appears the same regardless of editor or tool, diffs and code reviews display consistently, and the codebase maintains a uniform visual style. + +## Examples + +### ✅ Good + +```erb +
+

Hello

+
+``` + +### 🚫 Bad + +```erb +
+

Hello

+
+``` + +## References + +- [Shopify/erb_lint - `SpaceIndentation`](https://github.com/Shopify/erb_lint/blob/main/lib/erb_lint/linters/space_indentation.rb) diff --git a/javascript/packages/linter/src/rules.ts b/javascript/packages/linter/src/rules.ts index 777499c24..f2054638b 100644 --- a/javascript/packages/linter/src/rules.ts +++ b/javascript/packages/linter/src/rules.ts @@ -33,7 +33,6 @@ import { ERBPreferImageTagHelperRule } from "./rules/erb-prefer-image-tag-helper import { ERBRequireTrailingNewlineRule } from "./rules/erb-require-trailing-newline.js" import { ERBRequireWhitespaceRule } from "./rules/erb-require-whitespace-inside-tags.js" import { ERBRightTrimRule } from "./rules/erb-right-trim.js" -import { ERBSpaceIndentationRule } from "./rules/erb-space-indentation.js" import { ERBStrictLocalsCommentSyntaxRule } from "./rules/erb-strict-locals-comment-syntax.js" import { ERBStrictLocalsRequiredRule } from "./rules/erb-strict-locals-required.js" @@ -84,6 +83,8 @@ import { HTMLTagNameLowercaseRule } from "./rules/html-tag-name-lowercase.js" import { ParserNoErrorsRule } from "./rules/parser-no-errors.js" +import { SourceSpaceIndentationRule } from "./rules/source-space-indentation.js" + import { SVGTagNameCapitalizationRule } from "./rules/svg-tag-name-capitalization.js" import { TurboPermanentRequireIdRule } from "./rules/turbo-permanent-require-id.js" @@ -120,7 +121,6 @@ export const rules: RuleClass[] = [ ERBNoUnsafeScriptInterpolationRule, ERBPreferImageTagHelperRule, ERBRequireTrailingNewlineRule, - ERBSpaceIndentationRule, ERBRequireWhitespaceRule, ERBRightTrimRule, ERBStrictLocalsCommentSyntaxRule, @@ -173,6 +173,8 @@ export const rules: RuleClass[] = [ ParserNoErrorsRule, + SourceSpaceIndentationRule, + SVGTagNameCapitalizationRule, TurboPermanentRequireIdRule, diff --git a/javascript/packages/linter/src/rules/index.ts b/javascript/packages/linter/src/rules/index.ts index 0fecffd10..0be59c3ab 100644 --- a/javascript/packages/linter/src/rules/index.ts +++ b/javascript/packages/linter/src/rules/index.ts @@ -34,7 +34,6 @@ export * from "./erb-prefer-image-tag-helper.js" export * from "./erb-require-trailing-newline.js" export * from "./erb-require-whitespace-inside-tags.js" export * from "./erb-right-trim.js" -export * from "./erb-space-indentation.js" export * from "./erb-strict-locals-comment-syntax.js" export * from "./erb-strict-locals-required.js" @@ -82,4 +81,6 @@ export * from "./html-require-closing-tags.js" export * from "./html-require-script-nonce.js" export * from "./html-tag-name-lowercase.js" +export * from "./source-space-indentation.js" + export * from "./svg-tag-name-capitalization.js" diff --git a/javascript/packages/linter/src/rules/erb-space-indentation.ts b/javascript/packages/linter/src/rules/source-space-indentation.ts similarity index 84% rename from javascript/packages/linter/src/rules/erb-space-indentation.ts rename to javascript/packages/linter/src/rules/source-space-indentation.ts index 88bac5186..77a6d9de9 100644 --- a/javascript/packages/linter/src/rules/erb-space-indentation.ts +++ b/javascript/packages/linter/src/rules/source-space-indentation.ts @@ -6,7 +6,7 @@ import type { UnboundLintOffense, LintOffense, LintContext, FullRuleConfig } fro const START_BLANKS = /^[^\S\n]*\t[^\S\n]*/ -class ERBSpaceIndentationVisitor extends BaseSourceRuleVisitor { +class SourceSpaceIndentationVisitor extends BaseSourceRuleVisitor { protected visitSource(source: string): void { const lines = source.split("\n") let offset = 0 @@ -30,9 +30,10 @@ class ERBSpaceIndentationVisitor extends BaseSourceRuleVisitor { } } -export class ERBSpaceIndentationRule extends SourceRule { +export class SourceSpaceIndentationRule extends SourceRule { static autocorrectable = true - static ruleName = "erb-space-indentation" + static ruleName = "source-space-indentation" + static introducedIn = this.version("unreleased") get defaultConfig(): FullRuleConfig { return { @@ -42,7 +43,7 @@ export class ERBSpaceIndentationRule extends SourceRule { } check(source: string, context?: Partial): UnboundLintOffense[] { - const visitor = new ERBSpaceIndentationVisitor(this.ruleName, context) + const visitor = new SourceSpaceIndentationVisitor(this.ruleName, context) visitor.visit(source) diff --git a/javascript/packages/linter/test/__snapshots__/cli.test.ts.snap b/javascript/packages/linter/test/__snapshots__/cli.test.ts.snap index b55d4fa3e..c5a4b3dd1 100644 --- a/javascript/packages/linter/test/__snapshots__/cli.test.ts.snap +++ b/javascript/packages/linter/test/__snapshots__/cli.test.ts.snap @@ -111,9 +111,10 @@ test/fixtures/ignored.html.erb:8:8 Fixable 7 offenses | 4 autocorrectable using \`--fix\` New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -180,9 +181,10 @@ test/fixtures/test-file-with-errors.html.erb:2:22 Fixable 3 offenses | 2 autocorrectable using \`--fix\` New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -211,9 +213,10 @@ test/fixtures/no-trailing-newline.html.erb:1:29 Fixable 1 offense | 1 autocorrectable using \`--fix\` New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -268,9 +271,10 @@ test/fixtures/erb-no-extra-whitespace-inside-tags.html.erb:9:3 Fixable 3 offenses | 3 autocorrectable using \`--fix\` New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -318,9 +322,10 @@ test/fixtures/ignored.html.erb:6:14 Fixable 2 offenses | 2 autocorrectable using \`--fix\` New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -353,9 +358,10 @@ test/fixtures/parser-errors.html.erb:2:16 Fixable 1 offense New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -577,9 +583,10 @@ test/fixtures/multiple-rule-offenses.html.erb:4:2 Fixable 14 offenses | 4 autocorrectable using \`--fix\` New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -683,9 +690,10 @@ test/fixtures/few-rule-offenses.html.erb:6:0 Fixable 6 offenses | 3 autocorrectable using \`--fix\` New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -731,9 +739,10 @@ test/fixtures/bad-file.html.erb:1:16 Fixable 2 offenses | 2 autocorrectable using \`--fix\` New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -749,9 +758,10 @@ exports[`CLI Output Formatting > formats GitHub Actions output correctly for cle Offenses 0 offenses New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -815,9 +825,10 @@ test/fixtures/test-file-with-errors.html.erb:2:22 Fixable 3 offenses | 2 autocorrectable using \`--fix\` New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -860,9 +871,10 @@ test/fixtures/test-file-simple.html.erb:2:22 Fixable 2 offenses | 2 autocorrectable using \`--fix\` New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -916,7 +928,7 @@ exports[`CLI Output Formatting > formats JSON output correctly for bad file 1`] "summary": { "filesChecked": 1, "filesWithOffenses": 1, - "ruleCount": 74, + "ruleCount": 72, "totalErrors": 2, "totalHints": 0, "totalIgnored": 0, @@ -937,7 +949,7 @@ exports[`CLI Output Formatting > formats JSON output correctly for clean file 1` "summary": { "filesChecked": 1, "filesWithOffenses": 0, - "ruleCount": 74, + "ruleCount": 72, "totalErrors": 0, "totalHints": 0, "totalIgnored": 0, @@ -1010,7 +1022,7 @@ exports[`CLI Output Formatting > formats JSON output correctly for file with err "summary": { "filesChecked": 1, "filesWithOffenses": 1, - "ruleCount": 74, + "ruleCount": 72, "totalErrors": 2, "totalHints": 0, "totalIgnored": 0, @@ -1073,9 +1085,10 @@ test/fixtures/test-file-with-errors.html.erb:2:22 Fixable 3 offenses | 2 autocorrectable using \`--fix\` New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -1101,9 +1114,10 @@ exports[`CLI Output Formatting > formats simple output correctly 1`] = ` Fixable 2 offenses | 2 autocorrectable using \`--fix\` New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -1129,9 +1143,10 @@ exports[`CLI Output Formatting > formats simple output for bad-file correctly 1` Fixable 2 offenses | 2 autocorrectable using \`--fix\` New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -1150,9 +1165,10 @@ exports[`CLI Output Formatting > formats success output correctly 1`] = ` Offenses 0 offenses New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -1171,9 +1187,10 @@ exports[`CLI Output Formatting > handles boolean attributes 1`] = ` Offenses 0 offenses New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -1215,9 +1232,10 @@ test/fixtures/bad-file.html.erb:1:16 Fixable 2 offenses | 2 autocorrectable using \`--fix\` New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -1356,9 +1374,10 @@ test/fixtures/disabled-1.html.erb:14:19 Fixable 8 offenses | 1 autocorrectable using \`--fix\` New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -1568,9 +1587,10 @@ test/fixtures/disabled-2.html.erb:2:44 Fixable 13 offenses | 6 autocorrectable using \`--fix\` New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or @@ -1637,9 +1657,10 @@ test/fixtures/test-file-with-errors.html.erb:2:22 Fixable 3 offenses | 2 autocorrectable using \`--fix\` New rules available: - Your .herb.yml version is 0.9.2. 2 new rules are disabled to ease upgrades: + Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) + erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or diff --git a/javascript/packages/linter/test/autofix/erb-space-indentation.autofix.test.ts b/javascript/packages/linter/test/autofix/source-space-indentation.autofix.test.ts similarity index 80% rename from javascript/packages/linter/test/autofix/erb-space-indentation.autofix.test.ts rename to javascript/packages/linter/test/autofix/source-space-indentation.autofix.test.ts index 7248529c6..c6566c5fd 100644 --- a/javascript/packages/linter/test/autofix/erb-space-indentation.autofix.test.ts +++ b/javascript/packages/linter/test/autofix/source-space-indentation.autofix.test.ts @@ -4,9 +4,9 @@ import { Herb } from "@herb-tools/node-wasm" import { Config } from "@herb-tools/config" import { Linter } from "../../src/linter.js" -import { ERBSpaceIndentationRule } from "../../src/rules/erb-space-indentation.js" +import { SourceSpaceIndentationRule } from "../../src/rules/source-space-indentation.js" -describe("erb-space-indentation autofix", () => { +describe("source-space-indentation autofix", () => { beforeAll(async () => { await Herb.load() }) @@ -15,7 +15,7 @@ describe("erb-space-indentation autofix", () => { const input = "\tthis is a line\n\tanother line\n" const expected = " this is a line\n another line\n" - const linter = new Linter(Herb, [ERBSpaceIndentationRule]) + const linter = new Linter(Herb, [SourceSpaceIndentationRule]) const result = linter.autofix(input) expect(result.source).toBe(expected) @@ -27,7 +27,7 @@ describe("erb-space-indentation autofix", () => { const input = "\t\tthis is a line\n" const expected = " this is a line\n" - const linter = new Linter(Herb, [ERBSpaceIndentationRule]) + const linter = new Linter(Herb, [SourceSpaceIndentationRule]) const result = linter.autofix(input) expect(result.source).toBe(expected) @@ -39,7 +39,7 @@ describe("erb-space-indentation autofix", () => { const input = " \t this is a line\n \t another line\n" const expected = " this is a line\n another line\n" - const linter = new Linter(Herb, [ERBSpaceIndentationRule]) + const linter = new Linter(Herb, [SourceSpaceIndentationRule]) const result = linter.autofix(input) expect(result.source).toBe(expected) @@ -50,7 +50,7 @@ describe("erb-space-indentation autofix", () => { test("ignores space-only indentation", () => { const input = " this is a line\n another line\n" - const linter = new Linter(Herb, [ERBSpaceIndentationRule]) + const linter = new Linter(Herb, [SourceSpaceIndentationRule]) const result = linter.autofix(input) expect(result.source).toBe(input) @@ -61,7 +61,7 @@ describe("erb-space-indentation autofix", () => { test("ignores lines without indentation", () => { const input = "this is a line\n" - const linter = new Linter(Herb, [ERBSpaceIndentationRule]) + const linter = new Linter(Herb, [SourceSpaceIndentationRule]) const result = linter.autofix(input) expect(result.source).toBe(input) @@ -72,7 +72,7 @@ describe("erb-space-indentation autofix", () => { test("ignores tabs in the middle of a line", () => { const input = "hello\tworld\n" - const linter = new Linter(Herb, [ERBSpaceIndentationRule]) + const linter = new Linter(Herb, [SourceSpaceIndentationRule]) const result = linter.autofix(input) expect(result.source).toBe(input) @@ -84,7 +84,7 @@ describe("erb-space-indentation autofix", () => { const input = "
\n\t

hello

\n
\n" const expected = "
\n

hello

\n
\n" - const linter = new Linter(Herb, [ERBSpaceIndentationRule]) + const linter = new Linter(Herb, [SourceSpaceIndentationRule]) const result = linter.autofix(input) expect(result.source).toBe(expected) @@ -96,7 +96,7 @@ describe("erb-space-indentation autofix", () => { const input = "\tthis is a line\n\t\tindented twice\n" const expected = " this is a line\n indented twice\n" - const linter = new Linter(Herb, [ERBSpaceIndentationRule]) + const linter = new Linter(Herb, [SourceSpaceIndentationRule]) const result = linter.autofix(input, { indentWidth: 4 }) expect(result.source).toBe(expected) @@ -111,6 +111,11 @@ describe("erb-space-indentation autofix", () => { const config = Config.fromObject({ formatter: { indentWidth: 4 + }, + linter: { + rules: { + "source-space-indentation": { enabled: true } + } } }) diff --git a/javascript/packages/linter/test/rules/erb-space-indentation.test.ts b/javascript/packages/linter/test/rules/source-space-indentation.test.ts similarity index 87% rename from javascript/packages/linter/test/rules/erb-space-indentation.test.ts rename to javascript/packages/linter/test/rules/source-space-indentation.test.ts index c81587d1a..876075ce3 100644 --- a/javascript/packages/linter/test/rules/erb-space-indentation.test.ts +++ b/javascript/packages/linter/test/rules/source-space-indentation.test.ts @@ -1,11 +1,11 @@ import { describe, test } from "vitest" -import { ERBSpaceIndentationRule } from "../../src/rules/erb-space-indentation.js" +import { SourceSpaceIndentationRule } from "../../src/rules/source-space-indentation.js" import { createLinterTest } from "../helpers/linter-test-helper.js" -const { expectNoOffenses, expectError, assertOffenses } = createLinterTest(ERBSpaceIndentationRule) +const { expectNoOffenses, expectError, assertOffenses } = createLinterTest(SourceSpaceIndentationRule) -describe("ERBSpaceIndentationRule", () => { +describe("SourceSpaceIndentationRule", () => { test("ignores empty lines", () => { expectNoOffenses("\n\n\n") }) From 58787c7f43257cdcc36491a05c1363f33bb68017 Mon Sep 17 00:00:00 2001 From: Marco Roth Date: Sun, 22 Mar 2026 22:35:44 +0100 Subject: [PATCH 4/5] Update snapshots --- .../test/__snapshots__/cli.test.ts.snap | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/javascript/packages/linter/test/__snapshots__/cli.test.ts.snap b/javascript/packages/linter/test/__snapshots__/cli.test.ts.snap index c5a4b3dd1..cfc30093e 100644 --- a/javascript/packages/linter/test/__snapshots__/cli.test.ts.snap +++ b/javascript/packages/linter/test/__snapshots__/cli.test.ts.snap @@ -114,8 +114,8 @@ test/fixtures/ignored.html.erb:8:8 Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -184,8 +184,8 @@ test/fixtures/test-file-with-errors.html.erb:2:22 Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once." @@ -216,8 +216,8 @@ test/fixtures/no-trailing-newline.html.erb:1:29 Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once." @@ -274,8 +274,8 @@ test/fixtures/erb-no-extra-whitespace-inside-tags.html.erb:9:3 Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -325,8 +325,8 @@ test/fixtures/ignored.html.erb:6:14 Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -361,8 +361,8 @@ test/fixtures/parser-errors.html.erb:2:16 Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -586,8 +586,8 @@ test/fixtures/multiple-rule-offenses.html.erb:4:2 Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -693,8 +693,8 @@ test/fixtures/few-rule-offenses.html.erb:6:0 Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -742,8 +742,8 @@ test/fixtures/bad-file.html.erb:1:16 Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once." @@ -761,8 +761,8 @@ exports[`CLI Output Formatting > formats GitHub Actions output correctly for cle Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once." @@ -828,8 +828,8 @@ test/fixtures/test-file-with-errors.html.erb:2:22 Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once." @@ -874,8 +874,8 @@ test/fixtures/test-file-simple.html.erb:2:22 Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1088,8 +1088,8 @@ test/fixtures/test-file-with-errors.html.erb:2:22 Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1117,8 +1117,8 @@ exports[`CLI Output Formatting > formats simple output correctly 1`] = ` Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1146,8 +1146,8 @@ exports[`CLI Output Formatting > formats simple output for bad-file correctly 1` Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1168,8 +1168,8 @@ exports[`CLI Output Formatting > formats success output correctly 1`] = ` Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1190,8 +1190,8 @@ exports[`CLI Output Formatting > handles boolean attributes 1`] = ` Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1235,8 +1235,8 @@ test/fixtures/bad-file.html.erb:1:16 Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1377,8 +1377,8 @@ test/fixtures/disabled-1.html.erb:14:19 Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1590,8 +1590,8 @@ test/fixtures/disabled-2.html.erb:2:44 Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1660,8 +1660,8 @@ test/fixtures/test-file-with-errors.html.erb:2:22 Your .herb.yml version is 0.9.2. 3 new rules are disabled to ease upgrades: actionview-no-void-element-content (introduced in next release) - erb-space-indentation (introduced in next release) html-require-script-nonce (introduced in next release) + source-space-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once." From df01ddbadadf5d0a94c17010919ab8df40cd4b9c Mon Sep 17 00:00:00 2001 From: Marco Roth Date: Sun, 22 Mar 2026 22:41:35 +0100 Subject: [PATCH 5/5] Rename to `source-indentation` --- .../packages/linter/docs/rules/README.md | 2 +- ...e-indentation.md => source-indentation.md} | 4 +- javascript/packages/linter/src/rules.ts | 4 +- javascript/packages/linter/src/rules/index.ts | 2 +- ...e-indentation.ts => source-indentation.ts} | 8 ++-- .../test/__snapshots__/cli.test.ts.snap | 48 +++++++++---------- ....ts => source-indentation.autofix.test.ts} | 22 ++++----- ...ion.test.ts => source-indentation.test.ts} | 6 +-- 8 files changed, 48 insertions(+), 48 deletions(-) rename javascript/packages/linter/docs/rules/{source-space-indentation.md => source-indentation.md} (92%) rename javascript/packages/linter/src/rules/{source-space-indentation.ts => source-indentation.ts} (86%) rename javascript/packages/linter/test/autofix/{source-space-indentation.autofix.test.ts => source-indentation.autofix.test.ts} (82%) rename javascript/packages/linter/test/rules/{source-space-indentation.test.ts => source-indentation.test.ts} (87%) diff --git a/javascript/packages/linter/docs/rules/README.md b/javascript/packages/linter/docs/rules/README.md index 1bb17a81c..45b93e98f 100644 --- a/javascript/packages/linter/docs/rules/README.md +++ b/javascript/packages/linter/docs/rules/README.md @@ -78,7 +78,7 @@ This page contains documentation for all Herb Linter rules. - [`html-require-script-nonce`](./html-require-script-nonce.md) - Require `nonce` attribute on script tags and helpers - [`html-tag-name-lowercase`](./html-tag-name-lowercase.md) - Enforces lowercase tag names in HTML - [`parser-no-errors`](./parser-no-errors.md) - Disallow parser errors in HTML+ERB documents -- [`source-space-indentation`](./source-space-indentation.md) - Indent with spaces instead of tabs. +- [`source-indentation`](./source-indentation.md) - Indent with spaces instead of tabs. - [`svg-tag-name-capitalization`](./svg-tag-name-capitalization.md) - Enforces proper camelCase capitalization for SVG elements - [`turbo-permanent-require-id`](./turbo-permanent-require-id.md) - Require `id` attribute on elements with `data-turbo-permanent` diff --git a/javascript/packages/linter/docs/rules/source-space-indentation.md b/javascript/packages/linter/docs/rules/source-indentation.md similarity index 92% rename from javascript/packages/linter/docs/rules/source-space-indentation.md rename to javascript/packages/linter/docs/rules/source-indentation.md index bc4d3d357..68856bd6a 100644 --- a/javascript/packages/linter/docs/rules/source-space-indentation.md +++ b/javascript/packages/linter/docs/rules/source-indentation.md @@ -1,6 +1,6 @@ -# Linter Rule: Space Indentation +# Linter Rule: Indentation -**Rule:** `source-space-indentation` +**Rule:** `source-indentation` ## Description diff --git a/javascript/packages/linter/src/rules.ts b/javascript/packages/linter/src/rules.ts index f2054638b..050aed818 100644 --- a/javascript/packages/linter/src/rules.ts +++ b/javascript/packages/linter/src/rules.ts @@ -83,7 +83,7 @@ import { HTMLTagNameLowercaseRule } from "./rules/html-tag-name-lowercase.js" import { ParserNoErrorsRule } from "./rules/parser-no-errors.js" -import { SourceSpaceIndentationRule } from "./rules/source-space-indentation.js" +import { SourceIndentationRule } from "./rules/source-indentation.js" import { SVGTagNameCapitalizationRule } from "./rules/svg-tag-name-capitalization.js" @@ -173,7 +173,7 @@ export const rules: RuleClass[] = [ ParserNoErrorsRule, - SourceSpaceIndentationRule, + SourceIndentationRule, SVGTagNameCapitalizationRule, diff --git a/javascript/packages/linter/src/rules/index.ts b/javascript/packages/linter/src/rules/index.ts index 0be59c3ab..15123bbfd 100644 --- a/javascript/packages/linter/src/rules/index.ts +++ b/javascript/packages/linter/src/rules/index.ts @@ -81,6 +81,6 @@ export * from "./html-require-closing-tags.js" export * from "./html-require-script-nonce.js" export * from "./html-tag-name-lowercase.js" -export * from "./source-space-indentation.js" +export * from "./source-indentation.js" export * from "./svg-tag-name-capitalization.js" diff --git a/javascript/packages/linter/src/rules/source-space-indentation.ts b/javascript/packages/linter/src/rules/source-indentation.ts similarity index 86% rename from javascript/packages/linter/src/rules/source-space-indentation.ts rename to javascript/packages/linter/src/rules/source-indentation.ts index 77a6d9de9..63144f0d8 100644 --- a/javascript/packages/linter/src/rules/source-space-indentation.ts +++ b/javascript/packages/linter/src/rules/source-indentation.ts @@ -6,7 +6,7 @@ import type { UnboundLintOffense, LintOffense, LintContext, FullRuleConfig } fro const START_BLANKS = /^[^\S\n]*\t[^\S\n]*/ -class SourceSpaceIndentationVisitor extends BaseSourceRuleVisitor { +class SourceIndentationVisitor extends BaseSourceRuleVisitor { protected visitSource(source: string): void { const lines = source.split("\n") let offset = 0 @@ -30,9 +30,9 @@ class SourceSpaceIndentationVisitor extends BaseSourceRuleVisitor { } } -export class SourceSpaceIndentationRule extends SourceRule { +export class SourceIndentationRule extends SourceRule { static autocorrectable = true - static ruleName = "source-space-indentation" + static ruleName = "source-indentation" static introducedIn = this.version("unreleased") get defaultConfig(): FullRuleConfig { @@ -43,7 +43,7 @@ export class SourceSpaceIndentationRule extends SourceRule { } check(source: string, context?: Partial): UnboundLintOffense[] { - const visitor = new SourceSpaceIndentationVisitor(this.ruleName, context) + const visitor = new SourceIndentationVisitor(this.ruleName, context) visitor.visit(source) diff --git a/javascript/packages/linter/test/__snapshots__/cli.test.ts.snap b/javascript/packages/linter/test/__snapshots__/cli.test.ts.snap index cfc30093e..b8ada0255 100644 --- a/javascript/packages/linter/test/__snapshots__/cli.test.ts.snap +++ b/javascript/packages/linter/test/__snapshots__/cli.test.ts.snap @@ -115,7 +115,7 @@ test/fixtures/ignored.html.erb:8:8 actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -185,7 +185,7 @@ test/fixtures/test-file-with-errors.html.erb:2:22 actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once." @@ -217,7 +217,7 @@ test/fixtures/no-trailing-newline.html.erb:1:29 actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once." @@ -275,7 +275,7 @@ test/fixtures/erb-no-extra-whitespace-inside-tags.html.erb:9:3 actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -326,7 +326,7 @@ test/fixtures/ignored.html.erb:6:14 actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -362,7 +362,7 @@ test/fixtures/parser-errors.html.erb:2:16 actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -587,7 +587,7 @@ test/fixtures/multiple-rule-offenses.html.erb:4:2 actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -694,7 +694,7 @@ test/fixtures/few-rule-offenses.html.erb:6:0 actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -743,7 +743,7 @@ test/fixtures/bad-file.html.erb:1:16 actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once." @@ -762,7 +762,7 @@ exports[`CLI Output Formatting > formats GitHub Actions output correctly for cle actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once." @@ -829,7 +829,7 @@ test/fixtures/test-file-with-errors.html.erb:2:22 actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once." @@ -875,7 +875,7 @@ test/fixtures/test-file-simple.html.erb:2:22 actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1089,7 +1089,7 @@ test/fixtures/test-file-with-errors.html.erb:2:22 actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1118,7 +1118,7 @@ exports[`CLI Output Formatting > formats simple output correctly 1`] = ` actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1147,7 +1147,7 @@ exports[`CLI Output Formatting > formats simple output for bad-file correctly 1` actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1169,7 +1169,7 @@ exports[`CLI Output Formatting > formats success output correctly 1`] = ` actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1191,7 +1191,7 @@ exports[`CLI Output Formatting > handles boolean attributes 1`] = ` actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1236,7 +1236,7 @@ test/fixtures/bad-file.html.erb:1:16 actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1378,7 +1378,7 @@ test/fixtures/disabled-1.html.erb:14:19 actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1403,7 +1403,7 @@ test/fixtures/disabled-2.html.erb:6:30 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ [1/13] ⎯⎯⎯⎯ -[warning] Unknown rule \`this-rule-doesnt-exist\`. Did you mean \`erb-no-empty-tags\`? (herb-disable-comment-valid-rule-name) +[warning] Unknown rule \`this-rule-doesnt-exist\`. Did you mean \`source-indentation\`? (herb-disable-comment-valid-rule-name) test/fixtures/disabled-2.html.erb:4:30 @@ -1417,7 +1417,7 @@ test/fixtures/disabled-2.html.erb:4:30 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ [2/13] ⎯⎯⎯⎯ -[warning] Unknown rule \`this-rule-doesnt-exist\`. Did you mean \`erb-no-empty-tags\`? (herb-disable-comment-valid-rule-name) +[warning] Unknown rule \`this-rule-doesnt-exist\`. Did you mean \`source-indentation\`? (herb-disable-comment-valid-rule-name) test/fixtures/disabled-2.html.erb:6:35 @@ -1432,7 +1432,7 @@ test/fixtures/disabled-2.html.erb:6:35 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ [3/13] ⎯⎯⎯⎯ -[warning] Unknown rule \`this-rule-doesnt-exist\`. Did you mean \`erb-no-empty-tags\`? (herb-disable-comment-valid-rule-name) +[warning] Unknown rule \`this-rule-doesnt-exist\`. Did you mean \`source-indentation\`? (herb-disable-comment-valid-rule-name) test/fixtures/disabled-2.html.erb:8:55 @@ -1591,7 +1591,7 @@ test/fixtures/disabled-2.html.erb:2:44 actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once. @@ -1661,7 +1661,7 @@ test/fixtures/test-file-with-errors.html.erb:2:22 actionview-no-void-element-content (introduced in next release) html-require-script-nonce (introduced in next release) - source-space-indentation (introduced in next release) + source-indentation (introduced in next release) Run herb-lint --upgrade to update the version and disable all new rules, or update the version in your .herb.yml to "0.9.2" to enable them all at once." diff --git a/javascript/packages/linter/test/autofix/source-space-indentation.autofix.test.ts b/javascript/packages/linter/test/autofix/source-indentation.autofix.test.ts similarity index 82% rename from javascript/packages/linter/test/autofix/source-space-indentation.autofix.test.ts rename to javascript/packages/linter/test/autofix/source-indentation.autofix.test.ts index c6566c5fd..1e14462cc 100644 --- a/javascript/packages/linter/test/autofix/source-space-indentation.autofix.test.ts +++ b/javascript/packages/linter/test/autofix/source-indentation.autofix.test.ts @@ -4,9 +4,9 @@ import { Herb } from "@herb-tools/node-wasm" import { Config } from "@herb-tools/config" import { Linter } from "../../src/linter.js" -import { SourceSpaceIndentationRule } from "../../src/rules/source-space-indentation.js" +import { SourceIndentationRule } from "../../src/rules/source-indentation.js" -describe("source-space-indentation autofix", () => { +describe("source-indentation autofix", () => { beforeAll(async () => { await Herb.load() }) @@ -15,7 +15,7 @@ describe("source-space-indentation autofix", () => { const input = "\tthis is a line\n\tanother line\n" const expected = " this is a line\n another line\n" - const linter = new Linter(Herb, [SourceSpaceIndentationRule]) + const linter = new Linter(Herb, [SourceIndentationRule]) const result = linter.autofix(input) expect(result.source).toBe(expected) @@ -27,7 +27,7 @@ describe("source-space-indentation autofix", () => { const input = "\t\tthis is a line\n" const expected = " this is a line\n" - const linter = new Linter(Herb, [SourceSpaceIndentationRule]) + const linter = new Linter(Herb, [SourceIndentationRule]) const result = linter.autofix(input) expect(result.source).toBe(expected) @@ -39,7 +39,7 @@ describe("source-space-indentation autofix", () => { const input = " \t this is a line\n \t another line\n" const expected = " this is a line\n another line\n" - const linter = new Linter(Herb, [SourceSpaceIndentationRule]) + const linter = new Linter(Herb, [SourceIndentationRule]) const result = linter.autofix(input) expect(result.source).toBe(expected) @@ -50,7 +50,7 @@ describe("source-space-indentation autofix", () => { test("ignores space-only indentation", () => { const input = " this is a line\n another line\n" - const linter = new Linter(Herb, [SourceSpaceIndentationRule]) + const linter = new Linter(Herb, [SourceIndentationRule]) const result = linter.autofix(input) expect(result.source).toBe(input) @@ -61,7 +61,7 @@ describe("source-space-indentation autofix", () => { test("ignores lines without indentation", () => { const input = "this is a line\n" - const linter = new Linter(Herb, [SourceSpaceIndentationRule]) + const linter = new Linter(Herb, [SourceIndentationRule]) const result = linter.autofix(input) expect(result.source).toBe(input) @@ -72,7 +72,7 @@ describe("source-space-indentation autofix", () => { test("ignores tabs in the middle of a line", () => { const input = "hello\tworld\n" - const linter = new Linter(Herb, [SourceSpaceIndentationRule]) + const linter = new Linter(Herb, [SourceIndentationRule]) const result = linter.autofix(input) expect(result.source).toBe(input) @@ -84,7 +84,7 @@ describe("source-space-indentation autofix", () => { const input = "
\n\t

hello

\n
\n" const expected = "
\n

hello

\n
\n" - const linter = new Linter(Herb, [SourceSpaceIndentationRule]) + const linter = new Linter(Herb, [SourceIndentationRule]) const result = linter.autofix(input) expect(result.source).toBe(expected) @@ -96,7 +96,7 @@ describe("source-space-indentation autofix", () => { const input = "\tthis is a line\n\t\tindented twice\n" const expected = " this is a line\n indented twice\n" - const linter = new Linter(Herb, [SourceSpaceIndentationRule]) + const linter = new Linter(Herb, [SourceIndentationRule]) const result = linter.autofix(input, { indentWidth: 4 }) expect(result.source).toBe(expected) @@ -114,7 +114,7 @@ describe("source-space-indentation autofix", () => { }, linter: { rules: { - "source-space-indentation": { enabled: true } + "source-indentation": { enabled: true } } } }) diff --git a/javascript/packages/linter/test/rules/source-space-indentation.test.ts b/javascript/packages/linter/test/rules/source-indentation.test.ts similarity index 87% rename from javascript/packages/linter/test/rules/source-space-indentation.test.ts rename to javascript/packages/linter/test/rules/source-indentation.test.ts index 876075ce3..b3c5b44e2 100644 --- a/javascript/packages/linter/test/rules/source-space-indentation.test.ts +++ b/javascript/packages/linter/test/rules/source-indentation.test.ts @@ -1,11 +1,11 @@ import { describe, test } from "vitest" -import { SourceSpaceIndentationRule } from "../../src/rules/source-space-indentation.js" +import { SourceIndentationRule } from "../../src/rules/source-indentation.js" import { createLinterTest } from "../helpers/linter-test-helper.js" -const { expectNoOffenses, expectError, assertOffenses } = createLinterTest(SourceSpaceIndentationRule) +const { expectNoOffenses, expectError, assertOffenses } = createLinterTest(SourceIndentationRule) -describe("SourceSpaceIndentationRule", () => { +describe("SourceIndentationRule", () => { test("ignores empty lines", () => { expectNoOffenses("\n\n\n") })