Skip to content

Commit

Permalink
Merge branch 'master' into exhaustive-pattern-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed May 1, 2021
2 parents 37add9d + de79636 commit 667bda7
Show file tree
Hide file tree
Showing 565 changed files with 23,145 additions and 3,272 deletions.
179 changes: 179 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
/** @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-inner-declarations': 'off',
// TODO: Think about re-enabling this rule
'no-sparse-arrays': 'off',

// turning off some regex rules
// these are supposed to protect against accidental use but we need those quite often
'no-control-regex': 'off',
'no-empty-character-class': 'off',
'no-useless-escape': 'off'
},
settings: {
jsdoc: { mode: 'typescript' }
},
ignorePatterns: [
'*.min.js',
'vendor/',
'docs/',
'components.js',
'prism.js',
'node_modules'
],

overrides: [
{
// Languages and plugins
files: [
'components/*.js',
'plugins/*/prism-*.js'
],
excludedFiles: 'components/index.js',
env: {
browser: true,
node: true,
worker: true
},
globals: {
'Prism': true
},
rules: {
'no-var': 'off'
}
},
{
// `loadLanguages` function for Node.js
files: 'components/index.js',
env: {
es6: true,
node: true
},
parserOptions: {
ecmaVersion: 6
},
globals: {
'Prism': true
}
},
{
// Gulp and Danger
files: 'dependencies.js',
env: {
browser: true,
node: true
},
rules: {
'no-var': 'off'
}
},
{
// The scripts that run on our website
files: 'assets/*.js',
env: {
browser: true
},
globals: {
'components': true,
'getLoader': true,
'PrefixFree': true,
'Prism': true,
'Promise': true,
'saveAs': true,
'$': true,
'$$': true,
'$u': true
},
rules: {
'no-var': 'off'
}
},
{
// Test files
files: 'tests/**',
env: {
es6: true,
mocha: true,
node: true
},
parserOptions: {
ecmaVersion: 2018
}
},
{
// Gulp and Danger
files: [
'gulpfile.js/**',
'dangerfile.js'
],
env: {
es6: true,
node: true
},
parserOptions: {
ecmaVersion: 2018
}
},
{
// This file
files: '.eslintrc.js',
env: {
node: true
}
},
]
};
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
contact_links:
- name: Questions and Help
url: https://github.com/PrismJS/prism/discussions/categories/q-a
about: This issue tracker is not for support questions. Please refer to the Prism's Discussion tab.
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,16 @@ jobs:
git add --all && \
git diff-index --cached HEAD --stat --exit-code || \
(echo && echo "The above files changed because the build is not up to date." && echo "Please rebuild Prism." && exit 1)
lint:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- run: npm ci
- run: npm run lint:ci
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ gulpfile.js
.editorconfig
.gitattributes
.travis.yml
.eslintrc.js
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ Prism depends on community contributions to expand and cover a wider array of us

Thank you so much for contributing!!

### Software requirements

Prism will run on [almost any browser](https://prismjs.com/#features-full) and Node.js version but you need the following software to contribute:

- Node.js >= 10.x
- npm >= 6.x

## Translations

* [简体中文](https://www.awesomes.cn/repo/PrismJS/prism) (temporarily unavailable; see copy [here](https://deepmind.t-salon.cc/article/113))
* [简体中文](https://www.awesomes.cn/repo/PrismJS/prism) (if unavailable, see [here](https://deepmind.t-salon.cc/article/113))
67 changes: 33 additions & 34 deletions assets/code.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
(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) {
var src = element.getAttribute('data-src'),
html = element.getAttribute('data-type') === 'text/html',
contentProperty = html ? 'innerHTML' : 'textContent';
$$('[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;

// Run JS

$$('script', element).forEach(function (script) {
var after = script.nextSibling, parent = script.parentNode;
var parent = script.parentNode;
parent.removeChild(script);
document.head.appendChild(script);
});
}
catch (e) {}
} catch (e) { /* noop */ }
}
});
});

})();
}());

/**
* Table of contents
*/
(function(){
(function () {
var toc = document.createElement('ol');

$$('body > section > h1').forEach(function(h1) {
var section = h1.parentNode,
text = h1.textContent,
id = h1.id || section.id;
$$('body > section > h1').forEach(function (h1) {
var section = h1.parentNode;
var text = h1.textContent;
var id = h1.id || section.id;

// Assign id if one does not exist
if (!id) {
Expand Down Expand Up @@ -98,7 +97,7 @@ if (toc.children.length > 0) {
});
}

})();
}());

/**
* Linkify h2
Expand All @@ -116,36 +115,36 @@ if (toc.children.length > 0) {
inside: h2
});
});
})();
}());

// 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%)'
style.width = 'calc(1px + 1%)';

if(!style.width) {
if (!style.width) {
// calc not supported
var header = $('header'),
footer = $('footer');
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);
calculatePadding();
}
}
})();
}());

// 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 @@ -167,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 All @@ -186,7 +185,7 @@ for (var id in themes) {
$u.element.create('input', {
properties: {
type: 'radio',
name: "theme",
name: 'theme',
id: 'theme=' + id,
checked: current === id,
value: id,
Expand All @@ -207,9 +206,9 @@ for (var id in themes) {
}

setTheme(current);
})();
}());

(function(){
(function () {

function listPlugins(ul) {
for (var id in components.plugins) {
Expand Down Expand Up @@ -261,9 +260,9 @@ Prism && Prism.hooks.add('complete', function (env) {

// transfer margin of pre to wrapper
wrapper.style.margin = window.getComputedStyle(pre).margin;
pre.style.margin = "0";
pre.style.margin = '0';

});
});

})();
}());
Loading

0 comments on commit 667bda7

Please sign in to comment.