Clean up repo, update to integration-tools@v2
This commit is contained in:
174
.eslintrc.json
174
.eslintrc.json
@ -1,174 +0,0 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true,
|
||||
"node": true,
|
||||
"jest": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"indent": [
|
||||
"error",
|
||||
2
|
||||
],
|
||||
"quotes": [
|
||||
"error",
|
||||
"single",
|
||||
{
|
||||
"avoidEscape": true,
|
||||
"allowTemplateLiterals": true
|
||||
}
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"semi-spacing": [
|
||||
"error",
|
||||
{
|
||||
"before": false,
|
||||
"after": true
|
||||
}
|
||||
],
|
||||
"no-duplicate-imports": "error",
|
||||
"no-useless-computed-key": "error",
|
||||
"rest-spread-spacing": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"no-console": "off",
|
||||
"eqeqeq": [
|
||||
"error",
|
||||
"smart"
|
||||
],
|
||||
"brace-style": [
|
||||
"error",
|
||||
"1tbs",
|
||||
{
|
||||
"allowSingleLine": true
|
||||
}
|
||||
],
|
||||
"curly": [
|
||||
"error",
|
||||
"multi-or-nest"
|
||||
],
|
||||
"guard-for-in": "warn",
|
||||
"object-shorthand": [
|
||||
"warn",
|
||||
"always"
|
||||
],
|
||||
"key-spacing": [
|
||||
"error",
|
||||
{
|
||||
"beforeColon": false,
|
||||
"afterColon": true,
|
||||
"mode": "strict"
|
||||
}
|
||||
],
|
||||
"camelcase": [
|
||||
"error",
|
||||
{
|
||||
"properties": "always"
|
||||
}
|
||||
],
|
||||
"dot-location": [
|
||||
"error",
|
||||
"property"
|
||||
],
|
||||
"generator-star-spacing": [
|
||||
"error",
|
||||
{
|
||||
"before": true,
|
||||
"after": false
|
||||
}
|
||||
],
|
||||
"block-spacing": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"comma-style": [
|
||||
"error",
|
||||
"last"
|
||||
],
|
||||
"comma-spacing": [
|
||||
"error",
|
||||
{
|
||||
"before": false,
|
||||
"after": true
|
||||
}
|
||||
],
|
||||
"no-extend-native": "error",
|
||||
"no-loop-func": "error",
|
||||
"no-implied-eval": "error",
|
||||
"no-iterator": "error",
|
||||
"no-label-var": "error",
|
||||
"no-multi-str": "error",
|
||||
"no-script-url": "error",
|
||||
"no-shadow-restricted-names": "error",
|
||||
"no-spaced-func": "error",
|
||||
"no-sparse-arrays": "warn",
|
||||
"no-fallthrough": "warn",
|
||||
"no-caller": "error",
|
||||
"no-eval": "error",
|
||||
"no-multiple-empty-lines": [
|
||||
"error",
|
||||
{
|
||||
"max": 2,
|
||||
"maxEOF": 1
|
||||
}
|
||||
],
|
||||
"no-multi-spaces":[
|
||||
"error",
|
||||
{
|
||||
"ignoreEOLComments": true
|
||||
}
|
||||
],
|
||||
"no-negated-in-lhs": "error",
|
||||
"no-new": "error",
|
||||
"no-new-require": "error",
|
||||
"block-scoped-var": "error",
|
||||
"no-use-before-define": "warn",
|
||||
"no-trailing-spaces": "error",
|
||||
"no-proto": "error",
|
||||
"complexity": [
|
||||
"warn",
|
||||
5
|
||||
],
|
||||
"wrap-iife": [
|
||||
"error",
|
||||
"outside"
|
||||
],
|
||||
"new-parens": "error",
|
||||
"space-infix-ops": "error",
|
||||
"eol-last": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"space-unary-ops": "error",
|
||||
"arrow-parens": [
|
||||
"error",
|
||||
"as-needed"
|
||||
],
|
||||
"arrow-spacing": "error",
|
||||
"space-before-blocks": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"yoda": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"space-before-function-paren": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"spaced-comment": [
|
||||
"error",
|
||||
"always"
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -10,7 +10,6 @@ before_install:
|
||||
- npm install -g prettier
|
||||
- npm install -g eslint
|
||||
script:
|
||||
- npm run linter
|
||||
- npm run extractor
|
||||
after_success:
|
||||
- chmod +x .travis/push.sh
|
||||
|
||||
12
config.js
12
config.js
@ -8,23 +8,13 @@ module.exports = {
|
||||
// Path information
|
||||
snippetPath: `snippets`,
|
||||
snippetDataPath: `snippet_data`,
|
||||
assetPath: `assets`,
|
||||
pagePath: `src/docs/pages`,
|
||||
staticPartsPath: `src/static-parts`,
|
||||
distPath: `dist`,
|
||||
testPath: `test`,
|
||||
// General information
|
||||
language: {
|
||||
short: `js`,
|
||||
long: `JavaScript`
|
||||
},
|
||||
// Module information
|
||||
moduleName: `_30s`,
|
||||
rollupInputFile: `imports.temp.js`,
|
||||
testModuleFile: `test/_30s.js`,
|
||||
// Requirable JSONs
|
||||
requirables: [
|
||||
`snippets.json`
|
||||
],
|
||||
parser: '_30codeParser',
|
||||
]
|
||||
};
|
||||
|
||||
1967
package-lock.json
generated
1967
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -26,12 +26,6 @@
|
||||
"homepage": "https://30secondsofcode.org/",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@30-seconds/integration-tools": "^1.3.4",
|
||||
"@babel/core": "^7.5.4",
|
||||
"@babel/preset-env": "^7.5.4",
|
||||
"eslint": "^5.16.0",
|
||||
"fs-extra": "^8.1.0",
|
||||
"kleur": "^3.0.3",
|
||||
"prettier": "^1.18.2"
|
||||
"@30-seconds/integration-tools": "^2.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,83 +0,0 @@
|
||||
/*
|
||||
This is the linter script that lints snippets.
|
||||
Run using `npm run linter`.
|
||||
You might have to run
|
||||
`npm i -g semistandard && npm i -g prettier`
|
||||
for this script to run properly.
|
||||
*/
|
||||
const fs = require('fs-extra');
|
||||
const cp = require('child_process');
|
||||
const path = require('path');
|
||||
const { green, red } = require('kleur');
|
||||
const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env;
|
||||
if (isTravisCI() && /^Travis build: \d+/g.test(process.env['TRAVIS_COMMIT_MESSAGE'])) {
|
||||
console.log(`${green('NOBUILD')} Linting terminated, parent commit is a Travis build!`);
|
||||
process.exit(0);
|
||||
}
|
||||
const SNIPPETS_PATH = './snippets';
|
||||
const TEMP_PATH = './temp';
|
||||
|
||||
const codeRE = /```\s*js([\s\S]*?)```/g;
|
||||
|
||||
console.time('Linter');
|
||||
|
||||
try {
|
||||
const snippets = fs
|
||||
.readdirSync(SNIPPETS_PATH)
|
||||
.sort((a, b) => a.toLowerCase() - b.toLowerCase())
|
||||
// turn it into an object so we can add data to it to be used in a different scope
|
||||
.map(name => ({ name }));
|
||||
|
||||
if (!fs.existsSync(TEMP_PATH))
|
||||
fs.mkdirSync(TEMP_PATH);
|
||||
|
||||
|
||||
for (const snippet of snippets) {
|
||||
snippet.data = fs.readFileSync(path.join(SNIPPETS_PATH, snippet.name), 'utf8');
|
||||
snippet.tempNames = [];
|
||||
snippet.code = [];
|
||||
|
||||
let match = codeRE.exec(snippet.data);
|
||||
// make a counter so we write the definition + example code blocks to different files
|
||||
let counter = 0;
|
||||
while (match) {
|
||||
snippet.code.push(match[1]); // capture group
|
||||
snippet.tempNames.push(snippet.name.replace('.md', counter++));
|
||||
match = codeRE.exec(snippet.data);
|
||||
}
|
||||
|
||||
snippet.code.forEach((str, i) => {
|
||||
fs.writeFileSync(`${TEMP_PATH}/${snippet.tempNames[i]}.js`, str);
|
||||
});
|
||||
}
|
||||
|
||||
const cmd =
|
||||
`prettier "${TEMP_PATH}/*.js" --single-quote --print-width=100 --write & ` +
|
||||
`eslint "${TEMP_PATH}/*.js" --quiet --fix --rule "no-undef: 0, no-unused-vars: 0, no-multiple-empty-lines: 0" -o eslint_errors.log -f table`;
|
||||
|
||||
cp.exec(cmd, {}, () => {
|
||||
// Loop through each snippet now that semistandard and prettier did their job
|
||||
for (const snippet of snippets) {
|
||||
// an array to store each linted code block (definition + example)
|
||||
const lintedCode = [];
|
||||
|
||||
for (const tempName of snippet.tempNames) {
|
||||
lintedCode.push(fs.readFileSync(`${TEMP_PATH}/${tempName}.js`, 'utf8'));
|
||||
fs.unlink(`${TEMP_PATH}/${tempName}.js`);
|
||||
}
|
||||
|
||||
// We replace each ```js ``` code block with the newly linted code
|
||||
let index = 0;
|
||||
snippet.data = snippet.data.replace(codeRE, () => '```js\n' + lintedCode[index++] + '```');
|
||||
|
||||
fs.writeFileSync(path.join(SNIPPETS_PATH, snippet.name), snippet.data);
|
||||
}
|
||||
|
||||
fs.removeSync(TEMP_PATH);
|
||||
console.log(`${green('SUCCESS!')} Snippet files linted!`);
|
||||
console.timeEnd('Linter');
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(`${red('ERROR!')} During linting: ${err}`);
|
||||
process.exit(1);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user