Created
June 28, 2017 08:12
-
-
Save jpaulin/8b4a819a65416616d9beef6ffaa0bcc9 to your computer and use it in GitHub Desktop.
Fitsy - search for occurrence of inline stylesheets in TypeScript based React Native code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# TypeScript / react native tooling: "fitsy" search tool | |
# | |
# Configuration | |
# Set the 'lookfor' variable string to any pattern that matches the source code | |
# snippets you like to search for | |
# | |
# Add features | |
# 1. multi-instance per one line: enable matching all | |
# 2. printing options: just print -c count of elements | |
# 3. ? <Add your idea> | |
# | |
# - separate printing formats from the matching logic | |
# | |
# The dogmatic form of the occurrence shall be decided. | |
# | |
# The default string to match: looking for use of named inline stylesheets | |
lookfor='styles\.[a-z]' | |
# | |
# overriding is possible if 1. parameter on command line is given | |
if [ ! -z $1 ]; then | |
lookfor=$1 | |
fi | |
# Look for for a named Stylesheet usage on Typescript files *.tsx | |
# (trim leading whitespace from the output) | |
grep -i $lookfor *.tsx | sed 's/^[ \t]*//' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use this for catching unused (Stylesheet) definitions in React Native code.
This means basically that I have a bunch of definitions in the source, and then I use <Component style = { this.styles.banana } />
If I don't remember to remove unused classes, the bottom part of source might have a lot of other unnecessary fruit as well.
Very rudimentary and early level tool. :)