Comments (6)
ruby 方面可以試試看 rubocop
裝好以後,開一個只抓 indent 相關的 rubocop config file
AllCops:
DisabledByDefault: true
Layout/IndentationWidth:
StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-indentation
Enabled: true
Width: 2
Layout/Tab:
StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-indentation
Enabled: true
在 command line 執行
rubocop --auto-correct
command line 的參數說明在 http://rubocop.readthedocs.io/en/latest/basic_usage/
但是你的 project 原本的 style 不固定的話,他可能會更正太多東西,所以你可能還要微調其他幾個參數例如
- Layout/CaseIndentation
- Layout/AccessModifierIndentation
- Layout/CommentIndentation
- ...
總之如果不滿意自動更正的結果,到 http://rubocop.readthedocs.io/en/latest/cops/#layout 找所有的 indent, space 相關的參數並調整 config
from ama.
如果只是 js 我會建議你使用 eslint -fix ,所有的 code style 一次解決
https://eslint.org/docs/user-guide/command-line-interface
from ama.
可以用 linux 的 find 和 sed 組合來解決 ?
from ama.
@aryung 我懂你的意思,就是單純使用正規表示法的 pattern 來取代。
你可以看我上面的測試附件,不固定的 space,那麼我 pattern 就要寫的更彈性才能符合需求。
from ama.
@puff-tw 測試文件可以補一下你想要變成的結果嗎?
from ama.
請參考最上面的結果附件
規則
- 1個 tab 視為 2個 space
- 2個space 視為 2個 space
- 不足2個space 視而不見
- 只限每行開頭的縮排,碰到文字後面有space、tab 不可以取代
範例
1個space 1個tab 變2個space
2個space 1個tab 變4個space
3個space 1個tab 變4個space
4個space 1個tab 變6個space
5個space 1個tab 變6個space
1個tab 1個space 變2個space
1個tab 2個space 變4個space
1個tab 3個space 變4個space
1個tab 4個space 變6個space
1個tab 5個space 變6個space
from ama.
Related Issues (20)
- 想請問一下 遠端機器環境建置問題 HOT 5
- fork gem 後指定 gem source 為自己的 github,capistrano deploy bundle 錯誤 HOT 10
- 請教Devise的問題 HOT 1
- 實作 Agile Web Development With Rails 4 HOT 5
- Agile Web Development With Rails 4 Chapter 11.5
- Agile Web Development With Rails 4 Chapter 11.5
- ActionCable 佈署到 production 後 WebSocket connection failed HOT 4
- 如何直接取得hash的size並作運算 HOT 2
- About rails breadcrumbs gem
- Rails5 WebSocket 偶爾 handshake 404 HOT 2
- 請問關於加密的問題 HOT 2
- 面試題目參考資料 HOT 1
- 請問為何 better_errors 無法在 Rails 4.2.0 + Ruby 2.2.0 上使用? HOT 2
- 請問要如何實做複選框+背景新增值的功能,或是有那種複選tagging的功能? HOT 11
- 為什麼 deep_dup 實作卻只是呼叫 dup HOT 1
- 請教一下,我把專案從Rails 4.2升級到 5.2,忽然Devise就無法登出了!!! HOT 5
- 請教一下,如何讓一個驗證失敗後就停住? HOT 2
- 想請教一下,如何讓事件點進去能在 Daterangepicker 顯示正確日期? HOT 3
- 商务
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ama.