Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit ec8a389

Browse files
committed
Only allow optional params to trail
1 parent 23a654c commit ec8a389

File tree

1 file changed

+74
-60
lines changed

1 file changed

+74
-60
lines changed

Diff for: grammars/javascript.cson

+74-60
Original file line numberDiff line numberDiff line change
@@ -1936,46 +1936,53 @@
19361936
\\s*
19371937
(?:
19381938
(?:
1939-
\\(
1940-
\\s*
1939+
\\(\\s*
19411940
\\.{3}[a-zA-Z_$][\\w$]+ # {function(...string)} variable number of parameters
1942-
\\s*
1943-
\\)
1941+
\\s*\\)
19441942
)
19451943
|
19461944
(?:
1947-
\\(
1948-
\\s*
1945+
\\(\\s*
19491946
(?:
1947+
(?:\\?|!)? # {function(?string)} or function(!string)} nullable/non-nullable type
1948+
[a-zA-Z_$][\\w$]+
1949+
(?:\\[\\])? # {function(string[])} type application, an array of strings
19501950
(?:
19511951
(?:
1952-
\\? | # {function(?string)} nullable type
1953-
! # {function(!string)} non-nullable type
1954-
)?
1955-
[a-zA-Z_$][\\w$]+
1956-
(?:\\[\\])? # {function(string[])} type application, an array of strings
1952+
(?:
1953+
\\s*,\\s*
1954+
(?:\\?|!)? # {function(?string)} or function(!string)} nullable/non-nullable type
1955+
[a-zA-Z_$][\\w$]+
1956+
(?:\\[\\])? # {function(string[])} type application, an array of strings
1957+
)*
1958+
(?:
1959+
\\s*,\\s*
1960+
\\.{3}[a-zA-Z_$][\\w$]+ # {function(string, ...string)} variable number of parameters
1961+
)?
1962+
)
1963+
|
19571964
(?:
1958-
\\s*,\\s*
1965+
=? # {function(string=)} optional parameter
19591966
(?:
1960-
(?:
1961-
(?:
1962-
\\? | # {function(string, ?string)} nullable type
1963-
! # {function(string, !string)} non-nullable type
1964-
)?
1965-
[a-zA-Z_$][\\w$]+
1966-
(?:\\[\\])? # {function(string[])} type application, an array of strings
1967-
)
1968-
)
1969-
)*
1970-
=? # {function(string=)} optional parameter
1971-
)+
1972-
(?:
1973-
\\s*,\\s*
1974-
\\.{3}[a-zA-Z_$][\\w$]+ # {function(string, ...string)} variable number of parameters
1975-
)?
1967+
(?<!=) # {function(string, string, number)} loop non-optional params
1968+
\\s*,\\s*
1969+
(?:\\?|!)? # {function(?string)} or function(!string)} nullable/non-nullable type
1970+
[a-zA-Z_$][\\w$]+
1971+
(?:\\[\\])? # {function(string[])} type application, an array of strings
1972+
=?
1973+
)*
1974+
(?:
1975+
(?<==) # {function(string, string=, number=)} loop optional params
1976+
\\s*,\\s*
1977+
(?:\\?|!)? # {function(?string)} or function(!string)} nullable/non-nullable type
1978+
[a-zA-Z_$][\\w$]+
1979+
(?:\\[\\])? # {function(string[])} type application, an array of strings
1980+
=
1981+
)*
1982+
)
1983+
)
19761984
)?
1977-
\\s*
1978-
\\)
1985+
\\s*\\)
19791986
)
19801987
)
19811988
(?: # {function(): string} function return type
@@ -2091,46 +2098,53 @@
20912098
\\s*
20922099
(?:
20932100
(?:
2094-
\\(
2095-
\\s*
2101+
\\(\\s*
20962102
\\.{3}[a-zA-Z_$][\\w$]+ # {function(...string)} variable number of parameters
2097-
\\s*
2098-
\\)
2103+
\\s*\\)
20992104
)
21002105
|
21012106
(?:
2102-
\\(
2103-
\\s*
2107+
\\(\\s*
21042108
(?:
2109+
(?:\\?|!)? # {function(?string)} or function(!string)} nullable/non-nullable type
2110+
[a-zA-Z_$][\\w$]+
2111+
(?:\\[\\])? # {function(string[])} type application, an array of strings
21052112
(?:
21062113
(?:
2107-
\\? | # {function(?string)} nullable type
2108-
! # {function(!string)} non-nullable type
2109-
)?
2110-
[a-zA-Z_$][\\w$]+
2111-
(?:\\[\\])? # {function(string[])} type application, an array of strings
2114+
(?:
2115+
\\s*,\\s*
2116+
(?:\\?|!)? # {function(?string)} or function(!string)} nullable/non-nullable type
2117+
[a-zA-Z_$][\\w$]+
2118+
(?:\\[\\])? # {function(string[])} type application, an array of strings
2119+
)*
2120+
(?:
2121+
\\s*,\\s*
2122+
\\.{3}[a-zA-Z_$][\\w$]+ # {function(string, ...string)} variable number of parameters
2123+
)?
2124+
)
2125+
|
21122126
(?:
2113-
\\s*,\\s*
2127+
=? # {function(string=)} optional parameter
21142128
(?:
2115-
(?:
2116-
(?:
2117-
\\? | # {function(string, ?string)} nullable type
2118-
! # {function(string, !string)} non-nullable type
2119-
)?
2120-
[a-zA-Z_$][\\w$]+
2121-
(?:\\[\\])? # {function(string[])} type application, an array of strings
2122-
)
2123-
)
2124-
)*
2125-
=? # {function(string=)} optional parameter
2126-
)+
2127-
(?:
2128-
\\s*,\\s*
2129-
\\.{3}[a-zA-Z_$][\\w$]+ # {function(string, ...string)} variable number of parameters
2130-
)?
2129+
(?<!=) # {function(string, string, number)} loop non-optional params
2130+
\\s*,\\s*
2131+
(?:\\?|!)? # {function(?string)} or function(!string)} nullable/non-nullable type
2132+
[a-zA-Z_$][\\w$]+
2133+
(?:\\[\\])? # {function(string[])} type application, an array of strings
2134+
=?
2135+
)*
2136+
(?:
2137+
(?<==) # {function(string, string=, number=)} loop optional params
2138+
\\s*,\\s*
2139+
(?:\\?|!)? # {function(?string)} or function(!string)} nullable/non-nullable type
2140+
[a-zA-Z_$][\\w$]+
2141+
(?:\\[\\])? # {function(string[])} type application, an array of strings
2142+
=
2143+
)*
2144+
)
2145+
)
21312146
)?
2132-
\\s*
2133-
\\)
2147+
\\s*\\)
21342148
)
21352149
)
21362150
(?: # {function(): string} function return type

0 commit comments

Comments
 (0)