Skip to content

Commit

Permalink
(chore) eslint --fix against most grammars (#2853)
Browse files Browse the repository at this point in the history
This doesn't include all grammars because I focused on those that we're in flux from other PRs.
  • Loading branch information
joshgoebel committed Nov 17, 2020
1 parent b4b5bf0 commit f0c4a36
Show file tree
Hide file tree
Showing 144 changed files with 5,896 additions and 3,716 deletions.
38 changes: 28 additions & 10 deletions .eslintrc.js
Expand Up @@ -22,6 +22,7 @@ module.exports = {
"@typescript-eslint"
],
rules: {
"no-var": 1,
"init-declarations": ["error", "always"],
"array-callback-return": "error",
"block-scoped-var": "error",
Expand All @@ -32,7 +33,7 @@ module.exports = {
// for now ignore diff between types of quoting
quotes: "off",
// this is the style we are already using
"operator-linebreak": ["error", "before", { overrides: { "?": "after", ":": "after", "+": "after" } }],
"operator-linebreak": ["error", "before", { overrides: { "=": "after", "?": "after", ":": "after", "+": "after" } }],
// sometimes we declare variables with extra spacing
indent: ["error", 2, { VariableDeclarator: 2 }],
// seems like a good idea not to use explicit undefined
Expand All @@ -53,15 +54,32 @@ module.exports = {
files: ["src/languages/*.js"],
rules: {
"no-unused-expressions": "off",
// languages are all over the map and we don't want to
// do a mass edit so turn off the most egregious rule violations
indent: "off",
"comma-dangle": "off",
"array-bracket-spacing": "off",
"object-curly-spacing": "off",
"key-spacing": "off",
"object-curly-newline": "off",
"object-property-newline": "off"
// // languages are all over the map and we don't want to
// // do a mass edit so turn off the most egregious rule violations
// indent: "off",
"camelcase": 0,
"no-control-regex": 0,
"no-useless-escape": 0,
"comma-dangle": 1,
"array-bracket-spacing": ["error", "always"
// {
// objectsInArrays: true
// }
],
// "object-curly-spacing": 1,
// "key-spacing": "off",
// "array-bracket-spacing": [1],
"array-bracket-newline": [1, {
multiline: true,
minItems: 2
}],
"array-element-newline": 1,
"object-curly-newline": [1, {
minProperties: 1
}],
"object-property-newline": [2,
{ allowAllPropertiesOnSameLine: false }
]
}
}
]
Expand Down
116 changes: 58 additions & 58 deletions src/languages/abnf.js
Expand Up @@ -6,70 +6,70 @@ Website: https://tools.ietf.org/html/rfc5234

/** @type LanguageFn */
export default function(hljs) {
var regexes = {
ruleDeclaration: "^[a-zA-Z][a-zA-Z0-9-]*",
unexpectedChars: "[!@#$^&',?+~`|:]"
};
const regexes = {
ruleDeclaration: "^[a-zA-Z][a-zA-Z0-9-]*",
unexpectedChars: "[!@#$^&',?+~`|:]"
};

var keywords = [
"ALPHA",
"BIT",
"CHAR",
"CR",
"CRLF",
"CTL",
"DIGIT",
"DQUOTE",
"HEXDIG",
"HTAB",
"LF",
"LWSP",
"OCTET",
"SP",
"VCHAR",
"WSP"
];
const keywords = [
"ALPHA",
"BIT",
"CHAR",
"CR",
"CRLF",
"CTL",
"DIGIT",
"DQUOTE",
"HEXDIG",
"HTAB",
"LF",
"LWSP",
"OCTET",
"SP",
"VCHAR",
"WSP"
];

var commentMode = hljs.COMMENT(";", "$");
const commentMode = hljs.COMMENT(";", "$");

var terminalBinaryMode = {
className: "symbol",
begin: /%b[0-1]+(-[0-1]+|(\.[0-1]+)+){0,1}/
};
const terminalBinaryMode = {
className: "symbol",
begin: /%b[0-1]+(-[0-1]+|(\.[0-1]+)+){0,1}/
};

var terminalDecimalMode = {
className: "symbol",
begin: /%d[0-9]+(-[0-9]+|(\.[0-9]+)+){0,1}/
};
const terminalDecimalMode = {
className: "symbol",
begin: /%d[0-9]+(-[0-9]+|(\.[0-9]+)+){0,1}/
};

var terminalHexadecimalMode = {
className: "symbol",
begin: /%x[0-9A-F]+(-[0-9A-F]+|(\.[0-9A-F]+)+){0,1}/,
};
const terminalHexadecimalMode = {
className: "symbol",
begin: /%x[0-9A-F]+(-[0-9A-F]+|(\.[0-9A-F]+)+){0,1}/
};

var caseSensitivityIndicatorMode = {
className: "symbol",
begin: /%[si]/
};
const caseSensitivityIndicatorMode = {
className: "symbol",
begin: /%[si]/
};

var ruleDeclarationMode = {
className: "attribute",
begin: regexes.ruleDeclaration + '(?=\\s*=)',
};
const ruleDeclarationMode = {
className: "attribute",
begin: regexes.ruleDeclaration + '(?=\\s*=)'
};

return {
name: 'Augmented Backus-Naur Form',
illegal: regexes.unexpectedChars,
keywords: keywords.join(" "),
contains: [
ruleDeclarationMode,
commentMode,
terminalBinaryMode,
terminalDecimalMode,
terminalHexadecimalMode,
caseSensitivityIndicatorMode,
hljs.QUOTE_STRING_MODE,
hljs.NUMBER_MODE
]
};
return {
name: 'Augmented Backus-Naur Form',
illegal: regexes.unexpectedChars,
keywords: keywords.join(" "),
contains: [
ruleDeclarationMode,
commentMode,
terminalBinaryMode,
terminalDecimalMode,
terminalHexadecimalMode,
caseSensitivityIndicatorMode,
hljs.QUOTE_STRING_MODE,
hljs.NUMBER_MODE
]
};
}
22 changes: 13 additions & 9 deletions src/languages/accesslog.js
Expand Up @@ -5,20 +5,20 @@
Website: https://httpd.apache.org/docs/2.4/logs.html#accesslog
*/

/** @type LanguageFn */
/** @type LanguageFn */
export default function(hljs) {
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
var HTTP_VERBS = [
const HTTP_VERBS = [
"GET", "POST", "HEAD", "PUT", "DELETE", "CONNECT", "OPTIONS", "PATCH", "TRACE"
]
];
return {
name: 'Apache Access Log',
contains: [
// IP
{
className: 'number',
begin: '^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b',
relevance:5
relevance: 5
},
// Other numbers
{
Expand All @@ -29,13 +29,14 @@ export default function(hljs) {
// Requests
{
className: 'string',
begin: '"(' + HTTP_VERBS.join("|") + ')', end: '"',
begin: '"(' + HTTP_VERBS.join("|") + ')',
end: '"',
keywords: HTTP_VERBS.join(" "),
illegal: '\\n',
relevance: 5,
contains: [{
begin: 'HTTP/[12]\\.\\d',
relevance:5
relevance: 5
}]
},
// Dates
Expand All @@ -50,21 +51,24 @@ export default function(hljs) {
},
{
className: 'string',
begin: /\[/, end: /\]/,
begin: /\[/,
end: /\]/,
illegal: '\\n',
relevance: 0
},
// User agent / relevance boost
{
className: 'string',
begin: '"Mozilla/\\d\\.\\d \\\(', end: '"',
begin: '"Mozilla/\\d\\.\\d \\(',
end: '"',
illegal: '\\n',
relevance: 3
},
// Strings
{
className: 'string',
begin: '"', end: '"',
begin: '"',
end: '"',
illegal: '\\n',
relevance: 0
}
Expand Down
36 changes: 20 additions & 16 deletions src/languages/actionscript.js
Expand Up @@ -6,12 +6,13 @@ Category: scripting

/** @type LanguageFn */
export default function(hljs) {
var IDENT_RE = '[a-zA-Z_$][a-zA-Z0-9_$]*';
var IDENT_FUNC_RETURN_TYPE_RE = '([*]|[a-zA-Z_$][a-zA-Z0-9_$]*)';
const IDENT_RE = '[a-zA-Z_$][a-zA-Z0-9_$]*';
const IDENT_FUNC_RETURN_TYPE_RE = '([*]|[a-zA-Z_$][a-zA-Z0-9_$]*)';

var AS3_REST_ARG_MODE = {
const AS3_REST_ARG_MODE = {
className: 'rest_arg',
begin: '[.]{3}', end: IDENT_RE,
begin: '[.]{3}',
end: IDENT_RE,
relevance: 10
};

Expand All @@ -34,33 +35,38 @@ export default function(hljs) {
hljs.C_NUMBER_MODE,
{
className: 'class',
beginKeywords: 'package', end: /\{/,
beginKeywords: 'package',
end: /\{/,
contains: [hljs.TITLE_MODE]
},
{
className: 'class',
beginKeywords: 'class interface', end: /\{/, excludeEnd: true,
beginKeywords: 'class interface',
end: /\{/,
excludeEnd: true,
contains: [
{
beginKeywords: 'extends implements'
},
{ beginKeywords: 'extends implements' },
hljs.TITLE_MODE
]
},
{
className: 'meta',
beginKeywords: 'import include', end: ';',
keywords: {'meta-keyword': 'import include'}
beginKeywords: 'import include',
end: ';',
keywords: { 'meta-keyword': 'import include' }
},
{
className: 'function',
beginKeywords: 'function', end: '[{;]', excludeEnd: true,
beginKeywords: 'function',
end: '[{;]',
excludeEnd: true,
illegal: '\\S',
contains: [
hljs.TITLE_MODE,
{
className: 'params',
begin: '\\(', end: '\\)',
begin: '\\(',
end: '\\)',
contains: [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
Expand All @@ -69,9 +75,7 @@ export default function(hljs) {
AS3_REST_ARG_MODE
]
},
{
begin: ':\\s*' + IDENT_FUNC_RETURN_TYPE_RE
}
{ begin: ':\\s*' + IDENT_FUNC_RETURN_TYPE_RE }
]
},
hljs.METHOD_GUARD
Expand Down

0 comments on commit f0c4a36

Please sign in to comment.