Skip to content

Commit 71fd718

Browse files
committed
fixes highlighting in SQL editor, and popups on Firefox
1 parent 5b2686a commit 71fd718

18 files changed

+1703
-337
lines changed

.eslintignore

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1-
*
1+
node_modules
2+
jspm_packages
3+
dist
4+
stubs
5+
src/vendor
6+
lib/browser/wrap
7+
test/polyfills
8+
test/vendor
9+
test/saucelabs-browsers.js
10+
test/specs/server/compiler/fixtures
11+
test/specs/server/compiler/expect
12+
test/specs/server/compiler/parsers/js
13+
test/performance/db-monster
14+
*.hbs
15+
hbs
16+
*hbs
17+
views/*
18+
assets/vendor

.eslintrc.js

Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
module.exports = {
2+
parser: "babel-eslint",
3+
4+
extends: "plugin:prettier/recommended",
5+
plugins: ["prettier"],
6+
7+
env: {
8+
es6: true,
9+
browser: true
10+
},
11+
globals: {
12+
stateObj: true,
13+
workbox: false,
14+
document: true,
15+
window: true,
16+
CodeMirror: true,
17+
jQuery: true,
18+
$: true,
19+
20+
hljs: true
21+
},
22+
parserOptions: {
23+
ecmaVersion: 2017,
24+
ecmaFeatures: {
25+
arrowFunctions: true,
26+
binaryLiterals: true,
27+
blockBindings: true,
28+
classes: true,
29+
defaultParams: true,
30+
destructuring: true,
31+
forOf: true,
32+
generators: true,
33+
modules: true,
34+
objectLiteralComputedProperties: true,
35+
objectLiteralDuplicateProperties: true,
36+
objectLiteralShorthandMethods: true,
37+
objectLiteralShorthandProperties: true,
38+
octalLiterals: true,
39+
regexUFlag: true,
40+
regexYFlag: true,
41+
spread: true,
42+
superInFunctions: true,
43+
templateStrings: true,
44+
unicodeCodePointEscapes: true,
45+
globalReturn: true,
46+
jsx: true
47+
}
48+
},
49+
50+
rules: {
51+
"prettier/prettier": "error",
52+
53+
//
54+
//Possible Errors
55+
//
56+
// The following rules point out areas where you might have made mistakes.
57+
//
58+
"comma-dangle": 0, // disallow or enforce trailing commas
59+
"no-cond-assign": 2, // disallow assignment in conditional expressions
60+
"no-console": 0, // disallow use of console (off by default in the node environment)
61+
"no-constant-condition": 2, // disallow use of constant expressions in conditions
62+
"no-control-regex": 2, // disallow control characters in regular expressions
63+
"no-debugger": 2, // disallow use of debugger
64+
"no-dupe-args": 2, // disallow duplicate arguments in functions
65+
"no-dupe-keys": 2, // disallow duplicate keys when creating object literals
66+
"no-duplicate-case": 2, // disallow a duplicate case label.
67+
"no-empty": 2, // disallow empty statements
68+
69+
"no-ex-assign": 2, // disallow assigning to the exception in a catch block
70+
"no-extra-boolean-cast": 2, // disallow double-negation boolean casts in a boolean context
71+
"no-extra-parens": 0, // disallow unnecessary parentheses (off by default)
72+
"no-extra-semi": 2, // disallow unnecessary semicolons
73+
"no-func-assign": 2, // disallow overwriting functions written as function declarations
74+
"no-inner-declarations": 2, // disallow function or variable declarations in nested blocks
75+
"no-invalid-regexp": 2, // disallow invalid regular expression strings in the RegExp constructor
76+
"no-irregular-whitespace": 2, // disallow irregular whitespace outside of strings and comments
77+
"no-negated-in-lhs": 2, // disallow negation of the left operand of an in expression
78+
"no-obj-calls": 2, // disallow the use of object properties of the global object (Math and JSON) as functions
79+
"no-regex-spaces": 2, // disallow multiple spaces in a regular expression literal
80+
"no-sparse-arrays": 2, // disallow sparse arrays
81+
"no-unreachable": 2, // disallow unreachable statements after a return, throw, continue, or break statement
82+
"use-isnan": 2, // disallow comparisons with the value NaN
83+
"valid-jsdoc": 0, // Ensure JSDoc comments are valid (off by default)
84+
"valid-typeof": 2, // Ensure that the results of typeof are compared against a valid string
85+
86+
//
87+
// Best Practices
88+
//
89+
// These are rules designed to prevent you from making mistakes.
90+
// They either prescribe a better way of doing something or help you avoid footguns.
91+
//
92+
"block-scoped-var": 0, // treat var statements as if they were block scoped (off by default). 0: deep destructuring is not compatible https://github.com/eslint/eslint/issues/1863
93+
complexity: 0, // specify the maximum cyclomatic complexity allowed in a program (off by default)
94+
"consistent-return": 0, // require return statements to either always or never specify values
95+
curly: 2, // specify curly brace conventions for all control statements
96+
"default-case": 2, // require default case in switch statements (off by default)
97+
"dot-notation": 2, // encourages use of dot notation whenever possible
98+
eqeqeq: 2, // require the use of === and !==
99+
"guard-for-in": 2, // make sure for-in loops have an if statement (off by default)
100+
"no-alert": 0, // disallow the use of alert, confirm, and prompt
101+
"no-caller": 2, // disallow use of arguments.caller or arguments.callee
102+
"no-div-regex": 2, // disallow division operators explicitly at beginning of regular expression (off by default)
103+
"no-else-return": 0, // disallow else after a return in an if (off by default)
104+
"no-eq-null": 2, // disallow comparisons to null without a type-checking operator (off by default)
105+
"no-eval": 2, // disallow use of eval()
106+
"no-extend-native": 2, // disallow adding to native types
107+
"no-extra-bind": 2, // disallow unnecessary function binding
108+
"no-fallthrough": 2, // disallow fallthrough of case statements
109+
"no-floating-decimal": 2, // disallow the use of leading or trailing decimal points in numeric literals (off by default)
110+
"no-implied-eval": 2, // disallow use of eval()-like methods
111+
"no-iterator": 2, // disallow usage of __iterator__ property
112+
"no-labels": 2, // disallow use of labeled statements
113+
"no-lone-blocks": 2, // disallow unnecessary nested blocks
114+
"no-loop-func": 2, // disallow creation of functions within loops
115+
"no-multi-spaces": 2, // disallow use of multiple spaces
116+
"no-multi-str": 2, // disallow use of multiline strings
117+
"no-native-reassign": 2, // disallow reassignments of native objects
118+
"no-new": 2, // disallow use of new operator when not part of the assignment or comparison
119+
"no-new-func": 2, // disallow use of new operator for Function object
120+
"no-new-wrappers": 2, // disallows creating new instances of String,Number, and Boolean
121+
"no-octal": 2, // disallow use of octal literals
122+
"no-octal-escape": 2, // disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251";
123+
"no-param-reassign": 0, // disallow reassignment of function parameters (off by default)
124+
"no-process-env": 0, // disallow use of process.env (off by default)
125+
"no-proto": 2, // disallow usage of __proto__ property
126+
"no-redeclare": 2, // disallow declaring the same variable more then once
127+
"no-return-assign": 2, // disallow use of assignment in return statement
128+
"no-script-url": 2, // disallow use of javascript: urls.
129+
"no-self-compare": 2, // disallow comparisons where both sides are exactly the same (off by default)
130+
"no-sequences": 2, // disallow use of comma operator
131+
"no-throw-literal": 2, // restrict what can be thrown as an exception (off by default)
132+
"no-unused-expressions": 2, // disallow usage of expressions in statement position
133+
"no-void": 2, // disallow use of void operator (off by default)
134+
"no-warning-comments": [
135+
0,
136+
{
137+
terms: ["todo", "fixme"],
138+
location: "start"
139+
}
140+
], // disallow usage of configurable warning terms in comments": 2, // e.g. TODO or FIXME (off by default)
141+
"no-with": 2, // disallow use of the with statement
142+
radix: 2, // require use of the second argument for parseInt() (off by default)
143+
"vars-on-top": 0, // requires to declare all vars on top of their containing scope (off by default)
144+
"wrap-iife": 2, // require immediate function invocation to be wrapped in parentheses (off by default)
145+
yoda: 2, // require or disallow Yoda conditions
146+
147+
//
148+
// Strict Mode
149+
//
150+
// These rules relate to using strict mode.
151+
//
152+
strict: 0, // controls location of Use Strict Directives. 0: required by `babel-eslint`
153+
154+
//
155+
// Variables
156+
//
157+
// These rules have to do with variable declarations.
158+
//
159+
"no-catch-shadow": 2, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment)
160+
"no-delete-var": 2, // disallow deletion of variables
161+
"no-label-var": 2, // disallow labels that share a name with a variable
162+
"no-shadow": 2, // disallow declaration of variables already declared in the outer scope
163+
"no-shadow-restricted-names": 2, // disallow shadowing of names such as arguments
164+
"no-undef": 2, // disallow use of undeclared variables unless mentioned in a /*global */ block
165+
"no-undef-init": 2, // disallow use of undefined when initializing variables
166+
"no-undefined": 0, // disallow use of undefined variable (off by default)
167+
"no-unused-vars": 0, // disallow declaration of variables that are not used in the code
168+
"no-use-before-define": 2, // disallow use of variables before they are defined
169+
170+
//
171+
//Stylistic Issues
172+
//
173+
// These rules are purely matters of style and are quite subjective.
174+
//
175+
indent: [0, "tab"], // this option sets a specific tab width for your code (off by default)
176+
"brace-style": 1, // enforce one true brace style (off by default)
177+
camelcase: 0, // require camel case names
178+
"comma-spacing": [
179+
1,
180+
{
181+
before: false,
182+
after: true
183+
}
184+
], // enforce spacing before and after comma
185+
"comma-style": [1, "last"], // enforce one true comma style (off by default)
186+
"consistent-this": [1, "_this"], // enforces consistent naming when capturing the current execution context (off by default)
187+
"eol-last": 1, // enforce newline at the end of file, with no multiple empty lines
188+
"func-names": 0, // require function expressions to have a name (off by default)
189+
"func-style": 0, // enforces use of function declarations or expressions (off by default)
190+
"key-spacing": [
191+
1,
192+
{
193+
beforeColon: false,
194+
afterColon: true
195+
}
196+
], // enforces spacing between keys and values in object literal properties
197+
"max-nested-callbacks": [1, 4], // specify the maximum depth callbacks can be nested (off by default)
198+
"new-cap": [
199+
1,
200+
{
201+
newIsCap: true,
202+
capIsNew: false
203+
}
204+
], // require a capital letter for constructors
205+
"new-parens": 1, // disallow the omission of parentheses when invoking a constructor with no arguments
206+
"newline-after-var": 0, // allow/disallow an empty newline after var statement (off by default)
207+
"no-array-constructor": 1, // disallow use of the Array constructor
208+
"no-inline-comments": 0, // disallow comments inline after code (off by default)
209+
"no-lonely-if": 1, // disallow if as the only statement in an else block (off by default)
210+
"no-mixed-spaces-and-tabs": 1, // disallow mixed spaces and tabs for indentation
211+
"no-multiple-empty-lines": [
212+
1,
213+
{
214+
max: 2
215+
}
216+
], // disallow multiple empty lines (off by default)
217+
"no-nested-ternary": 1, // disallow nested ternary expressions (off by default)
218+
"no-new-object": 1, // disallow use of the Object constructor
219+
"no-spaced-func": 1, // disallow space between function identifier and application
220+
"no-ternary": 0, // disallow the use of ternary operators (off by default)
221+
"no-trailing-spaces": 1, // disallow trailing whitespace at the end of lines
222+
"no-underscore-dangle": 0, // disallow dangling underscores in identifiers
223+
//"one-var": ["warn", { "initialized": "never" }], // allow just one var statement per function (off by default)
224+
"operator-assignment": [0, "never"], // require assignment operator shorthand where possible or prohibit it entirely (off by default)
225+
"padded-blocks": [0, "always"], // enforce padding within blocks (off by default)
226+
"quote-props": [0, "as-needed"], // require quotes around object literal property names (off by default)
227+
quotes: [0, "single"], // specify whether double or single quotes should be used
228+
semi: [1, "always"], // require or disallow use of semicolons instead of ASI
229+
"semi-spacing": [
230+
1,
231+
{
232+
before: false,
233+
after: true
234+
}
235+
], // enforce spacing before and after semicolons
236+
"sort-vars": 0, // sort variables within the same declaration block (off by default)
237+
238+
"space-before-blocks": [1, "always"], // require or disallow space before blocks (off by default)
239+
"space-before-function-paren": [
240+
0,
241+
{
242+
anonymous: "always",
243+
named: "never"
244+
}
245+
], // require or disallow space before function opening parenthesis (off by default)
246+
247+
//"space-infix-ops": [1], // require spaces around operators
248+
//"space-return-throw-case": [1, "always"], // require a space after return, throw, and case
249+
"space-unary-ops": [
250+
1,
251+
{
252+
words: true,
253+
nonwords: false
254+
}
255+
], // Require or disallow spaces before/after unary operators (words on by default, nonwords off by default)
256+
"wrap-regex": 0, // require regex literals to be wrapped in parentheses (off by default)
257+
258+
//
259+
// ECMAScript 6
260+
//
261+
// These rules are only relevant to ES6 environments and are off by default.
262+
//
263+
"no-var": 0, // require let or const instead of var (off by default)
264+
"generator-star-spacing": [2, "before"], // enforce the spacing around the * in generator functions (off by default)
265+
266+
//
267+
// Legacy
268+
//
269+
// The following rules are included for compatibility with JSHint and JSLint.
270+
// While the names of the rules may not match up with the JSHint/JSLint counterpart,
271+
// the functionality is the same.
272+
//
273+
"max-depth": [2, 3], // specify the maximum depth that blocks can be nested (off by default)
274+
"max-len": [1, 150, 2], // specify the maximum length of a line in your program (off by default)
275+
"max-params": [1, 10], // limits the number of parameters that can be used in the function declaration. (off by default)
276+
"max-statements": 0, // specify the maximum number of statement allowed in a function (off by default)
277+
"no-bitwise": 1, // disallow use of bitwise operators (off by default)
278+
"no-plusplus": 0 // disallow use of unary operators, ++ and -- (off by default)
279+
}
280+
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
CodeMirror.sqlLint = function (text, updateLinting, options, cm) {
2+
// Skipping check if text box is empty.
3+
if (text.trim() === '') {
4+
updateLinting(cm, []);
5+
return;
6+
}
7+
8+
function handleResponse (response) {
9+
var found = [];
10+
for (var idx in response) {
11+
found.push({
12+
from: CodeMirror.Pos(
13+
response[idx].fromLine, response[idx].fromColumn
14+
),
15+
to: CodeMirror.Pos(
16+
response[idx].toLine, response[idx].toColumn
17+
),
18+
messageHTML: response[idx].message,
19+
severity : response[idx].severity
20+
});
21+
}
22+
23+
updateLinting(cm, found);
24+
}
25+
26+
$.ajax({
27+
method: 'POST',
28+
url: 'lint.php',
29+
dataType: 'json',
30+
data: {
31+
sql_query: text,
32+
server: PMA_commonParams.get('server'),
33+
options: options.lintOptions,
34+
no_history: true,
35+
},
36+
success: handleResponse
37+
});
38+
};

0 commit comments

Comments
 (0)