diff --git a/CHANGELOG.md b/CHANGELOG.md index c6e5cac..9844494 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ - `Rails/MissingPartial` finds a partial in the format of the template that renders it, whichever gem or initializer registered that format: `index.mobile.haml` renders `_card.mobile.haml` (`mobile-fu`'s `:mobile`, a custom `.amp`) without a report. - `Rails/UnsafeOutput` no longer reports a safe call with a trailing `if` or `unless` (`== render "a" if x`, `<%== render "a" unless x %>`, `!= render "a" if x`). - `ruby-templates check` and `format` skip `lib/templates` (Rails generator templates), `vendor`, `tmp`, `public` and `log` when walking a folder, as well as hidden folders and `node_modules`; `app/views` may hold folders with those names, and files named on the command line are always processed. `.gitignore` is not read. +- `ruby-templates check` prints one note on stderr per Rails-looking app (`app/views` or `config/application.rb`) that has no `Gemfile.lock`, saying that the `Rails/*`, `Stimulus/*` and `Turbo/*` rules are off for lack of it. Exit codes and stdout don't change. +- ERB formatting no longer refuses a file for an inline `<%= tag.style x %>`, `<%= tag.script(src: x) %>`, `<%= javascript_tag "x" %>` or `content_tag :script, x`; only the block forms (`javascript_tag do`) still leave the file as it is. +- `ruby-templates check --help` and the command line guide say that Jbuilder and Builder views get their partial and `locals:` checks, not Ruby syntax errors, which stay with Ruby LSP. +- `insert_final_newline = true` in `.editorconfig` turns `Layout/TrailingEmptyLines` on for ERB (off by default there); `enabled = false` in a `.ruby-templates.toml` still wins. +- `Rails/UnsafeOutput` no longer reports a string whose interpolations are all safe (`"Hi #{h(name)}".html_safe`) or `truncate(...)` without `escape: false`. +- `Rails/UnsafeOutput` quotes long or multi-line code cut with `…` instead of saying "its value". - **Behaviour change:** `Rails/InstanceVariableInPartial` is information instead of a warning, so `ruby-templates check` no longer fails on it; the editor still shows it. - **Breaking:** the kebab-case diagnostic codes from before 0.11 (`img-missing-alt`, `unresolved-render`, ...) are no longer accepted in `disabledDiagnostics`, in the VS Code settings or `.ruby-templates.toml`. Use the rule names (`Html/ImgAlt`, `Rails/MissingPartial`), listed in the diagnostics reference; the toml reports an old code as an unknown rule. - **Breaking:** `ruby-templates-ls --check` and `ruby-templates-ls --format` are removed. Use `ruby-templates check` and `ruby-templates format`. diff --git a/server/src/cli.rs b/server/src/cli.rs index 1478442..bfa3e10 100644 --- a/server/src/cli.rs +++ b/server/src/cli.rs @@ -7,7 +7,7 @@ use crate::format::SkipKind; use crate::lang::TemplateLang; use crate::options::Options; use crate::rails::paths; -use crate::rails::project::{Project, Projects}; +use crate::rails::project::{missing_lockfile_note, Project, Projects}; use crate::rails::view_roots; use crate::report::{self, Finding, Format, Severity}; use crate::rules::file::ConfigFile; @@ -33,8 +33,8 @@ Usage: ruby-templates format [--check | --write] [--format text|github] [--verbose] [--align-comments] ... ruby-templates format [--check] [--format text|github] [--verbose] [--align-comments] --stdin-filepath [-] -check prints the diagnostics of ERB, Haml, Slim, Jbuilder and Builder templates, and with Layout/LineLength (off) the lines - over its max. +check prints the diagnostics of ERB, Haml, Slim, Jbuilder and Builder templates (for Jbuilder and Builder, partials and + locals, not Ruby syntax errors), and with Layout/LineLength (off) the lines over its max. format re-indents HTML ERB, Haml and Slim templates and fixes trailing whitespace. The rules Layout/EmptyLines, Layout/EmptyLinesAroundBlockBody, Layout/EmptyLinesAroundElementBody and Layout/EmptyLinesAroundBranches (all off) and Layout/TrailingEmptyLines (on for Haml and Slim, off for ERB) set blank lines and the final newline. @@ -297,12 +297,14 @@ struct Checked { /// The problems of each `.ruby-templates.toml` the file uses; the printer shows a file's once, with its first template. config: Vec<(PathBuf, Rendered)>, stderr: String, + /// The Rails-looking app the file is in when it has no `Gemfile.lock`, and its name for the note; the printer notes each app once. + unlocked_app: Option<(PathBuf, PathBuf)>, code: i32, } impl Checked { fn new(code: i32) -> Self { - Checked { rendered: Rendered::default(), config: Vec::new(), stderr: String::new(), code } + Checked { rendered: Rendered::default(), config: Vec::new(), stderr: String::new(), unlocked_app: None, code } } } @@ -329,8 +331,15 @@ fn check_file( let Ok(text) = std::fs::read_to_string(path) else { return failed(format!("cannot read {shown}\n")) }; let Some((uri, lang)) = absolute_file_uri(path).zip(language(path)) else { return failed(format!("{shown}: unknown template type\n")) }; // Every worker's projects of one app share its view roots. - Project::memoized(projects, path, Some(view_roots)); + // The path as the diagnostics see it, so a relative `check x/f.erb` finds the app above the working folder. + let real = util::file_path(&uri).unwrap_or_else(|| path.to_path_buf()); + let project = Project::memoized(projects, &real, Some(view_roots)); let mut checked = Checked::new(OK); + checked.unlocked_app = project.rails_root_without_lockfile(&real).map(|app| { + let shown = shown_path(&app, output.cwd); + let shown = if shown.as_os_str().is_empty() { Path::new(".") } else { shown }; + (app.clone(), shown.to_path_buf()) + }); let rules = resolve(&uri, lang, &Options::default(), configs); for file in rules.files().iter().filter(|file| !file.problems.is_empty()) { let rendered = render_config_problems(file, output); @@ -377,22 +386,27 @@ fn print_in_order(results: mpsc::Receiver<(usize, Checked)>, format: Format) -> let mut code = OK; let mut findings = Vec::new(); let mut reported = HashSet::new(); + let mut noted_apps = HashSet::new(); for (index, checked) in results { waiting.insert(index, checked); while let Some(checked) = waiting.remove(&next) { next += 1; code = code.max(checked.code); + let mut stderr = checked.stderr; + if let Some((_, shown)) = checked.unlocked_app.filter(|(app, _)| noted_apps.insert(app.clone())) { + stderr.push_str(&missing_lockfile_note(&shown)); + } let new_config = checked.config.into_iter().filter(|(path, _)| reported.insert(path.clone())); let shown: Vec = new_config.map(|(_, rendered)| rendered).chain([checked.rendered]).collect(); let text: String = shown.iter().map(|rendered| rendered.stdout.as_str()).collect(); findings.extend(shown.into_iter().flat_map(|rendered| rendered.findings)); let printed = stdout.write_all(text.as_bytes()).and_then(|()| { - if checked.stderr.is_empty() { + if stderr.is_empty() { return Ok(()); } // Keep stderr lines in place among the diagnostics. stdout.flush()?; - std::io::stderr().write_all(checked.stderr.as_bytes()) + std::io::stderr().write_all(stderr.as_bytes()) }); if printed.is_err() { return USAGE; @@ -477,7 +491,7 @@ fn format_text( (Some(uri), Some(lang)) => { let rules = resolve(&uri, lang, &Options::default(), configs); let resolved = config::settings_for(&util::file_path(&uri).unwrap_or_else(|| path.to_path_buf())); - let mut settings = rules.format_settings(resolved.settings); + let mut settings = rules.format_settings(resolved.settings, resolved.insert_final_newline); settings.align_comments |= args.align_comments; if args.verbose { print_verbose(&shown.to_string(), &settings, &resolved.notes, (&rules, cwd)); diff --git a/server/src/config.rs b/server/src/config.rs index 15ed206..dd5a606 100644 --- a/server/src/config.rs +++ b/server/src/config.rs @@ -1,5 +1,5 @@ -//! The indentation width and style of a file, from the project's `.editorconfig`. The editor's tab size and `insertSpaces` go on top -//! in the language server (`Settings::with_editor`). Every other property is ignored and listed in the notes. +//! The indentation width and style and the final newline of a file, from the project's `.editorconfig`. The editor's tab size and +//! `insertSpaces` go on top in the language server (`Settings::with_editor`). Every other property is ignored and listed in the notes. use crate::format::{IndentStyle, Settings}; use crate::glob::Glob; @@ -9,23 +9,28 @@ use std::path::Path; /// Settings for one file, and what was read or ignored to get them. pub struct Resolved { pub settings: Settings, + /// `insert_final_newline = true`: turns `Layout/TrailingEmptyLines` on where it is off by default (ERB). + pub insert_final_newline: bool, pub notes: Vec, } pub fn settings_for(path: &Path) -> Resolved { let mut notes = Vec::new(); let defaults = Settings::default(); - let (size, style) = editorconfig_indent(path, &mut notes); - let settings = - Settings { indent_size: size.unwrap_or(defaults.indent_size), indent_style: style.unwrap_or(defaults.indent_style), ..defaults }; - Resolved { settings, notes } + let properties = editorconfig_properties(path, &mut notes); + let settings = Settings { + indent_size: indent_size(&properties).unwrap_or(defaults.indent_size), + indent_style: indent_style(&properties).unwrap_or(defaults.indent_style), + ..defaults + }; + Resolved { settings, insert_final_newline: property(&properties, "insert_final_newline") == Some("true"), notes } } -/// The indentation width and style from the `.editorconfig` properties that apply to `path`: files from the root (or the topmost -/// `root = true`) down, later sections and nearer files winning, as the EditorConfig spec has it. -fn editorconfig_indent(path: &Path, notes: &mut Vec) -> (Option, Option) { +/// The `.editorconfig` properties that apply to `path`: files from the root (or the topmost `root = true`) down, later sections +/// and nearer files winning, as the EditorConfig spec has it. +fn editorconfig_properties(path: &Path, notes: &mut Vec) -> Vec<(String, String)> { if path.file_name().is_none() { - return (None, None); + return Vec::new(); } let mut properties = Vec::new(); for (dir, text) in editorconfig_files(path).iter().rev() { @@ -37,7 +42,7 @@ fn editorconfig_indent(path: &Path, notes: &mut Vec) -> (Option, for (key, value) in properties.iter().filter(|(k, v)| v != "unset" && !is_understood(k, v)) { notes.push(format!(".editorconfig: ignored {key} = {value}")); } - (indent_size(&properties), indent_style(&properties)) + properties } /// The folders above `path` that hold an `.editorconfig`, with its text: nearest first, up to the first `root = true`. @@ -109,6 +114,8 @@ fn is_understood(key: &str, value: &str) -> bool { "indent_style" => matches!(value, "space" | "tab"), "indent_size" => value == "tab" || positive_number(value).is_some(), "tab_width" => positive_number(value).is_some(), + // `false` changes nothing: the final newline is only ever added. + "insert_final_newline" => value == "true", _ => false, } } @@ -195,6 +202,16 @@ mod tests { assert!(project.settings("a.html.erb").notes.iter().all(|n| !n.contains("ignored")), "indent_style is understood"); } + #[test] + fn editorconfig_insert_final_newline_true_is_read() { + let text = "[*.erb]\ninsert_final_newline = true\n[*.slim]\ninsert_final_newline = false\n"; + let project = Project::new("newline", &[(".editorconfig", text), ("a.html.erb", ""), ("b.html.slim", ""), ("c.html.haml", "")]); + let newline = |file: &str| project.settings(file).insert_final_newline; + assert_eq!((newline("a.html.erb"), newline("b.html.slim"), newline("c.html.haml")), (true, false, false)); + let notes = project.settings("a.html.erb").notes; + assert!(notes.iter().all(|n| !n.contains("ignored")), "{notes:?}"); + } + #[test] fn editorconfig_tab_width_and_unreadable_values() { let text = "[*]\nindent_style = space\ntab_width = 8\ntrim_trailing_whitespace = yes\n[[z-a].erb]\nindent_size = 3\n"; diff --git a/server/src/erb/tags.rs b/server/src/erb/tags.rs index f4935f5..224bfc6 100644 --- a/server/src/erb/tags.rs +++ b/server/src/erb/tags.rs @@ -403,7 +403,7 @@ pub(crate) fn tag_end(html: &[u8], from: usize) -> Option { /// HTML with ERB tags blanked out, plus every ERB tag as an event, in order. Tags are Erubi's; a `<%%` literal /// renders as text, so it stays in the HTML. With `skip_raw_blocks` the JS/CSS block helpers' bodies are blanked and -/// their events dropped; without, any such helper makes the result `None`. +/// their events dropped; without, any such helper with a block makes the result `None`. fn split<'a>( text: &'a str, analyzed: &[(erb::ruby::ErbTag<'a>, BlockEffect)], @@ -423,7 +423,8 @@ fn split<'a>( (BlockEffect::Neutral, "", "") } else { let snippet = &text[tag.code.clone()]; - if RAW_BLOCK.is_match(snippet) && (!skip_raw_blocks || BRACE_BLOCK_OPEN.is_match(snippet)) { + let unreadable_block = BRACE_BLOCK_OPEN.is_match(snippet) || (!skip_raw_blocks && matches!(effect, BlockEffect::Open(_))); + if RAW_BLOCK.is_match(snippet) && unreadable_block { return None; } (*effect, snippet.split_whitespace().next().unwrap_or(""), snippet) diff --git a/server/src/format/erb.rs b/server/src/format/erb.rs index 55ee245..57e4a9b 100644 --- a/server/src/format/erb.rs +++ b/server/src/format/erb.rs @@ -823,6 +823,14 @@ mod tests { } } + #[test] + fn inline_script_and_style_helpers_without_a_block_are_indented() { + for helper in ["tag.style x", "tag.script(src: x)", "javascript_tag \"x\"", "content_tag :script, x"] { + let out = indent(&format!("
\n<%= {helper} %>\n
\n"), " ", false).unwrap(); + assert_eq!(out.text, format!("
\n <%= {helper} %>\n
\n"), "{helper}"); + } + } + fn with_blank_lines(text: &str, settings: &Settings) -> String { let indented = indent(text, " ", false).unwrap(); crate::format::blank_lines::apply(&indented.text, &indented.lines, settings, text) diff --git a/server/src/lsp.rs b/server/src/lsp.rs index 19ceb11..648eaf8 100644 --- a/server/src/lsp.rs +++ b/server/src/lsp.rs @@ -877,8 +877,10 @@ impl Backend { if rules.excluded_by().is_some() || !rules.format_enabled() { return (Arc::new(rules), None); } - let base = util::file_path(&uri).map_or_else(format::Settings::default, |path| config::settings_for(&path).settings); - let mut settings = rules.format_settings(base.with_editor(&options)); + let resolved = util::file_path(&uri).map(|path| config::settings_for(&path)); + let insert_final_newline = resolved.as_ref().is_some_and(|resolved| resolved.insert_final_newline); + let base = resolved.map_or_else(format::Settings::default, |resolved| resolved.settings); + let mut settings = rules.format_settings(base.with_editor(&options), insert_final_newline); if lines_only { // A range can't add or remove a line, and may hold a comment's inner lines without the line they move with. settings.trailing_empty_lines = false; diff --git a/server/src/rails/project.rs b/server/src/rails/project.rs index f552c9f..142d248 100644 --- a/server/src/rails/project.rs +++ b/server/src/rails/project.rs @@ -17,6 +17,14 @@ use walkdir::WalkDir; pub const LOCKFILE: &str = "Gemfile.lock"; const RUBY_VERSION_FILE: &str = ".ruby-version"; +/// Tells why a Rails-looking app at `root` gets no Rails, Stimulus or Turbo rules. +pub fn missing_lockfile_note(root: &Path) -> String { + format!( + "note: {} looks like a Rails app but has no {LOCKFILE}, so the Rails/*, Stimulus/* and Turbo/* rules are off: they need its actionview gem\n", + root.display() + ) +} + #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Framework { Rails, @@ -191,6 +199,16 @@ impl Project { } } + /// The folder of a Rails-looking app (`app/views` or `config/application.rb`) that holds `template` when no `Gemfile.lock` is + /// above it: its Rails, Stimulus and Turbo rules are off. + pub fn rails_root_without_lockfile(&self, template: &Path) -> Option { + if self.root.is_some() { + return None; + } + let looks_like_rails = |dir: &&Path| dir.join(APP_VIEWS).is_dir() || dir.join("config/application.rb").is_file(); + template.ancestors().skip(1).find(looks_like_rails).map(Path::to_path_buf) + } + /// Is `segment` a template format: one of Rails' own or registered by the app? pub fn is_format(&self, segment: &str) -> bool { is_known_format(segment) || self.formats.iter().any(|f| f == segment) diff --git a/server/src/rails/unsafe_output.rs b/server/src/rails/unsafe_output.rs index 58156b8..dc1450d 100644 --- a/server/src/rails/unsafe_output.rs +++ b/server/src/rails/unsafe_output.rs @@ -14,7 +14,7 @@ use tower_lsp_server::ls_types::Diagnostic; pub(crate) const UNSAFE_OUTPUT: &str = "Rails/UnsafeOutput"; const SANITIZE_HINT: &str = "use `sanitize` if it holds user HTML"; -/// Longer code is not quoted in the message. +/// Longer code, and code past its first line, is cut in the message. const MAX_QUOTED_LEN: usize = 40; /// Helpers whose result is safe markup, or is escaped for the place it goes to. @@ -96,11 +96,11 @@ impl Finder<'_> { fn quoted(&self, expression: &Node) -> String { let location = expression.location(); - let code = &self.compiled.source[location.start() as usize..location.end() as usize]; - if code.len() > MAX_QUOTED_LEN || code.contains('\n') { - return "its value".into(); - } - format!("`{code}`") + let code = self.compiled.source[location.start() as usize..location.end() as usize].trim(); + let first_line = code.lines().next().unwrap_or(code); + let shown: String = first_line.chars().take(MAX_QUOTED_LEN).collect(); + let cut = if shown.len() < code.len() { "…" } else { "" }; + format!("`{}{cut}`", shown.trim_end()) } /// A node that is the whole code of an output tag or line, and has an unescaped marker before it. @@ -183,9 +183,9 @@ fn unwrapped<'pr>(node: Node<'pr>) -> Node<'pr> { /// Whether the expression is certainly safe to output unescaped: a literal, or what a helper that makes safe HTML returns. fn is_safe(source: &str, expression: &Node) -> bool { - let adjacent_literals = - expression.as_interpolated_string_node().is_some_and(|string| string.parts().iter().all(|part| part.as_string_node().is_some())); - let literal = adjacent_literals + let safe_string = + expression.as_interpolated_string_node().is_some_and(|string| string.parts().iter().all(|part| is_safe_part(source, &part))); + let literal = safe_string || expression.as_yield_node().is_some() || expression.as_string_node().is_some() || expression.as_symbol_node().is_some() @@ -197,7 +197,11 @@ fn is_safe(source: &str, expression: &Node) -> bool { let Some(call) = expression.as_call_node() else { return literal }; let name = String::from_utf8_lossy(call.name().as_slice()); let Some(receiver) = call.receiver() else { - return if TRANSLATIONS.contains(&name.as_ref()) { translates_html(&call) } else { SAFE_HELPERS.contains(&name.as_ref()) }; + return match name.as_ref() { + _ if TRANSLATIONS.contains(&name.as_ref()) => translates_html(&call), + "truncate" => truncate_escapes(&call), + _ => SAFE_HELPERS.contains(&name.as_ref()), + }; }; let location = receiver.location(); let receiver_code = &source[location.start() as usize..location.end() as usize]; @@ -206,6 +210,50 @@ fn is_safe(source: &str, expression: &Node) -> bool { escapes || (is_tag_builder && TAG_BUILDER_ELEMENTS.contains(&name.as_ref())) } +/// Escapers for a JavaScript string, which leave `<` alone: not safe inside HTML. +const JS_ESCAPERS: &[&str] = &["j", "escape_javascript"]; + +/// A part of a string literal that adds nothing unsafe: text, or `#{…}` of a safe expression (`"#{h(name)}"`). +fn is_safe_part(source: &str, part: &Node) -> bool { + if part.as_string_node().is_some() { + return true; + } + if let Some(nested) = part.as_interpolated_string_node() { + return nested.parts().iter().all(|part| is_safe_part(source, &part)); + } + let Some(statements) = part.as_embedded_statements_node().and_then(|embedded| embedded.statements()) else { return false }; + let mut body = statements.body().iter(); + let (Some(only), None) = (body.next(), body.next()) else { return false }; + let only = unwrapped(only); + let js_escaper = only + .as_call_node() + .is_some_and(|call| call.receiver().is_none() && JS_ESCAPERS.iter().any(|name| call.name().as_slice() == name.as_bytes())); + !js_escaper && is_safe(source, &only) +} + +/// `truncate` escapes its result (a `SafeBuffer`) unless called with `escape: false`; options it can't read are not trusted. +fn truncate_escapes(call: &CallNode) -> bool { + let Some(arguments) = call.arguments() else { return false }; + // A splat or `...` may carry `escape: false`. + if arguments.arguments().iter().any(|argument| argument.as_splat_node().is_some() || argument.as_forwarding_arguments_node().is_some()) + { + return false; + } + let options = arguments.arguments().iter().skip(1); + options.into_iter().all(|option| { + let Some(hash) = + option.as_keyword_hash_node().map(|hash| hash.elements()).or_else(|| option.as_hash_node().map(|hash| hash.elements())) + else { + return false; + }; + hash.iter().all(|element| { + let Some(pair) = element.as_assoc_node() else { return false }; + let is_escape = pair.key().as_symbol_node().is_some_and(|key| key.unescaped() == b"escape"); + !is_escape || pair.value().as_true_node().is_some() + }) + }) +} + /// `t(".name_html")`: the key is a literal that Rails marks safe. fn translates_html(call: &CallNode) -> bool { let Some(key) = call.arguments().and_then(|arguments| arguments.arguments().iter().next()) else { return false }; @@ -402,4 +450,40 @@ mod tests { assert!(flagged(Erb, "<%= raw \"a\" \"\" %>\n<%= (\"a\" 'b').html_safe %>\n").is_empty()); assert_eq!(flagged(Erb, "<%= raw \"a\" \"#{@b}\" %>\n"), ["raw"]); } + + #[test] + fn escaped_interpolations_and_truncate_are_quiet() { + assert!(flagged(Erb, "<%= \"Hi #{h(@q)}\".html_safe %>\n<%= raw \"#{html_escape(@a)} #{sanitize(@b)}\" %>\n").is_empty()); + assert!(flagged(Slim, "== \"Hi #{h(@q)}\"\n").is_empty()); + assert_eq!( + flagged(Erb, "<%= \"Hi #{@q}\".html_safe %>\n<%= \"#{h(@a)}#{@b}\".html_safe %>\n<%= \"#@q\".html_safe %>\n"), + ["html_safe"; 3] + ); + assert!(flagged(Erb, "<%= truncate(@x, length: 5).html_safe %>\n<%= raw truncate(@x) %>\n<%= truncate(@x, escape: true) { link_to \"a\", b }.html_safe %>\n").is_empty()); + let unsafe_truncates = + "<%= truncate(@x, escape: false).html_safe %>\n<%= truncate(@x, opts).html_safe %>\n<%= truncate(@x, **opts).html_safe %>\n\ + <%= truncate(@x, escape: @e).html_safe %>\n<%= @x.truncate(5).html_safe %>\n"; + assert_eq!(flagged(Erb, unsafe_truncates), ["html_safe"; 5]); + } + + #[test] + fn js_escapers_splats_and_nested_literals_in_safe_strings() { + let unsafe_cases = "<%= \"

#{j(@q)}

\".html_safe %>\n<%= \"

#{escape_javascript(@q)}

\".html_safe %>\n\ + <%= truncate(*args).html_safe %>\n<%= truncate(@x, *opts).html_safe %>\n<%= (\"a\" \"#{@y}\").html_safe %>\n"; + assert_eq!(flagged(Erb, unsafe_cases), ["html_safe"; 5]); + assert!(flagged(Erb, "<%= (\"a\" \"#{h @y}\").html_safe %>\n").is_empty()); + } + + #[test] + fn long_and_multi_line_code_is_quoted_cut() { + let message = |lang, text| found(lang, text).remove(0).1; + assert_eq!( + message(Slim, "== t('.x', name: user.name, other: user.other_name_long)\n"), + "`==` outputs `t('.x', name: user.name, other: user.oth…` without escaping; use `sanitize` if it holds user HTML" + ); + assert_eq!( + message(Erb, "<%= raw t('.x',\n a: 1) %>\n"), + "`raw` outputs `t('.x',…` without escaping; use `sanitize` if it holds user HTML" + ); + } } diff --git a/server/src/rules/resolve.rs b/server/src/rules/resolve.rs index eb88501..94d8406 100644 --- a/server/src/rules/resolve.rs +++ b/server/src/rules/resolve.rs @@ -34,6 +34,8 @@ pub struct ResolvedRules { /// `Layout/EmptyLines`: the longest run of blank lines kept; `None` when the rule is off. max_empty_lines: Option, trailing_empty_lines: bool, + /// `trailing_empty_lines` as an `insert_final_newline = true` in `.editorconfig` sets it: on unless the config turns the rule off. + trailing_empty_lines_with_final_newline: bool, around_block_body: Option