@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/README.md
CHANGED
package/dist/herb-config.cjs
CHANGED
|
@@ -11822,17 +11822,19 @@ function deepMerge(target, source) {
|
|
|
11822
11822
|
return output;
|
|
11823
11823
|
}
|
|
11824
11824
|
|
|
11825
|
-
var version = "0.8.
|
|
11825
|
+
var version = "0.8.5";
|
|
11826
11826
|
var packageJson = {
|
|
11827
11827
|
version: version};
|
|
11828
11828
|
|
|
11829
|
-
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.
|
|
11829
|
+
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";
|
|
11830
11830
|
|
|
11831
11831
|
const DEFAULT_VERSION = packageJson.version;
|
|
11832
11832
|
class Config {
|
|
11833
11833
|
static configPath = ".herb.yml";
|
|
11834
11834
|
static PROJECT_INDICATORS = [
|
|
11835
11835
|
'.git',
|
|
11836
|
+
'.herb',
|
|
11837
|
+
'.herb.yml',
|
|
11836
11838
|
'Gemfile',
|
|
11837
11839
|
'package.json',
|
|
11838
11840
|
'Rakefile',
|
|
@@ -11877,10 +11879,10 @@ class Config {
|
|
|
11877
11879
|
}
|
|
11878
11880
|
/**
|
|
11879
11881
|
* Check if the formatter is enabled.
|
|
11880
|
-
* @returns true if formatter is enabled
|
|
11882
|
+
* @returns true if formatter is explicitly enabled, false otherwise (default)
|
|
11881
11883
|
*/
|
|
11882
11884
|
get isFormatterEnabled() {
|
|
11883
|
-
return this.config.formatter?.enabled ?? Config.getDefaultConfig().formatter?.enabled ??
|
|
11885
|
+
return this.config.formatter?.enabled ?? Config.getDefaultConfig().formatter?.enabled ?? false;
|
|
11884
11886
|
}
|
|
11885
11887
|
/**
|
|
11886
11888
|
* Check if a specific rule is disabled.
|
|
@@ -12124,6 +12126,61 @@ class Config {
|
|
|
12124
12126
|
return false;
|
|
12125
12127
|
}
|
|
12126
12128
|
}
|
|
12129
|
+
/**
|
|
12130
|
+
* Find the project root by walking up from a given path.
|
|
12131
|
+
* Looks for .herb.yml first, then falls back to project indicators
|
|
12132
|
+
* (.git, Gemfile, package.json, etc.)
|
|
12133
|
+
*
|
|
12134
|
+
* @param startPath - File or directory path to start searching from
|
|
12135
|
+
* @returns The project root directory path
|
|
12136
|
+
*/
|
|
12137
|
+
static async findProjectRoot(startPath) {
|
|
12138
|
+
const { projectRoot } = await this.findConfigFile(startPath);
|
|
12139
|
+
return projectRoot;
|
|
12140
|
+
}
|
|
12141
|
+
/**
|
|
12142
|
+
* Synchronous version of findProjectRoot for use in CLIs.
|
|
12143
|
+
*
|
|
12144
|
+
* @param startPath - File or directory path to start searching from
|
|
12145
|
+
* @returns The project root directory path
|
|
12146
|
+
*/
|
|
12147
|
+
static findProjectRootSync(startPath) {
|
|
12148
|
+
const fsSync = require('fs');
|
|
12149
|
+
let currentPath = path$1.resolve(startPath);
|
|
12150
|
+
try {
|
|
12151
|
+
const stats = fsSync.statSync(currentPath);
|
|
12152
|
+
if (stats.isFile()) {
|
|
12153
|
+
currentPath = path$1.dirname(currentPath);
|
|
12154
|
+
}
|
|
12155
|
+
}
|
|
12156
|
+
catch {
|
|
12157
|
+
currentPath = path$1.resolve(process.cwd());
|
|
12158
|
+
}
|
|
12159
|
+
while (true) {
|
|
12160
|
+
const configPath = path$1.join(currentPath, this.configPath);
|
|
12161
|
+
try {
|
|
12162
|
+
fsSync.accessSync(configPath);
|
|
12163
|
+
return currentPath;
|
|
12164
|
+
}
|
|
12165
|
+
catch {
|
|
12166
|
+
// Config not in this directory, continue
|
|
12167
|
+
}
|
|
12168
|
+
for (const indicator of this.PROJECT_INDICATORS) {
|
|
12169
|
+
try {
|
|
12170
|
+
fsSync.accessSync(path$1.join(currentPath, indicator));
|
|
12171
|
+
return currentPath;
|
|
12172
|
+
}
|
|
12173
|
+
catch {
|
|
12174
|
+
// Indicator not found, continue checking
|
|
12175
|
+
}
|
|
12176
|
+
}
|
|
12177
|
+
const parentPath = path$1.dirname(currentPath);
|
|
12178
|
+
if (parentPath === currentPath) {
|
|
12179
|
+
return process.cwd();
|
|
12180
|
+
}
|
|
12181
|
+
currentPath = parentPath;
|
|
12182
|
+
}
|
|
12183
|
+
}
|
|
12127
12184
|
/**
|
|
12128
12185
|
* Read raw YAML content from a config file.
|
|
12129
12186
|
* Handles both explicit .herb.yml paths and directory paths.
|
|
@@ -12665,7 +12722,7 @@ class Config {
|
|
|
12665
12722
|
rules: {}
|
|
12666
12723
|
},
|
|
12667
12724
|
formatter: {
|
|
12668
|
-
enabled:
|
|
12725
|
+
enabled: false,
|
|
12669
12726
|
indentWidth: 2,
|
|
12670
12727
|
maxLineLength: 80
|
|
12671
12728
|
}
|