@herb-tools/config 0.8.3 → 0.8.5
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/README.md +1 -1
- package/dist/herb-config.cjs +62 -5
- package/dist/herb-config.cjs.map +1 -1
- package/dist/herb-config.esm.js +62 -5
- package/dist/herb-config.esm.js.map +1 -1
- package/dist/package.json +3 -3
- package/dist/src/config.js +60 -3
- package/dist/src/config.js.map +1 -1
- package/dist/types/config.d.ts +17 -1
- package/dist/types/src/config.d.ts +17 -1
- package/package.json +3 -3
- package/src/config-template.yml +1 -1
- package/src/config.ts +70 -3
package/dist/herb-config.esm.js
CHANGED
|
@@ -11801,17 +11801,19 @@ function deepMerge(target, source) {
|
|
|
11801
11801
|
return output;
|
|
11802
11802
|
}
|
|
11803
11803
|
|
|
11804
|
-
var version = "0.8.
|
|
11804
|
+
var version = "0.8.5";
|
|
11805
11805
|
var packageJson = {
|
|
11806
11806
|
version: version};
|
|
11807
11807
|
|
|
11808
|
-
var configTemplate = "# This file configures Herb for your project and team.\n# Settings here take precedence over individual editor preferences.\n#\n# Herb is a suite of tools for HTML+ERB templates including:\n# - Linter: Validates templates and enforces best practices\n# - Formatter: Auto-formats templates with intelligent indentation\n# - Language Server: Provides IDE support (VS Code, Zed, Neovim, etc.)\n#\n# Website: https://herb-tools.dev\n# Configuration: https://herb-tools.dev/configuration\n# GitHub Repo: https://github.com/marcoroth/herb\n#\n\nversion: 0.8.
|
|
11808
|
+
var configTemplate = "# This file configures Herb for your project and team.\n# Settings here take precedence over individual editor preferences.\n#\n# Herb is a suite of tools for HTML+ERB templates including:\n# - Linter: Validates templates and enforces best practices\n# - Formatter: Auto-formats templates with intelligent indentation\n# - Language Server: Provides IDE support (VS Code, Zed, Neovim, etc.)\n#\n# Website: https://herb-tools.dev\n# Configuration: https://herb-tools.dev/configuration\n# GitHub Repo: https://github.com/marcoroth/herb\n#\n\nversion: 0.8.5\n\n# files:\n# # Additional patterns beyond the defaults (**.html, **.rhtml, **.html.erb, etc.)\n# include:\n# - '**/*.xml.erb'\n# - 'custom/**/*.html'\n#\n# # Patterns to exclude (can exclude defaults too)\n# exclude:\n# - 'public/**/*'\n# - 'tmp/**/*'\n\nlinter:\n enabled: true\n\n # # Additional patterns beyond the defaults for linting\n # include:\n # - '**/*.xml.erb'\n #\n # # Patterns to exclude from linting\n # exclude:\n # - 'app/views/admin/**/*'\n\n # rules:\n # erb-no-extra-newline:\n # enabled: false\n #\n # # Rules can have 'include', 'only', and 'exclude' patterns\n # some-rule:\n # # Additional patterns to check (additive, ignored when 'only' is present)\n # include:\n # - 'app/components/**/*'\n # # Don't apply this rule to files matching these patterns\n # exclude:\n # - 'app/views/admin/**/*'\n #\n # another-rule:\n # # Only apply this rule to files matching these patterns (overrides all 'include')\n # only:\n # - 'app/views/**/*'\n # # Exclude still applies even with 'only'\n # exclude:\n # - 'app/views/admin/**/*'\n\nformatter:\n enabled: false\n indentWidth: 2\n maxLineLength: 80\n\n # # Additional patterns beyond the defaults for formatting\n # include:\n # - '**/*.xml.erb'\n #\n # # Patterns to exclude from formatting\n # exclude:\n # - 'app/views/admin/**/*'\n\n # # Rewriters modify templates during formatting\n # rewriter:\n # # Pre-format rewriters (modify AST before formatting)\n # pre:\n # - tailwind-class-sorter\n # # Post-format rewriters (modify formatted output string)\n # post: []\n";
|
|
11809
11809
|
|
|
11810
11810
|
const DEFAULT_VERSION = packageJson.version;
|
|
11811
11811
|
class Config {
|
|
11812
11812
|
static configPath = ".herb.yml";
|
|
11813
11813
|
static PROJECT_INDICATORS = [
|
|
11814
11814
|
'.git',
|
|
11815
|
+
'.herb',
|
|
11816
|
+
'.herb.yml',
|
|
11815
11817
|
'Gemfile',
|
|
11816
11818
|
'package.json',
|
|
11817
11819
|
'Rakefile',
|
|
@@ -11856,10 +11858,10 @@ class Config {
|
|
|
11856
11858
|
}
|
|
11857
11859
|
/**
|
|
11858
11860
|
* Check if the formatter is enabled.
|
|
11859
|
-
* @returns true if formatter is enabled
|
|
11861
|
+
* @returns true if formatter is explicitly enabled, false otherwise (default)
|
|
11860
11862
|
*/
|
|
11861
11863
|
get isFormatterEnabled() {
|
|
11862
|
-
return this.config.formatter?.enabled ?? Config.getDefaultConfig().formatter?.enabled ??
|
|
11864
|
+
return this.config.formatter?.enabled ?? Config.getDefaultConfig().formatter?.enabled ?? false;
|
|
11863
11865
|
}
|
|
11864
11866
|
/**
|
|
11865
11867
|
* Check if a specific rule is disabled.
|
|
@@ -12103,6 +12105,61 @@ class Config {
|
|
|
12103
12105
|
return false;
|
|
12104
12106
|
}
|
|
12105
12107
|
}
|
|
12108
|
+
/**
|
|
12109
|
+
* Find the project root by walking up from a given path.
|
|
12110
|
+
* Looks for .herb.yml first, then falls back to project indicators
|
|
12111
|
+
* (.git, Gemfile, package.json, etc.)
|
|
12112
|
+
*
|
|
12113
|
+
* @param startPath - File or directory path to start searching from
|
|
12114
|
+
* @returns The project root directory path
|
|
12115
|
+
*/
|
|
12116
|
+
static async findProjectRoot(startPath) {
|
|
12117
|
+
const { projectRoot } = await this.findConfigFile(startPath);
|
|
12118
|
+
return projectRoot;
|
|
12119
|
+
}
|
|
12120
|
+
/**
|
|
12121
|
+
* Synchronous version of findProjectRoot for use in CLIs.
|
|
12122
|
+
*
|
|
12123
|
+
* @param startPath - File or directory path to start searching from
|
|
12124
|
+
* @returns The project root directory path
|
|
12125
|
+
*/
|
|
12126
|
+
static findProjectRootSync(startPath) {
|
|
12127
|
+
const fsSync = require('fs');
|
|
12128
|
+
let currentPath = path$1.resolve(startPath);
|
|
12129
|
+
try {
|
|
12130
|
+
const stats = fsSync.statSync(currentPath);
|
|
12131
|
+
if (stats.isFile()) {
|
|
12132
|
+
currentPath = path$1.dirname(currentPath);
|
|
12133
|
+
}
|
|
12134
|
+
}
|
|
12135
|
+
catch {
|
|
12136
|
+
currentPath = path$1.resolve(process.cwd());
|
|
12137
|
+
}
|
|
12138
|
+
while (true) {
|
|
12139
|
+
const configPath = path$1.join(currentPath, this.configPath);
|
|
12140
|
+
try {
|
|
12141
|
+
fsSync.accessSync(configPath);
|
|
12142
|
+
return currentPath;
|
|
12143
|
+
}
|
|
12144
|
+
catch {
|
|
12145
|
+
// Config not in this directory, continue
|
|
12146
|
+
}
|
|
12147
|
+
for (const indicator of this.PROJECT_INDICATORS) {
|
|
12148
|
+
try {
|
|
12149
|
+
fsSync.accessSync(path$1.join(currentPath, indicator));
|
|
12150
|
+
return currentPath;
|
|
12151
|
+
}
|
|
12152
|
+
catch {
|
|
12153
|
+
// Indicator not found, continue checking
|
|
12154
|
+
}
|
|
12155
|
+
}
|
|
12156
|
+
const parentPath = path$1.dirname(currentPath);
|
|
12157
|
+
if (parentPath === currentPath) {
|
|
12158
|
+
return process.cwd();
|
|
12159
|
+
}
|
|
12160
|
+
currentPath = parentPath;
|
|
12161
|
+
}
|
|
12162
|
+
}
|
|
12106
12163
|
/**
|
|
12107
12164
|
* Read raw YAML content from a config file.
|
|
12108
12165
|
* Handles both explicit .herb.yml paths and directory paths.
|
|
@@ -12644,7 +12701,7 @@ class Config {
|
|
|
12644
12701
|
rules: {}
|
|
12645
12702
|
},
|
|
12646
12703
|
formatter: {
|
|
12647
|
-
enabled:
|
|
12704
|
+
enabled: false,
|
|
12648
12705
|
indentWidth: 2,
|
|
12649
12706
|
maxLineLength: 80
|
|
12650
12707
|
}
|