- Fix: Broken lv locale, inconsistent tabs/spaces pt-PR

- Linting: Add ESLint script and devDeps and begin ESLint conversion (completed locales and jspdf directories only)
This commit is contained in:
Brett Zamir
2018-05-13 11:03:45 +08:00
parent ac6d5092e4
commit 820964334c
65 changed files with 3655 additions and 2046 deletions

3
.eslintignore Normal file
View File

@@ -0,0 +1,3 @@
node_modules
editor/jspdf/jspdf.min.js
editor/jspdf/underscore-min.js

19
.eslintrc Normal file
View File

@@ -0,0 +1,19 @@
{
"extends": "standard",
"parserOptions": {
"sourceType": "module"
},
"env": {
"node": false,
"browser": true
},
"rules": {
"semi": [2, "always"],
"indent": ["error", "tab", {"outerIIFEBody": 0}],
"no-tabs": 0,
"object-property-newline": 0,
"one-var": 0,
"no-var": 2,
"prefer-const": 2
}
}

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
node_modules
# See editor/config-sample.js for an example
editor/config.js
editor/custom.css

View File

@@ -1,5 +1,5 @@
/* globals RGBColor, DOMParser, jsPDF */
/*jslint eqeq:true, vars:true*/
/* eslint-disable no-var */
/*
* svgToPdf.js
*
@@ -46,7 +46,7 @@ var nodeIs = function (node, possible) {
var removeAttributes = function (node, attributes) {
var toRemove = [];
[].forEach.call(node.attributes, function (a) {
if (attributeIsNotEmpty(a) && attributes.indexOf(a.name.toLowerCase()) == -1) {
if (attributeIsNotEmpty(a) && attributes.indexOf(a.name.toLowerCase()) === -1) {
toRemove.push(a.name);
}
});
@@ -59,13 +59,13 @@ var removeAttributes = function(node, attributes) {
var svgElementToPdf = function (element, pdf, options) {
// pdf is a jsPDF object
// console.log("options =", options);
var remove = (options.removeInvalid == undef ? false : options.removeInvalid);
var k = (options.scale == undef ? 1.0 : options.scale);
var remove = (options.removeInvalid === undef ? false : options.removeInvalid);
var k = (options.scale === undef ? 1.0 : options.scale);
var colorMode = null;
[].forEach.call(element.children, function (node) {
// console.log("passing: ", node);
var hasFillColor = false;
var hasStrokeColor = false;
// var hasStrokeColor = false;
var fillRGB;
if (nodeIs(node, ['g', 'line', 'rect', 'ellipse', 'circle', 'text'])) {
var fillColor = node.getAttribute('fill');
@@ -90,9 +90,9 @@ var svgElementToPdf = function(element, pdf, options) {
if (attributeIsNotEmpty(strokeColor)) {
var strokeRGB = new RGBColor(strokeColor);
if (strokeRGB.ok) {
hasStrokeColor = true;
// hasStrokeColor = true;
pdf.setDrawColor(strokeRGB.r, strokeRGB.g, strokeRGB.b);
if(colorMode == 'F') {
if (colorMode === 'F') {
colorMode = 'FD';
} else {
colorMode = null;
@@ -160,17 +160,17 @@ var svgElementToPdf = function(element, pdf, options) {
if (hasFillColor) {
pdf.setTextColor(fillRGB.r, fillRGB.g, fillRGB.b);
}
var fontType = "";
var fontType = '';
if (node.hasAttribute('font-weight')) {
if(node.getAttribute('font-weight') == "bold") {
fontType = "bold";
if (node.getAttribute('font-weight') === 'bold') {
fontType = 'bold';
} else {
node.removeAttribute('font-weight');
}
}
if (node.hasAttribute('font-style')) {
if(node.getAttribute('font-style') == "italic") {
fontType += "italic";
if (node.getAttribute('font-style') === 'italic') {
fontType += 'italic';
} else {
node.removeAttribute('font-style');
}
@@ -213,7 +213,6 @@ var svgElementToPdf = function(element, pdf, options) {
};
jsPDFAPI.addSVG = function (element, x, y, options) {
options = (options === undef ? {} : options);
options.x_offset = x;
options.y_offset = y;

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "af",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "ar",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "az",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "be",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "bg",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "ca",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "cs",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "cy",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "da",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "de",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "el",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "en",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "es",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "et",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "fa",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "fi",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "fr",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "fy",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "ga",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "gl",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "he",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "hi",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "hr",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "hu",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "hy",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "id",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "is",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "it",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "ja",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "ko",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "lt",

View File

@@ -1,4 +1,4 @@
/*globals svgEditor */
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "lv",
@@ -218,12 +218,9 @@ svgEditor.readLang({
"enterNewLayerName": "Please enter the new layer name",
"layerHasThatName": "Layer already has that name",
"QmoveElemsToLayer": "Move selected elements to layer '%s'?",
"QwantToClear":"Do you want to clear the drawing?
This will also erase your undo history!",
"QwantToOpen":"Do you want to open a new file?
This will also erase your undo history!",
"QerrorsRevertToSource":"There were parsing errors in your SVG source.
Revert back to original SVG source?",
"QwantToClear": "Do you want to clear the drawing?\nThis will also erase your undo history!",
"QwantToOpen": "Do you want to open a new file?\nThis will also erase your undo history!",
"QerrorsRevertToSource": "There were parsing errors in your SVG source.\nRevert back to original SVG source?",
"QignoreSourceChanges": "Ignore changes made to SVG source?",
"featNotSupported": "Feature not supported",
"enterNewImgURL": "Enter the new image URL",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "mk",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "ms",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "mt",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "nl",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "no",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "pl",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "pt-BR",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "pt-PT",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "ro",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "ru",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "sk",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "sl",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "sq",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "sr",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "sv",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "sw",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "test",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "th",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "tl",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "tr",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "uk",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "vi",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "yi",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "zh-CN",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "zh-HK",

View File

@@ -1,3 +1,4 @@
/* eslint-disable quotes */
/* globals svgEditor */
svgEditor.readLang({
lang: "zh-TW",

View File

@@ -1,5 +1,5 @@
/* eslint-disable no-var */
/* globals jQuery */
/*jslint vars: true, eqeq: true, forin: true*/
/*
* Localizing script for SVG-edit UI
*
@@ -15,9 +15,10 @@
// 2) svgcanvas.js
// 3) svg-editor.js
var svgEditor = (function($, editor) {'use strict';
var svgEditor = (function ($, editor) {
'use strict';
var lang_param;
var langParam;
function setStrings (type, obj, ids) {
// Root element to look for element from
@@ -46,8 +47,6 @@ var svgEditor = (function($, editor) {'use strict';
elem.title = val;
break;
}
} else {
console.log('Missing: ' + sel);
}
@@ -55,7 +54,7 @@ var svgEditor = (function($, editor) {'use strict';
}
editor.readLang = function (langData) {
var more = editor.canvas.runExtensions('addlangData', lang_param, true);
var more = editor.canvas.runExtensions('addlangData', langParam, true);
$.each(more, function (i, m) {
if (m.data) {
langData = $.merge(langData, m.data);
@@ -66,7 +65,7 @@ var svgEditor = (function($, editor) {'use strict';
if (!langData.tools) { return; }
var tools = langData.tools,
misc = langData.misc,
// misc = langData.misc,
properties = langData.properties,
config = langData.config,
layers = langData.layers,
@@ -102,7 +101,7 @@ var svgEditor = (function($, editor) {'use strict';
smallest_object: tools.smallest_object,
straight_segments: properties.straight_segments,
svginfo_bg_url: config.editor_img_url + ":",
svginfo_bg_url: config.editor_img_url + ':',
svginfo_bg_note: config.editor_bg_note,
svginfo_change_background: config.background,
svginfo_dim: config.doc_dims,
@@ -272,46 +271,42 @@ var svgEditor = (function($, editor) {'use strict';
}, true);
editor.setLang(lang_param, langData);
editor.setLang(langParam, langData);
};
editor.putLocale = function (given_param, good_langs) {
if (given_param) {
lang_param = given_param;
}
else {
lang_param = $.pref('lang');
if (!lang_param) {
editor.putLocale = function (givenParam, goodLangs) {
if (givenParam) {
langParam = givenParam;
} else {
langParam = $.pref('lang');
if (!langParam) {
if (navigator.userLanguage) { // Explorer
lang_param = navigator.userLanguage;
langParam = navigator.userLanguage;
} else if (navigator.language) { // FF, Opera, ...
langParam = navigator.language;
}
else if (navigator.language) { // FF, Opera, ...
lang_param = navigator.language;
}
if (lang_param == null) { // Todo: Would cause problems if uiStrings removed; remove this?
if (langParam == null) { // Todo: Would cause problems if uiStrings removed; remove this?
return;
}
}
console.log('Lang: ' + lang_param);
console.log('Lang: ' + langParam);
// Set to English if language is not in list of good langs
if ($.inArray(lang_param, good_langs) === -1 && lang_param !== 'test') {
lang_param = "en";
if ($.inArray(langParam, goodLangs) === -1 && langParam !== 'test') {
langParam = 'en';
}
// don't bother on first run if language is English
// The following line prevents setLang from running
// extensions which depend on updated uiStrings,
// so commenting it out.
// if (lang_param.indexOf("en") === 0) {return;}
// if (langParam.indexOf("en") === 0) {return;}
}
var conf = editor.curConfig;
var url = conf.langPath + "lang." + lang_param + ".js";
var url = conf.langPath + 'lang.' + langParam + '.js';
$.getScript(url, function (d) {
// Fails locally in Chrome 5+
@@ -321,8 +316,7 @@ var svgEditor = (function($, editor) {'use strict';
document.querySelector('head').appendChild(s);
}
});
};
return editor;
}(jQuery, svgEditor));
}(jQuery, svgEditor)); // eslint-disable-line no-use-before-define

1533
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -10,6 +10,7 @@
},
"engines": {},
"scripts": {
"eslint": "eslint .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
@@ -35,5 +36,13 @@
"url": "https://github.com/SVG-Edit/svgedit/issues"
},
"homepage": "https://github.com/SVG-Edit/svgedit#readme",
"dependencies": {}
"dependencies": {},
"devDependencies": {
"eslint": "4.19.1",
"eslint-config-standard": "11.0.0",
"eslint-plugin-import": "2.11.0",
"eslint-plugin-node": "6.0.1",
"eslint-plugin-promise": "3.7.0",
"eslint-plugin-standard": "3.1.0"
}
}