Browse Source

Merge pull request #3209 from chicoxyzzy/eslint-everywhere

lint from root
main
Paul O’Shannessy 10 years ago
parent
commit
6460227d05
  1. 3
      _js/examples/.eslintrc
  2. 12
      extractCode.js

3
_js/examples/.eslintrc

@ -0,0 +1,3 @@
rules:
block-scoped-var: false
no-undef: false

12
extractCode.js

@ -1,3 +1,5 @@
'use strict';
var argv = require('optimist').argv; var argv = require('optimist').argv;
var fs = require('fs'); var fs = require('fs');
@ -5,9 +7,9 @@ var CODE_SAMPLE = /```[\S]+\s*[\s\S]*?```/g;
var PARTS = /```[\S]+\s*\/\/\s+(.+?)\n([\s\S]*?)```/; var PARTS = /```[\S]+\s*\/\/\s+(.+?)\n([\s\S]*?)```/;
function truncate(s, n) { function truncate(s, n) {
n = n || 256 n = n || 256;
if (s.length < n) { if (s.length < n) {
return s; return s;
} }
return s.substring(0, n) + '...'; return s.substring(0, n) + '...';
} }
@ -27,9 +29,9 @@ function main(dest, filenames) {
if (!extracted) { if (!extracted) {
throw new Error('Code sample did not match correct format in ' + filename + ': ' + truncate(codeSample)); throw new Error('Code sample did not match correct format in ' + filename + ': ' + truncate(codeSample));
} }
var filename = extracted[1]; var codeSampleFilename = extracted[1];
var content = extracted[2].replace(/\*\*/g, ''); var codeSampleContent = extracted[2].replace(/\*\*/g, '');
fs.writeFileSync(argv.dest + '/' + filename, content); fs.writeFileSync(argv.dest + '/' + codeSampleFilename, codeSampleContent);
}); });
}); });
} }

Loading…
Cancel
Save