Skip to content

Commit

Permalink
make the standard gods happy
Browse files Browse the repository at this point in the history
  • Loading branch information
leastbad committed Dec 28, 2022
1 parent 5237f4c commit d615494
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [12, 14, 16]
node: [14, 16, 18]

steps:
- uses: actions/checkout@master
Expand Down
2 changes: 0 additions & 2 deletions cable_ready.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ Gem::Specification.new do |gem|
"[A-Z]*"
]

gem.test_files = Dir["test/**/*.rb"]

rails_version = ">= 5.2"
gem.add_dependency "actioncable", rails_version
gem.add_dependency "actionpack", rails_version
Expand Down
7 changes: 2 additions & 5 deletions javascript/elements/updates_for_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ export default class UpdatesForElement extends SubscribingElement {
const blocks = Array.from(
document.querySelectorAll(this.query),
element => new Block(element)
)
).filter(block => block.shouldUpdate(data))

// first updates-for element in the DOM *at any given moment* updates all of the others
if (blocks[0].element !== this) return
if (blocks.length === 0 || blocks[0].element !== this) return

// hold a reference to the active element so that it can be restored after the morph
ActiveElement.set(document.activeElement)
Expand Down Expand Up @@ -113,9 +113,6 @@ class Block {
}

async process (data, html, index) {
// with the index incremented, we can now safely bail - before a fetch - if there's no work to be done
if (!this.shouldUpdate(data)) return

const blockIndex = index[this.url]
const template = document.createElement('template')
this.element.setAttribute('updating', 'updating')
Expand Down
2 changes: 1 addition & 1 deletion lib/cable_ready/channels.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def initialize

def [](*keys)
keys.select!(&:itself)
identifier = keys.many? || (keys.one? && keys.first.respond_to?(:to_global_id)) ? compound(keys) : keys.pop
identifier = (keys.many? || (keys.one? && keys.first.respond_to?(:to_global_id))) ? compound(keys) : keys.pop
@channels[identifier] ||= CableReady::Channel.new(identifier)
end

Expand Down
2 changes: 2 additions & 0 deletions lib/cable_ready/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,15 @@ def gemfile
end

def prefix
# standard:disable Style/RedundantStringEscape
@prefix ||= {
"vite" => "..\/",
"webpacker" => "",
"shakapacker" => "",
"importmap" => "",
"esbuild" => ".\/"
}[footgun]
# standard:enable Style/RedundantStringEscape
end

def application_record_path
Expand Down
4 changes: 2 additions & 2 deletions lib/install/esbuild.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
# uncomment_lines only works with Ruby comments 🙄
lines = pack_path.readlines
matches = lines.select { |line| line =~ controllers_commented_pattern }
lines[lines.index(matches.last).to_i] = "import \".\/controllers\"\n"
lines[lines.index(matches.last).to_i] = "import \".\/controllers\"\n" # standard:disable Style/RedundantStringEscape
pack_path.write lines.join
say "✅ Stimulus controllers imported in #{friendly_pack_path}"
else
Expand All @@ -91,7 +91,7 @@
else
lines = pack_path.readlines
matches = lines.select { |line| line =~ /^import / }
lines.insert lines.index(matches.last).to_i + 1, "import \".\/controllers\"\n"
lines.insert lines.index(matches.last).to_i + 1, "import \".\/controllers\"\n" # standard:disable Style/RedundantStringEscape
pack_path.write lines.join
say "✅ Stimulus controllers imported in #{friendly_pack_path}"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/install/mrujs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
say "✅ pin mrujs"
end

if !importmap.include?("pin \"mrujs\/plugins\"")
if !importmap.include?("pin \"mrujs/plugins\"")
append_file(importmap_path, <<~RUBY, verbose: false)
pin "mrujs/plugins", to: "https://ga.jspm.io/npm:[email protected]/plugins/dist/plugins.module.js"
RUBY
Expand Down Expand Up @@ -59,7 +59,7 @@
index = index_path.read
friendly_index_path = index_path.relative_path_from(Rails.root).to_s
mrujs_pattern = /import ['"].\/mrujs['"]/
mrujs_import = "import '.\/mrujs'\n"
mrujs_import = "import '.\/mrujs'\n" # standard:disable Style/RedundantStringEscape

if !index.match?(mrujs_pattern)
append_file(index_path, mrujs_import, verbose: false)
Expand Down
2 changes: 1 addition & 1 deletion lib/install/vite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

controllers_pattern = /import ['"](\.\.\/)?controllers['"]/
controllers_commented_pattern = /\s*\/\/\s*#{controllers_pattern}/
prefix = "..\/"
prefix = "..\/" # standard:disable Style/RedundantStringEscape

if pack.match?(controllers_pattern)
if pack.match?(controllers_commented_pattern)
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/cable_ready/cable_ready.rake
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace :cable_ready do
kv[1] = if kv[1] == "true"
true
else
kv[1] == "false" ? false : kv[1]
(kv[1] == "false") ? false : kv[1]
end
options[kv[0]] = kv[1]
end
Expand Down
2 changes: 1 addition & 1 deletion test/dummy/config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Rails.application.config.assets.version = '1.0'

# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
Expand Down

0 comments on commit d615494

Please sign in to comment.