Skip to content

Instantly share code, notes, and snippets.

@watson
Last active August 28, 2024 05:54
Show Gist options
  • Save watson/453fc63cace521fcdadc to your computer and use it in GitHub Desktop.
Save watson/453fc63cace521fcdadc to your computer and use it in GitHub Desktop.

Revisions

  1. watson revised this gist Aug 9, 2015. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -38,6 +38,12 @@ Note that this is by no means foolproof as it will also convert the double quote
    find . -path ./node_modules -prune -o -type f -name '*.js' -exec sed -i '' -e 's/ *,/,/g' {} \;
    ```

    **Ensure one a single space around equal signs:**

    ```
    find . -path ./node_modules -prune -o -type f -name '*.js' -exec sed -i '' -e 's/ *= */ = /g' {} \;
    ```

    **Remove space in front of colons:**

    ```
  2. watson revised this gist Jul 25, 2015. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -32,12 +32,18 @@ find . -path ./node_modules -prune -o -type f -name '*.js' -exec sed -i '' -E -e

    Note that this is by no means foolproof as it will also convert the double quotes inside the string `'foo"bar'`!

    **Remove space in front of colons:**
    **Remove space in front of commas:**

    ```
    find . -path ./node_modules -prune -o -type f -name '*.js' -exec sed -i '' -e 's/ *,/,/g' {} \;
    ```

    **Remove space in front of colons:**

    ```
    find . -path ./node_modules -prune -o -type f -name '*.js' -exec sed -i '' -e 's/ *:/:/g' {} \;
    ```

    **Remove trailing line space:**

    ```
  3. watson revised this gist Jul 25, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -30,7 +30,7 @@ find . -path ./node_modules -prune -o -type f -name '*.js' -exec sed -i '' -E -e
    find . -path ./node_modules -prune -o -type f -name '*.js' -exec sed -i '' -E -e "s/\"/'/g" {} \;
    ```

    Note that this is by no means not foolproof as it will also convert the double quotes in the string `'foo"bar'`!
    Note that this is by no means foolproof as it will also convert the double quotes inside the string `'foo"bar'`!

    **Remove space in front of colons:**

  4. watson revised this gist Jul 25, 2015. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    The [standard](https://github.com/feross/standard) code style linter is a great tool by Feross - check it out!

    **Remove trailing semicolons:**

    ```
    @@ -24,12 +26,12 @@ find . -path ./node_modules -prune -o -type f -name '*.js' -exec sed -i '' -E -e

    **Use single quotes when defining strings:**

    Note that this is by no means not foolprof as it will also convert the double quotes in the string `'foo"bar'`!

    ```
    find . -path ./node_modules -prune -o -type f -name '*.js' -exec sed -i '' -E -e "s/\"/'/g" {} \;
    ```

    Note that this is by no means not foolproof as it will also convert the double quotes in the string `'foo"bar'`!

    **Remove space in front of colons:**

    ```
  5. watson created this gist Jul 25, 2015.
    43 changes: 43 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    **Remove trailing semicolons:**

    ```
    find . -path ./node_modules -prune -o -type f -name '*.js' -exec sed -i '' -e 's/;$//' {} \;
    ```

    **Ensure space between `function` and opening bracket:**

    ```
    find . -path ./node_modules -prune -o -type f -name '*.js' -exec sed -i '' -e 's/function(/function (/g' {} \;
    ```

    **Ensure space after colons in object literal:**

    ```
    find . -path ./node_modules -prune -o -type f -name '*.js' -exec sed -i '' -E -e 's/:([^ ])/: \1/g' {} \;
    ```

    **Ensure space after commas in object literal:**

    ```
    find . -path ./node_modules -prune -o -type f -name '*.js' -exec sed -i '' -E -e 's/,([^ ])/, \1/g' {} \;
    ```

    **Use single quotes when defining strings:**

    Note that this is by no means not foolprof as it will also convert the double quotes in the string `'foo"bar'`!

    ```
    find . -path ./node_modules -prune -o -type f -name '*.js' -exec sed -i '' -E -e "s/\"/'/g" {} \;
    ```

    **Remove space in front of colons:**

    ```
    find . -path ./node_modules -prune -o -type f -name '*.js' -exec sed -i '' -e 's/ *,/,/g' {} \;
    ```

    **Remove trailing line space:**

    ```
    find . -path ./node_modules -prune -o -type f -name '*.js' -exec sed -i '' -e 's/ *$//' {} \;
    ```