├── LICENSE ├── Makefile ├── README.md ├── ctagsrc ├── index.js └── test.js /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Romain Lafourcade 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SHELL := /bin/bash 2 | OUT = @echo `date +[\ %F\ -\ %T\ ]` 3 | 4 | .PHONY: all watch 5 | 6 | all: tags 7 | @true 8 | 9 | tags: ctagsrc index.js 10 | @ctags --options=NONE --options=./ctagsrc -f tags index.js 11 | $(OUT) "'tags' file updated." 12 | 13 | watch: 14 | $(OUT) "Watching..." 15 | @while sleep 1; do make tags -s; done 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Exuberant Ctags Patterns for JavaScript 2 | 3 | The purpose of this project is to modernize and augment the many custom JavaScript Patterns for Exuberant Ctags that have been floating the web for years. 4 | 5 | We want to make sure Exuberant Ctags doesn't miss a single named symbol in our whole code base and do so without unnecessary duplication: 6 | 7 | * [Tags](#tags), 8 | * [Array literals](#array-literals), 9 | * [Object literals](#object-literals), 10 | * [Object properties](#object-properties), 11 | * [Generator functions](#generator-functions), 12 | * [Free-form functions](#free-form-functions), 13 | * [Constructors and classes](#constructors-and-classes), 14 | * [Methods](#methods), 15 | * [Variables](#variables), 16 | * [Named imports](#name-imports), 17 | * [Named exports](#named-exports), 18 | * [Styled components](#styled-components) 19 | 20 | This is done by disabling the default "kinds", creating new ones, and crafting as many patterns as necessary. 21 | 22 | ## Reminders 23 | 24 | ### Compatibility 25 | 26 | These patterns are only usable with Exuberant Ctags. Universal Ctags is *not* currently supported and there's no plan to support it in the foreseeable future. 27 | 28 | ### A note about disabling the default "kinds". 29 | 30 | The option `--javascript-kinds=-c-f-m-p-v` in [ctagsrc](ctagsrc) will disable the default kinds, `c` (classes), `f` (functions), `m` (methods), `p` (properties), and `v` (global variables), for JavaScript files. 31 | 32 | This means your ctags program's builtin regex patterns or any user defined patterns registered against these kinds will no longer function and the patterns defined in [ctagsrc](ctagsrc) will be the only patterns active for the JavaScript language. 33 | 34 | This is done to have a single source of patterns and avoid duplicated tags. 35 | 36 | ## Try 37 | 38 | 1. Clone this repository: 39 | 40 | $ git clone https://github.com/romainl/ctags-patterns-for-javascript.git 41 | 42 | 2. Build a `tags` file against the provided `index.js`: 43 | 44 | $ make tags 45 | 46 | or: 47 | 48 | $ ctags --options=NONE --options=./ctagsrc -f tags index.js 49 | 50 | ## Use 51 | 52 | 1. Clone this repository: 53 | 54 | $ git clone https://github.com/romainl/ctags-patterns-for-javascript.git 55 | 56 | 2. In your shell, run the following command to tell Exuberant Ctags to use the options defined in the provided `ctagsrc` file: 57 | 58 | $ echo "--options=/absolute/path/to/ctags-patterns-for-javascript/ctagsrc" >> ~/.ctags 59 | 60 | with `/absolute/path/to/ctags-patterns-for-javascript/ctagsrc` being your actual path, of course. 61 | 62 | 3. Use this command to generate a `tags` file at the root of your JavaScript project: 63 | 64 | $ ctags -R . 65 | 66 | If for some reason the above instructions sound like Klingon to you, just copy the content of [this file](https://raw.githubusercontent.com/romainl/ctags-patterns-for-javascript/master/ctagsrc) and paste it *into* your own `~/.ctags` file. If that file doesn't exist, create it. 67 | 68 | ## Tags 69 | 70 | CODE | TAG | KIND 71 | ----------------------------------------------------|---------------------|----- 72 | // FIXME: fix non-working Patterns | FIXME | T 73 | // TODO: better ES6+ support | TODO | T 74 | // BUG: there's really something fishy about this | BUG | T 75 | // ???: what the flying fuck? | ??? | T 76 | // !!!: dear god! | !!! | T 77 | // HACK: deployment is in 15 minutes | HACK | T 78 | // XXX: I. Must. Finish. That. Mess. Quickly. | XXX | T 79 | 80 | ## Array literals 81 | 82 | CODE | TAG | KIND 83 | ----------------------------------------------------|---------------------|----- 84 | var|let|const array_name = [... | array_name | A 85 | 86 | ## Object literals 87 | 88 | CODE | TAG | KIND 89 | ----------------------------------------------------|---------------------|----- 90 | var|let|const object_name = {... | object_name | O 91 | 92 | ## Object properties 93 | 94 | CODE | TAG | KIND 95 | ----------------------------------------------------|---------------------|----- 96 | foo: 123, | foo | P 97 | foo: 123 | foo | P 98 | bar: "eee", | bar | P 99 | bar: "eee" | bar | P 100 | baz: /regexp/, | baz | P 101 | baz: /regexp/ | baz | P 102 | quux: [] | quux | P 103 | flax: {} | flax | P 104 | var obj = { sluf: 1 }; | sluf | P 105 | this.foo = {} | foo | P 106 | 107 | ## Generator functions 108 | 109 | CODE | TAG | KIND 110 | ----------------------------------------------------|---------------------|----- 111 | function* generator_name() {... | generator_name | G 112 | function *generator_name() {... | generator_name | G 113 | function * generator_name() {... | generator_name | G 114 | function*generator_name() {... | generator_name | G 115 | const generator_name = function* () {... | generator_name | G 116 | const generator_name = function * () {... | generator_name | G 117 | * generator_name() {... | generator_name | G 118 | 119 | 120 | ## Free-form functions 121 | 122 | CODE | TAG | KIND 123 | ----------------------------------------------------|---------------------|----- 124 | function func_name() {... | func_name | F 125 | (function func_name() {... | func_name | F 126 | var|let|const func_name = function() {... | func_name | F 127 | var|let|const function_name = (arg) => ... | func_name | F 128 | var|let|const function_name = arg => ... | func_name | F 129 | var|let|const function_name = (\n...) => ... | func_name | F 130 | async function function_name() {... | func_name | F 131 | (async function function_name() {... | func_name | F 132 | var|let|const function_name = async function() {... | func_name | F 133 | var|let|const function_name = async () => {... | func_name | F 134 | var|let|const function_name = async arg => {... | func_name | F 135 | 136 | ## Constructors and classes 137 | 138 | CODE | TAG | KIND 139 | ----------------------------------------------------|---------------------|----- 140 | class ClassName {... | ClassName | C 141 | 142 | ## Methods 143 | 144 | CODE | TAG | KIND 145 | ----------------------------------------------------|---------------------|----- 146 | this.method_name = function() {... | method_name | M 147 | method_name : function() {... | method_name | M 148 | method_name: (param) => ... | method_name | M 149 | method_name: param => ... | method_name | M 150 | static method_name() {... | method_name | M 151 | method_name() {... | method_name | M 152 | method_name = (param) => ... | method_name | M 153 | method_name = param => ... | method_name | M 154 | 155 | ## Variables 156 | 157 | CODE | TAG | KIND 158 | ----------------------------------------------------|---------------------|----- 159 | var|let|const var_name = 1; | var_name | V 160 | var|let|const var_name = /regexp/; | var_name | V 161 | var|let|const var_name = 'foo'; | var_name | V 162 | var|let|const var_name = "bar"; | var_name | V 163 | var|let|const var_name = new ClassName(); | var_name | V 164 | var|let|const var_name; | var_name | V 165 | var|let|const ..., var_name; | var_name | V 166 | var|let|const ..., ..., var_name; | var_name | V 167 | var|let|const [ var1, var2, var3 ] = useState([]); | var1, var2, var3 | V 168 | var|let|const { var1, var2, var3 } = props; | var1, var2, var3 | V 169 | var_name, | var_name | V 170 | var_name | var_name | V 171 | 172 | ## Named imports 173 | 174 | Tagging direct imports would be redundant so we only tag named imports. 175 | 176 | CODE | TAG | KIND 177 | ----------------------------------------------------|---------------------|----- 178 | import { * as imp1 } | imp1 | I 179 | import { foo as imp2 } | imp2 | I 180 | import { imp3, * as imp4 } | imp4 | I 181 | import { imp5, bar as imp6 } | imp6 | I 182 | import { imp7, imp8, * as imp9 } | imp9 | I 183 | import { imp10, imp11, baz as imp12 } | imp12 | I 184 | import { * as imp13, * as imp14, * as imp15 } | imp13, imp14, imp15 | I 185 | import { foo as imp16, bar as imp17, baz as imp18 } | imp16, imp17, imp18 | I 186 | import * as imp19 | imp19 | I 187 | import foo as imp20 | imp20 | I 188 | import imp21, * as imp22 | imp22 | I 189 | import imp23, bar as imp24 | imp24 | I 190 | import imp25, imp26, * as imp27 | imp27 | I 191 | import imp28, imp29, baz as imp30 | imp30 | I 192 | import * as imp31, * as imp32, * as imp33 | imp31, imp32, imp33 | I 193 | import foo as imp34, bar as imp35, baz as imp36 | imp34, imp35, imp36 | I 194 | foo as imp37 | imp37 | I 195 | 196 | ## Flow imports 197 | 198 | Same story as imports, tagging direct imports would be redundant so we only tag named imports. 199 | 200 | CODE | TAG | KIND 201 | ----------------------------------------------------|---------------------|----- 202 | import type {foo as impFlow01} from ... | impFlow01 | I 203 | import type * as impFlow02 from ... | impFlow02 | I 204 | import typeof {foo as impFlow03} from ... | impFlow03 | I 205 | import typeof * as impFlow04 from ... | impFlow04 | I 206 | 207 | ## Named exports 208 | 209 | Same story as imports, tagging direct exports would be redundant so we only tag named exports. 210 | 211 | CODE | TAG | KIND 212 | ----------------------------------------------------|---------------------|----- 213 | export { var1 as exp04, var2 as exp05 }; | exp04, exp05 | E 214 | export let exp06, exp07; | exp06, exp07 | E 215 | export var exp08, exp09, exp09b; | exp08, exp09 | E 216 | export let exp10 = 1, exp11 = 2; | exp10, exp11 | E 217 | export const exp12 = 1, exp13 = 2; | exp12, exp13 | E 218 | export var exp14 = 1, exp15 = 2; | exp14, exp15 | E 219 | export function exp16() {} | exp16 | E 220 | export default { var1 as exp20, var2 as exp21}; | exp20; exp21 | E 221 | export default let exp22, exp23; | exp22, exp23 | E 222 | export default var exp24, exp25; | exp24, exp25 | E 223 | export default let exp26 = 1, exp27 = 2; | exp26, exp27 | E 224 | export default const exp28 = 1, exp29 = 2; | exp28, exp29 | E 225 | export default var exp30 = 1, exp31 = 2; | exp30, exp31 | E 226 | export default function exp32() {} | exp32 | E 227 | 228 | ## Styled components 229 | 230 | "Visual primitives for the component age.", as they say [on the site](https://www.styled-components.com/), are not exactly native types but they are certainly named and very likely to be reused so they deserve a spot, here. 231 | 232 | CODE | TAG | KIND 233 | ----------------------------------------------------|---------------------|----- 234 | var|let|const Component = styled... | Component | S 235 | var|let|const Component = createGlobalStyle... | Component | S 236 | 237 | ## Hack 238 | 239 | ### Regular expressions dialect 240 | 241 | Because Exuberant Ctags takes no responsibility about the regular expression engine it uses under the hood, we must use the dumbest dialect, BRE, for portability. This has a number of consequences: 242 | 243 | * no alternation, 244 | * no lookbehind, 245 | * no backreference, 246 | * a verbose and frustrating syntax. 247 | 248 | But we are hackers, so we see challenges where others see obstacles, right? 249 | 250 | ### Watch and re-index 251 | 252 | The bundled `Makefile` has a very simple and very cheap `watch` phony target that will run `make tags` every second. In turn, the `tags` target will run `ctags --options=./ctagsrc -f tags index.js` *only* if `ctagsrc` or `index.js` have changed since last run. 253 | 254 | This allows us to start the watcher in a terminal: 255 | 256 | $ make watch 257 | 258 | open `ctagsrc`, `index.js`, and the `tags` file in Vim in another terminal: 259 | 260 | $ vim -O tags ctagsrc index.js +'set autoread' +'autocmd! CursorHold,CursorHoldI * checktime' 261 | 262 | and watch our `tags` file change as we edit existing patterns in `ctagsrc` or add expressions in `index.js`. 263 | 264 | 265 | [//]: # ( Vim: set spell spelllang=en: ) 266 | -------------------------------------------------------------------------------- /ctagsrc: -------------------------------------------------------------------------------- 1 | --langmap=javascript:.js.es6.es.jsx.mjs 2 | --javascript-kinds=-c-f-m-p-v 3 | 4 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*\[/\1/A,Array,Arrays/b 5 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*\[/\1/A,Array,Arrays/b 6 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*\[/\1/A,Array,Arrays/b 7 | 8 | --regex-javascript=/^[ \t]*class[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)/\1/C,Class,Classes/b 9 | 10 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}\({[ \t]*\)*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)\([A-Za-z0-9_]\{1,\}\)/\3/E,Export,Exports/b 11 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}\({[ \t]*\)*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)*\([A-Za-z0-9_]\{1,\}\),[ \t]*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)\([A-Za-z0-9_]\{1,\}\)/\5/E,Export,Exports/b 12 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}\({[ \t]*\)*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)*\([A-Za-z0-9_]\{1,\}\),[ \t]*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)*\([A-Za-z0-9_]\{1,\}\),[ \t]*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)\([A-Za-z0-9_]\{1,\}\)/\7/E,Export,Exports/b 13 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)/\1/E,Export,Exports/b 14 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)/\1/E,Export,Exports/b 15 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}const[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)/\1/E,Export,Exports/b 16 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}function[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)/\1/E,Export,Exports/b 17 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*[^,]\{1,\},[ \t]*\([A-Za-z0-9_$]\{1,\}\)/\2/E,Export,Exports/b 18 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*[^,]\{1,\},[ \t]*\([A-Za-z0-9_$]\{1,\}\)/\2/E,Export,Exports/b 19 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}const[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*[^,]\{1,\},[ \t]*\([A-Za-z0-9_$]\{1,\}\)/\2/E,Export,Exports/b 20 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*[^,]\{1,\},[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)/\3/E,Export,Exports/b 21 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*[^,]\{1,\},[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)/\3/E,Export,Exports/b 22 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}const[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*[^,]\{1,\},[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)/\3/E,Export,Exports/b 23 | 24 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}default[ \t]\{1,\}\({[ \t]*\)*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)\([A-Za-z0-9_]\{1,\}\)/\3/E,Export,Exports/b 25 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}default[ \t]\{1,\}\({[ \t]*\)*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)*\([A-Za-z0-9_]\{1,\}\),[ \t]*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)\([A-Za-z0-9_]\{1,\}\)/\5/E,Export,Exports/b 26 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}default[ \t]\{1,\}\({[ \t]*\)*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)*\([A-Za-z0-9_]\{1,\}\),[ \t]*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)*\([A-Za-z0-9_]\{1,\}\),[ \t]*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)\([A-Za-z0-9_]\{1,\}\)/\7/E,Export,Exports/b 27 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}default[ \t]\{1,\}var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)/\1/E,Export,Exports/b 28 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}default[ \t]\{1,\}let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)/\1/E,Export,Exports/b 29 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}default[ \t]\{1,\}const[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)/\1/E,Export,Exports/b 30 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}default[ \t]\{1,\}function[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)/\1/E,Export,Exports/b 31 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}default[ \t]\{1,\}var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*[^,]\{1,\},[ \t]*\([A-Za-z0-9_$]\{1,\}\)/\2/E,Export,Exports/b 32 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}default[ \t]\{1,\}let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*[^,]\{1,\},[ \t]*\([A-Za-z0-9_$]\{1,\}\)/\2/E,Export,Exports/b 33 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}default[ \t]\{1,\}const[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*[^,]\{1,\},[ \t]*\([A-Za-z0-9_$]\{1,\}\)/\2/E,Export,Exports/b 34 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}default[ \t]\{1,\}var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*[^,]\{1,\},[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)/\3/E,Export,Exports/b 35 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}default[ \t]\{1,\}let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*[^,]\{1,\},[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)/\3/E,Export,Exports/b 36 | --regex-javascript=/^[ \t]*export[ \t]\{1,\}default[ \t]\{1,\}const[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*[^,]\{1,\},[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)/\3/E,Export,Exports/b 37 | 38 | --regex-javascript=/^[ \t]*function[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t(]/\1/F,Function,Functions/b 39 | --regex-javascript=/^[ \t]*[(]function[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t(]/\1/F,Function,Functions/b 40 | --regex-javascript=/^[ \t]*async[ \t]function[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t(]/\1/F,Function,Functions/b 41 | --regex-javascript=/^[ \t]*[(]async[ \t]function[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t(]/\1/F,Function,Functions/b 42 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*\(async[ \t]\{1,\}\)*function[^\*][^\*]/\1/F,Function,Functions/b 43 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*\(async[ \t]\{1,\}\)*function[^\*][^\*]/\1/F,Function,Functions/b 44 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*\(async[ \t]\{1,\}\)*function[^\*][^\*]/\1/F,Function,Functions/b 45 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*([^)]*$/\1/F,Function,Functions/b 46 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*([^)]*$/\1/F,Function,Functions/b 47 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*([^)]*$/\1/F,Function,Functions/b 48 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=.\{1,\}=>/\1/F,Function,Functions/b 49 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=.\{1,\}=>/\1/F,Function,Functions/b 50 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=.\{1,\}=>/\1/F,Function,Functions/b 51 | 52 | --regex-javascript=/^[ \t]*function[ \t]*\*[ \t]*\([A-Za-z0-9_$]\{1,\}\)/\1/G,Generator,Generators/b 53 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*function\([ \t]*\*\)/\1/G,Generator,Generators/b 54 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*function\([ \t]*\*\)/\1/G,Generator,Generators/b 55 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*function\([ \t]*\*\)/\1/G,Generator,Generators/b 56 | --regex-javascript=/^[ \t]*\(\*[ \t]\)\([A-Za-z0-9_$]\{1,\}\)[ \t]*(.*)[ \t]*[{]/\2/G,Generator,Generators/b 57 | 58 | --regex-javascript=/^[ \t]*import[ \t]\{1,\}\([{][ \t]*\)*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)\([A-Za-z0-9_]\{1,\}\)/\3/I,Import,Imports/b 59 | --regex-javascript=/^[ \t]*import[ \t]\{1,\}\([{][ \t]*\)*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)*\([A-Za-z0-9_]\{1,\}\),[ \t]*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)\([A-Za-z0-9_]\{1,\}\)/\5/I,Import,Imports/b 60 | --regex-javascript=/^[ \t]*import[ \t]\{1,\}\([{][ \t]*\)*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)*\([A-Za-z0-9_]\{1,\}\),[ \t]*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)*\([A-Za-z0-9_]\{1,\}\),[ \t]*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)\([A-Za-z0-9_]\{1,\}\)/\7/I,Import,Imports/b 61 | --regex-javascript=/^[ \t]*import[ \t]\{1,\}type[ \t]\{1,\}\([{][ \t]*\)*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)\([A-Za-z0-9_]\{1,\}\)/\3/I,Import,Imports/b 62 | --regex-javascript=/^[ \t]*import[ \t]\{1,\}typeof[ \t]\{1,\}\([{][ \t]*\)*\([A-Za-z0-9_\*]*[ \t]as[ \t]\)\([A-Za-z0-9_]\{1,\}\)/\3/I,Import,Imports/b 63 | --regex-javascript=/^[ \t]*[A-Za-z0-9_]\{1,\}[ \t]as[ \t]\([A-Za-z0-9_]\{1,\}\)/\1/I,Import,Imports/b 64 | 65 | --regex-javascript=/^[ \t]*\([A-Za-z0-9_$]\{1,\}\)\.\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*function/\2/M,Method,Methods/b 66 | --regex-javascript=/^[ \t]*\([A-Za-z0-9_$]\{1,\}\)\.\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*(/\2/M,Method,Methods/b 67 | --regex-javascript=/^[ \t]*\([A-Za-z0-9_$]\{1,\}\)\.\([A-Za-z0-9_$]\{1,\}\)\.\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*function/\3/M,Method,Methods/b 68 | --regex-javascript=/^[ \t]*\([A-Za-z0-9_$]\{1,\}\)\.\([A-Za-z0-9_$]\{1,\}\)\.\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*(/\3/M,Method,Methods/b 69 | --regex-javascript=/^[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*[:=][ \t]*[(]*function[ \t]*(/\1/M,Method,Methods/b 70 | --regex-javascript=/^[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*[:=][ \t](\{1,\}/\1/M,Method,Methods/b 71 | --regex-javascript=/^[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*[:=][ \t]\{1,\}async[ \t](\{1,\}/\1/M,Method,Methods/b 72 | --regex-javascript=/^[ \t]*static[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*(/\1/M,Method,Methods/b 73 | --regex-javascript=/^[ \t]*async[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*(/\1/M,Method,Methods/b 74 | --regex-javascript=/^[ \t]*\([A-Za-z0-9_$]\{1,\}\)(.*)[ \t]*[{]/\1/M,Method,Methods/b 75 | --regex-javascript=/^[ \t]*get[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*(/\1/M,Method,Methods/b 76 | --regex-javascript=/^[ \t]*set[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*(/\1/M,Method,Methods/b 77 | 78 | --regex-javascript=/^[ \t]*\([A-Za-z0-9_$]\{1,\}\)\.\([A-Za-z0-9_$]\{1,\}\)[ \t]*[=][ \t]*{/\2/P,Property,Properties/b 79 | --regex-javascript=/^[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*:[ \t]*[{"\/\[]/\1/P,Property,Properties/b 80 | --regex-javascript=/^[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*:[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t,]*$/\1/P,Property,Properties/b 81 | 82 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*[{]/\1/O,Object,Objects/b 83 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*[{]/\1/O,Object,Objects/b 84 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*[{]/\1/O,Object,Objects/b 85 | 86 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*styled/\1/S,StyledComponent,StyledComponents/b 87 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*styled/\1/S,StyledComponent,StyledComponents/b 88 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*styled/\1/S,StyledComponent,StyledComponents/b 89 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*createGlobalStyle/\1/S,StyledComponent,StyledComponents/b 90 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*createGlobalStyle/\1/S,StyledComponent,StyledComponents/b 91 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*createGlobalStyle/\1/S,StyledComponent,StyledComponents/b 92 | 93 | --regex-javascript=/\/\/[ \t]*\(FIXME\)[ \t]*:*\(.*\)/\1/T,Tag,Tags/b 94 | --regex-javascript=/\/\/[ \t]*\(TODO\)[ \t]*:*\(.*\)/\1/T,Tag,Tags/b 95 | --regex-javascript=/\/\/[ \t]*\(BUG\)[ \t]*:*\(.*\)/\1/T,Tag,Tags/b 96 | --regex-javascript=/\/\/[ \t]*\(NOBUG\)[ \t]*:*\(.*\)/\1/T,Tag,Tags/b 97 | --regex-javascript=/\/\/[ \t]*\(???\)[ \t]*:*\(.*\)/\1/T,Tag,Tags/b 98 | --regex-javascript=/\/\/[ \t]*\(!!!\)[ \t]*:*\(.*\)/\1/T,Tag,Tags/b 99 | --regex-javascript=/\/\/[ \t]*\(HACK\)[ \t]*:*\(.*\)/\1/T,Tag,Tags/b 100 | --regex-javascript=/\/\/[ \t]*\(XXX\)[ \t]*:*\(.*\)/\1/T,Tag,Tags/b 101 | 102 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*[0-9\"'\/]/\1/V,Variable,Variables/b 103 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*[0-9\"'\/]/\1/V,Variable,Variables/b 104 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*[0-9\"'\/]/\1/V,Variable,Variables/b 105 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*new/\1/V,Variable,Variables/b 106 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*new/\1/V,Variable,Variables/b 107 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*=[ \t]*new/\1/V,Variable,Variables/b 108 | 109 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*[,;]/\1/V,Variable,Variables/b 110 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*[,;]/\1/V,Variable,Variables/b 111 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)/\2/V,Variable,Variables/b 112 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)/\2/V,Variable,Variables/b 113 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)/\3/V,Variable,Variables/b 114 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)/\3/V,Variable,Variables/b 115 | 116 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}{[ \t]*\([A-Za-z0-9_$]\{1,\}\)[^}]*}[ \t]*=/\1/V,Variable,Variables/b 117 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}{[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[^}]*}[ \t]*=/\2/V,Variable,Variables/b 118 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}{[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[^}]*}[ \t]*=/\3/V,Variable,Variables/b 119 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}{[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[^}]*}[ \t]*=/\4/V,Variable,Variables/b 120 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}\[[ \t]*\([A-Za-z0-9_$]\{1,\}\).*\][ \t]*=/\1/V,Variable,Variables/b 121 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}\[[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\).*\][ \t]*=/\2/V,Variable,Variables/b 122 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}\[[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\).*\][ \t]*=/\3/V,Variable,Variables/b 123 | --regex-javascript=/^[ \t]*const[ \t]\{1,\}\[[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\).*\][ \t]*=/\4/V,Variable,Variables/b 124 | 125 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}{[ \t]*\([A-Za-z0-9_$]\{1,\}\)[^}]*}[ \t]*=/\1/V,Variable,Variables/b 126 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}{[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[^}]*}[ \t]*=/\2/V,Variable,Variables/b 127 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}{[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[^}]*}[ \t]*=/\3/V,Variable,Variables/b 128 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}{[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[^}]*}[ \t]*=/\4/V,Variable,Variables/b 129 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}\[[ \t]*\([A-Za-z0-9_$]\{1,\}\).*\][ \t]*=/\1/V,Variable,Variables/b 130 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}\[[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\).*\][ \t]*=/\2/V,Variable,Variables/b 131 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}\[[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\).*\][ \t]*=/\3/V,Variable,Variables/b 132 | --regex-javascript=/^[ \t]*var[ \t]\{1,\}\[[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\).*\][ \t]*=/\4/V,Variable,Variables/b 133 | 134 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}{[ \t]*\([A-Za-z0-9_$]\{1,\}\)[^}]*}[ \t]*=/\1/V,Variable,Variables/b 135 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}{[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[^}]*}[ \t]*=/\2/V,Variable,Variables/b 136 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}{[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[^}]*}[ \t]*=/\3/V,Variable,Variables/b 137 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}{[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[^}]*}[ \t]*=/\4/V,Variable,Variables/b 138 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}\[[ \t]*\([A-Za-z0-9_$]\{1,\}\).*\][ \t]*=/\1/V,Variable,Variables/b 139 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}\[[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\).*\][ \t]*=/\2/V,Variable,Variables/b 140 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}\[[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\).*\][ \t]*=/\3/V,Variable,Variables/b 141 | --regex-javascript=/^[ \t]*let[ \t]\{1,\}\[[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\)[ \t]*,[ \t]*\([A-Za-z0-9_$]\{1,\}\).*\][ \t]*=/\4/V,Variable,Variables/b 142 | 143 | --regex-javascript=/^[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\),$/\1/V,Variable,Variables/b 144 | --regex-javascript=/^[ \t]\{1,\}\([A-Za-z0-9_$]\{1,\}\)$/\1/V,Variable,Variables/b 145 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // tags 2 | // ---- 3 | // TODO: better ES6+ support 4 | // FIXME: fix non-working patterns 5 | // BUG: there's really something fishy about this 6 | // NOBUG: no that's OK 7 | // ???: what the flying fuck? 8 | // !!!: dear god! 9 | // HACK: deployment is in 15 minutes 10 | // XXX: I. Must. Finish. That. Mess. Quickly. 11 | 12 | 13 | // arrays 14 | // ------ 15 | let arr_lit = [ 16 | 1, 3, 4 17 | ]; 18 | let arr_lit_inline = [1,4]; 19 | 20 | 21 | // objects 22 | // ------- 23 | var obj_lit = { 24 | obj_lit_prop_number: 123, 25 | obj_lit_prop_string : "eee", 26 | obj_lit_prop_array: [ 27 | "foo" 28 | ], 29 | obj_lit_prop_object : { 30 | inner_prop: bar 31 | }, 32 | obj_lit_prop_regexp : /regexp/, 33 | obj_lit_prop_method : function( 34 | obj_lit_prop_method_arg1_own_line, 35 | obj_lit_prop_method_arg2_own_line 36 | ){ 37 | return this; 38 | }, 39 | obj_lit_prop_method_arrow : ( 40 | obj_lit_prop_method_arrow_arg1_own_line, 41 | obj_lit_prop_method_arrow_arg2_own_line 42 | ) => { 43 | console.log(1); 44 | } 45 | }; 46 | var obj_lit_inline = { obj_lit_inline_prop: 1 }; 47 | this.this_prop = { 48 | this_inner_prop: "bar" 49 | }; 50 | this.this_prop_method = function( 51 | this_prop_method_arg1_own_line, 52 | this_prop_method_arg2_own_line 53 | ){ 54 | return this; 55 | } 56 | this.this_prop_method_arrow = ( 57 | this_prop_method_arrow_arg1_own_line, 58 | this_prop_method_arrow_arg2_own_line 59 | ) => { 60 | console.log(1); 61 | }; 62 | 63 | 64 | // constructors & methods 65 | // ---------------------- 66 | var Constr_var = function() { 67 | this.constr_var_meth = function() { 68 | return true; 69 | }; 70 | }; 71 | const Constr_const = function() { 72 | this.constr_const_meth = function() { 73 | return true; 74 | }; 75 | }; 76 | let Constr_let = function() { 77 | this.constr_let_meth = function() { 78 | return true; 79 | }; 80 | }; 81 | 82 | 83 | // functions 84 | // --------- 85 | function function_basic() { 86 | return 1; 87 | } 88 | (function function_iife() { 89 | return 2; 90 | })(); 91 | var function_var = function() { 92 | return 3; 93 | }; 94 | let function_let = function() { 95 | return 4; 96 | }; 97 | const function_const = function() { 98 | return 5; 99 | }; 100 | const function_arrow = (arg) => arg; 101 | const function_arrow_no_parentheses = arg => arg; 102 | var function_arrow_multiline = ( 103 | function_arrow_multiline_foo_own_line, 104 | function_arrow_multiline_bar_own_line 105 | ) => { 106 | return 1; 107 | }; 108 | const _function_arrow_underscore = (foo) => { 109 | return 1; 110 | } 111 | 112 | 113 | // async 114 | // ----- 115 | async function function_async_basic() { 116 | return 1; 117 | } 118 | (async function function_async_iife() { 119 | return 2; 120 | })(); 121 | let function_async_let = async function() { 122 | return 1; 123 | } 124 | const function_async_var = async function() { 125 | return 1; 126 | } 127 | var function_async_const = async function() { 128 | return 1; 129 | } 130 | let function_async_let_arrow = async () => { 131 | return 1; 132 | } 133 | const function_async_var_arrow = async () => { 134 | return 1; 135 | } 136 | var function_async_const_arrow = async () => { 137 | return 1; 138 | } 139 | let function_async_let_arrow_no_parens = async arg => { 140 | return 1; 141 | } 142 | const function_async_var_arrow_no_parens = async arg => { 143 | return 1; 144 | } 145 | var function_async_const_arrow_no_parens = async arg => { 146 | return 1; 147 | } 148 | 149 | 150 | // generators 151 | // ---------- 152 | function* generator_func1() { 153 | var generator_func1_iterator = 0; 154 | while(true) 155 | yield iterator1++; 156 | } 157 | function *generator_func2() { 158 | var generator_func2_iterator = 0; 159 | while(true) 160 | yield iterator2++; 161 | } 162 | function * generator_func3() { 163 | var generator_func3_iterator = 0; 164 | while(true) 165 | yield iterator3++; 166 | } 167 | function*generator_func4() { 168 | var generator_func4_iterator = 0; 169 | while(true) 170 | yield iterator4++; 171 | } 172 | const generator_func5 = function* () { 173 | var generator_func5_iterator = 0; 174 | while(true) 175 | yield iterator5++; 176 | }; 177 | const generator_func6 = function * () { 178 | var generator_func6_iterator = 0; 179 | while(true) 180 | yield iterator6++; 181 | }; 182 | 183 | 184 | // classes 185 | // ------- 186 | class ClassName { 187 | constructor(prop) { 188 | this.class_constr_prop = prop; 189 | this.class_constr_meth = function(){ 190 | return 666; 191 | }; 192 | } 193 | class_meth_equal = function( 194 | class_meth_equal_arg1_own_line, 195 | class_meth_equal_arg2_own_line 196 | ) { 197 | return this; 198 | }; 199 | class_meth_equal_arrow = ( 200 | class_meth_equal_arrow_arg1_own_line, 201 | class_meth_equal_arrow_arg2_own_line 202 | ) => { 203 | console.log(1); 204 | }; 205 | class_meth_equal_arrow_async = async () => { 206 | return 1; 207 | } 208 | static class_meth_static() { 209 | return 1; 210 | } 211 | async class_meth_async() { 212 | return 2; 213 | } 214 | class_meth_proto() { 215 | return 2; 216 | } 217 | class_meth_arrow = (foo) => { 218 | console.log(1); 219 | } 220 | if (foo) { 221 | console.log(1); 222 | } 223 | for (var i = 0, len = things.length; i < len; i++) { 224 | console.log(1); 225 | } 226 | * class_meth_generator() { 227 | var index = 0; 228 | while (true) 229 | yield index++; 230 | } 231 | get class_getter() { 232 | return this.class_constr_prop; 233 | } 234 | get class_setter(opt) { 235 | this.class_constr_prop = opt; 236 | } 237 | } 238 | 239 | 240 | // variables 241 | // --------- 242 | const var_const_number = 1; 243 | var var_var_regexp = /regexp/; 244 | let let_single_quotes = 'foo'; 245 | let let_double_quotes = "bar"; 246 | var var_class_instance = new ClassName(); 247 | let let_class_instance = new ClassName(); 248 | const const_class_instance = new ClassName(); 249 | var var_declaration; 250 | let let_declaration; 251 | var var_declaration_inlined_1_of_2, var_declaration_inlined_2_of_2; 252 | let let_declaration_inlined_1_of_2, let_declaration_inlined_2_of_2; 253 | var var_declaration_inlined_1_of_3, var_declaration_inlined_2_of_3, var_declaration_inlined_3_of_3; 254 | let let_declaration_inlined_1_of_3, let_declaration_inlined_2_of_3, let_declaration_inlined_3_of_3; 255 | var var_declaration_trailing_space ; 256 | let let_declaration_trailing_space ; 257 | var var_declaration_inlined_1_of_2_trailing_space , var_declaration_inlined_2_of_2_trailing_space ; 258 | let let_declaration_inlined_1_of_2_trailing_space , let_declaration_inlined_2_of_2_trailing_space ; 259 | var var_declaration_inlined_1_of_3_trailing_space , var_declaration_inlined_2_of_3_trailing_space , var_declaration_inlined_3_of_3_trailing_space ; 260 | let let_declaration_inlined_1_of_3_trailing_space , let_declaration_inlined_2_of_3_trailing_space , let_declaration_inlined_3_of_3_trailing_space ; 261 | const [const_destructuration_1] = foo; 262 | const [const_destructuration_2, const_destructuration_3] = foo; 263 | const [const_destructuration_4, const_destructuration_5, const_destructuration_6] = foo; 264 | const [const_destructuration_7, const_destructuration_8, const_destructuration_9, const_destructuration_10] = foo; 265 | const {const_destructuration_braces_1} = foo; 266 | const {const_destructuration_braces_2, const_destructuration_braces_3} = foo; 267 | const {const_destructuration_braces_4, const_destructuration_braces_5, const_destructuration_braces_6} = foo; 268 | const {const_destructuration_braces_7, const_destructuration_braces_8, const_destructuration_braces_9, const_destructuration_braces_10} = foo; 269 | const { 270 | const_destructuration_own_line_1, 271 | const_destructuration_own_line_2 272 | } 273 | 274 | 275 | // imports 276 | // ------- 277 | import { imp01 } 278 | import { * as imp02 } // imp02 279 | import { foo as imp03 } // imp03 280 | import { imp04, * as imp05 } // imp05 281 | import { imp06, bar as imp07 } // imp07 282 | import { imp08, imp09, * as imp10 } // imp10 283 | import { imp11, imp12, baz as imp13 } // imp13 284 | import { * as imp14, * as imp15, * as imp16 } // imp14, imp15, imp16 285 | import { foo as imp17, bar as imp18, baz as imp19 } // imp17, imp18, imp19 286 | import { imp20, imp21, imp22 } 287 | import imp23 288 | import * as imp24 // imp24 289 | import foo as imp25 // imp25 290 | import imp26, * as imp27 // imp27 291 | import imp28, bar as imp29 // imp29 292 | import imp30, imp31, * as imp32 // imp32 293 | import imp33, imp34, baz as imp35 // imp35 294 | import * as imp36, * as imp37, * as imp38 // imp36, imp37, imp38 295 | import foo as imp39, bar as imp40, baz as imp41 // imp39, imp40, imp41 296 | import { 297 | foo as imp42, // imp42 298 | bar as imp43 // imp43 299 | } 300 | 301 | // imports (flow) 302 | // -------------- 303 | import type impFlow01 from "./ExportDefault_Class"; 304 | import type {impFlow02} from "./ExportNamed_Class"; 305 | import type {impFlow03, impFlow04} from "./ExportCJSNamed_Class"; 306 | import type {impFlow05 as impFlow06} from "./ExportNamed_Class"; // impFlow06 307 | import type * as impFlow07 from "./ExportNamed_Multi"; // impFlow07 308 | import typeof impFlow08 from "./ExportDefault_Class"; 309 | import typeof {impFlow09 as impFlow10} from "./ExportNamed_Class"; // impFlow10 310 | import typeof * as impFlow11 from "./ExportNamed_Multi"; // impFlow11 311 | 312 | // exports 313 | // ------- 314 | export { exp01, exp02, exp03 }; 315 | export { variable1 as exp04, variable2 as exp05}; // exp04; exp05 316 | export let exp06, exp07; // exp06, exp07 317 | export var exp08, exp09; // exp08, exp09 318 | export let exp10 = 1, exp11 = 2; // exp10, exp11 319 | export const exp12 = 1, exp13 = 2; // exp12, exp13 320 | export var exp14 = 1, exp15 = 2; // exp14, exp15 321 | export function exp16() {} // exp16 322 | 323 | // default exports 324 | export default { exp17, exp18, exp19 }; 325 | export default { variable1 as exp20, variable2 as exp21}; // exp20; exp21 326 | export default let exp22, exp23; // exp22, exp23 327 | export default var exp24, exp25; // exp24, exp25 328 | export default let exp26 = 1, exp27 = 2; // exp26, exp27 329 | export default const exp28 = 1, exp29 = 2; // exp28, exp29 330 | export default var exp30 = 1, exp31 = 2; // exp30, exp31 331 | export default function exp32() {} // exp32 332 | 333 | /* 334 | 335 | Problems with imports and exports 336 | 337 | const foo -> export foo -> import foo 338 | tag const foo 339 | 340 | const foo -> export foo -> import foo as bar 341 | tag const foo AND import foo as bar 342 | 343 | const foo -> export foo as bar -> import bar 344 | tag const foo AND export foo as bar 345 | 346 | const foo -> export foo as bar -> import bar at baz 347 | tag const foo AND export foo as bar AND import bar as baz 348 | 349 | */ 350 | 351 | // styled components 352 | // ----------------- 353 | var Comp01 = styled(Box)` 354 | border-radius: 0px 5pt 5pt 5pt; 355 | `; 356 | let Comp02 = styled(Box)` 357 | border-radius: 0px 5pt 5pt 5pt; 358 | `; 359 | const Comp03 = styled(Box)` 360 | border-radius: 0px 5pt 5pt 5pt; 361 | `; 362 | var Comp04 = createGlobalStyle` 363 | body { 364 | color: ${props => (props.whiteColor ? 'white' : 'black')}; 365 | } 366 | `; 367 | let Comp05 = createGlobalStyle` 368 | body { 369 | color: ${props => (props.whiteColor ? 'white' : 'black')}; 370 | } 371 | `; 372 | const Comp06 = createGlobalStyle` 373 | body { 374 | color: ${props => (props.whiteColor ? 'white' : 'black')}; 375 | } 376 | `; 377 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | class Api { 2 | constructor(auth) { 3 | this._credentials = auth 4 | } 5 | 6 | // NOT WORKING 7 | getConfig = async (method, body) => { 8 | const config = { method, body: JSON.stringify(body) } 9 | config["headers"] = { 10 | ...headers, 11 | ...this._credentials, 12 | } 13 | return config 14 | } 15 | 16 | // WORKING 17 | getLocations = async ({ flags = [""] }) => { 18 | // some code 19 | } 20 | 21 | // NOT WORKING 22 | set params(obj) { 23 | const { latitude, longitude, page = 1, per_page = 3 } = obj 24 | this._coordinates = { latitude, longitude } 25 | this._page = page 26 | this._per_page = per_page 27 | } 28 | 29 | // NOT WORKING 30 | get latitude() { 31 | const { latitude } = this._coordinates 32 | return `latitude=${latitude}` 33 | } 34 | } 35 | --------------------------------------------------------------------------------