Skip to content

Commit

Permalink
ESLint: Added regexp plugin (#2924)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Jun 13, 2021
1 parent 5d3d808 commit 18a0082
Show file tree
Hide file tree
Showing 92 changed files with 162 additions and 105 deletions.
31 changes: 29 additions & 2 deletions .eslintrc.js
@@ -1,7 +1,7 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
plugins: ['jsdoc'],
plugins: ['jsdoc', 'regexp'],
extends: 'eslint:recommended',
rules: {
'no-use-before-define': ['error', { 'functions': false, 'classes': false }],
Expand Down Expand Up @@ -55,6 +55,29 @@ module.exports = {
'jsdoc/require-param-name': 'warn',
'jsdoc/require-property-name': 'warn',

// regexp
'regexp/no-assertion-capturing-group': 'error',
// 'regexp/no-dupe-disjunctions': 'error',
'regexp/no-empty-alternative': 'error',
'regexp/no-empty-lookarounds-assertion': 'error',
'regexp/no-lazy-ends': 'error',
'regexp/no-obscure-range': 'error',
'regexp/no-optional-assertion': 'error',
'regexp/no-standalone-backslash': 'error',
'regexp/no-zero-quantifier': 'error',
'regexp/optimal-lookaround-quantifier': 'error',
'regexp/no-unused-capturing-group': 'error',

'regexp/match-any': 'warn',
'regexp/negation': 'warn',
'regexp/no-dupe-characters-character-class': 'warn',
'regexp/no-trivially-nested-assertion': 'warn',
'regexp/no-trivially-nested-quantifier': 'warn',
'regexp/no-useless-character-class': 'warn',
'regexp/no-useless-lazy': 'warn',
'regexp/prefer-w': 'warn',
'regexp/sort-flags': 'warn',

// I turned this rule off because we use `hasOwnProperty` in a lot of places
// TODO: Think about re-enabling this rule
'no-prototype-builtins': 'off',
Expand All @@ -70,7 +93,11 @@ module.exports = {
'no-useless-escape': 'off'
},
settings: {
jsdoc: { mode: 'typescript' }
jsdoc: { mode: 'typescript' },
regexp: {
// allow alphanumeric and cyrillic ranges
allowedCharacterRanges: ['alphanumeric', 'а-я', 'А-Я']
}
},
ignorePatterns: [
'*.min.js',
Expand Down
2 changes: 1 addition & 1 deletion components/prism-ada.js
Expand Up @@ -15,5 +15,5 @@ Prism.languages.ada = {
'operator': /<[=>]?|>=?|=>?|:=|\/=?|\*\*?|[&+-]/,
'punctuation': /\.\.?|[,;():]/,
'char': /'.'/,
'variable': /\b[a-z](?:[_a-z\d])*\b/i
'variable': /\b[a-z](?:\w)*\b/i
};
2 changes: 1 addition & 1 deletion components/prism-ada.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/prism-aspnet.js
Expand Up @@ -40,7 +40,7 @@ Prism.languages.insertBefore('aspnet', 'comment', {
// script runat="server" contains csharp, not javascript
Prism.languages.insertBefore('aspnet', Prism.languages.javascript ? 'script' : 'tag', {
'asp-script': {
pattern: /(<script(?=.*runat=['"]?server['"]?)[^>]*>)[\s\S]*?(?=<\/script>)/i,
pattern: /(<script(?=.*runat=['"]?server\b)[^>]*>)[\s\S]*?(?=<\/script>)/i,
lookbehind: true,
alias: ['asp', 'script'],
inside: Prism.languages.csharp || {}
Expand Down
2 changes: 1 addition & 1 deletion components/prism-aspnet.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/prism-autohotkey.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/prism-autohotkey.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion components/prism-bash.js
Expand Up @@ -116,7 +116,7 @@
'string': [
// Support for Here-documents https://en.wikipedia.org/wiki/Here_document
{
pattern: /((?:^|[^<])<<-?\s*)(\w+?)\s[\s\S]*?(?:\r?\n|\r)\2/,
pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
lookbehind: true,
greedy: true,
inside: insideString
Expand Down

0 comments on commit 18a0082

Please sign in to comment.