Skip to content

Commit

Permalink
Merge branch 'master' into issue2871
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed May 4, 2021
2 parents 5eeb37f + a9a199b commit f938a46
Show file tree
Hide file tree
Showing 111 changed files with 1,424 additions and 807 deletions.
44 changes: 41 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,59 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
plugins: ['jsdoc'],
extends: 'eslint:recommended',
rules: {
'no-use-before-define': ['error', { 'functions': false, 'classes': false }],

// stylistic rules
'brace-style': ['warn', '1tbs', { allowSingleLine: true }],
'no-tabs': ['warn', { allowIndentationTabs: true }],
'no-var': 'error',
'quotes': ['warn', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
'semi': 'warn',
'wrap-iife': 'warn',

// spaces
'arrow-spacing': 'warn',
'block-spacing': 'warn',
'comma-spacing': 'warn',
'computed-property-spacing': 'warn',
'func-call-spacing': 'warn',
'generator-star-spacing': 'warn',
'key-spacing': 'warn',
'keyword-spacing': 'warn',
'no-multi-spaces': ['warn', { ignoreEOLComments: true }],
'no-trailing-spaces': 'warn',
'no-whitespace-before-property': 'warn',
'object-curly-spacing': ['warn', 'always'],
'rest-spread-spacing': 'warn',
'semi-spacing': 'warn',
'space-before-blocks': 'warn',
'space-before-function-paren': ['warn', { named: 'never' }],
'space-in-parens': 'warn',
'space-infix-ops': ['warn', { int32Hint: true }],
'space-unary-ops': 'warn',
'switch-colon-spacing': 'warn',
'template-curly-spacing': 'warn',
'yield-star-spacing': 'warn',

// JSDoc
'jsdoc/check-alignment': 'warn',
'jsdoc/check-syntax': 'warn',
'jsdoc/check-param-names': 'warn',
'jsdoc/require-hyphen-before-param-description': ['warn', 'never'],
'jsdoc/check-tag-names': 'warn',
'jsdoc/check-types': 'warn',
'jsdoc/empty-tags': 'warn',
'jsdoc/newline-after-description': 'warn',
'jsdoc/require-param-name': 'warn',
'jsdoc/require-property-name': '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',
// TODO: Think about re-enabling this rule
'no-cond-assign': 'off',
// TODO: Think about re-enabling this rule
'no-inner-declarations': 'off',
// TODO: Think about re-enabling this rule
'no-sparse-arrays': 'off',
Expand All @@ -28,10 +64,12 @@ module.exports = {
'no-empty-character-class': 'off',
'no-useless-escape': 'off'
},
settings: {
jsdoc: { mode: 'typescript' }
},
ignorePatterns: [
'*.min.js',
'vendor/',
'utopia.js',
'docs/',
'components.js',
'prism.js',
Expand Down
28 changes: 14 additions & 14 deletions assets/code.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
(function(){
(function () {

if(!document.body.addEventListener) {
if (!document.body.addEventListener) {
return;
}

$$('[data-plugin-header]').forEach(function (element) {
var plugin = components.plugins[element.getAttribute('data-plugin-header')];
element.innerHTML = '<div class="intro" data-src="assets/templates/header-plugins.html" data-type="text/html"></div>\n'
+ '<h2>' + plugin.title + '</h2>\n<p>' + plugin.description + '</p>';
+ '<h2>' + plugin.title + '</h2>\n<p>' + plugin.description + '</p>';
});

$$('[data-src][data-type="text/html"]').forEach(function(element) {
$$('[data-src][data-type="text/html"]').forEach(function (element) {
var src = element.getAttribute('data-src');
var html = element.getAttribute('data-type') === 'text/html';
var contentProperty = html ? 'innerHTML' : 'textContent';

$u.xhr({
url: src,
callback: function(xhr) {
callback: function (xhr) {
try {
element[contentProperty] = xhr.responseText;

Expand All @@ -38,10 +38,10 @@ $$('[data-src][data-type="text/html"]').forEach(function(element) {
/**
* Table of contents
*/
(function(){
(function () {
var toc = document.createElement('ol');

$$('body > section > h1').forEach(function(h1) {
$$('body > section > h1').forEach(function (h1) {
var section = h1.parentNode;
var text = h1.textContent;
var id = h1.id || section.id;
Expand Down Expand Up @@ -118,21 +118,21 @@ if (toc.children.length > 0) {
}());

// calc()
(function(){
if(!window.PrefixFree) return;
(function () {
if (!window.PrefixFree) return;

if (PrefixFree.functions.indexOf('calc') == -1) {
var style = document.createElement('_').style;
style.width = 'calc(1px + 1%)';

if(!style.width) {
if (!style.width) {
// calc not supported
var header = $('header');
var footer = $('footer');

function calculatePadding() {
header.style.padding =
footer.style.padding = '30px ' + (innerWidth/2 - 450) + 'px';
footer.style.padding = '30px ' + (innerWidth / 2 - 450) + 'px';
}

addEventListener('resize', calculatePadding);
Expand All @@ -144,7 +144,7 @@ if (toc.children.length > 0) {
// setTheme is intentionally global,
// so it can be accessed from download.js
var setTheme;
(function() {
(function () {
var p = $u.element.create('p', {
properties: {
id: 'theme'
Expand All @@ -166,7 +166,7 @@ if (!(current in themes)) {
if (current === undefined) {
var stored = localStorage.getItem('theme');

current = stored in themes? stored : 'prism';
current = stored in themes ? stored : 'prism';
}

setTheme = function (id) {
Expand Down Expand Up @@ -208,7 +208,7 @@ for (var id in themes) {
setTheme(current);
}());

(function(){
(function () {

function listPlugins(ul) {
for (var id in components.plugins) {
Expand Down
Loading

0 comments on commit f938a46

Please sign in to comment.