From 3fcd3824b34eae0994ef2efd58d32eb76f726275 Mon Sep 17 00:00:00 2001 From: chico Date: Fri, 20 Feb 2015 04:06:15 +0300 Subject: [PATCH] lint from root --- _js/examples/.eslintrc | 3 +++ extractCode.js | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 _js/examples/.eslintrc diff --git a/_js/examples/.eslintrc b/_js/examples/.eslintrc new file mode 100644 index 00000000..225d7850 --- /dev/null +++ b/_js/examples/.eslintrc @@ -0,0 +1,3 @@ +rules: + block-scoped-var: false + no-undef: false \ No newline at end of file diff --git a/extractCode.js b/extractCode.js index 1425065a..867118eb 100644 --- a/extractCode.js +++ b/extractCode.js @@ -1,3 +1,5 @@ +'use strict'; + var argv = require('optimist').argv; var fs = require('fs'); @@ -5,9 +7,9 @@ var CODE_SAMPLE = /```[\S]+\s*[\s\S]*?```/g; var PARTS = /```[\S]+\s*\/\/\s+(.+?)\n([\s\S]*?)```/; function truncate(s, n) { - n = n || 256 + n = n || 256; if (s.length < n) { - return s; + return s; } return s.substring(0, n) + '...'; } @@ -27,9 +29,9 @@ function main(dest, filenames) { if (!extracted) { throw new Error('Code sample did not match correct format in ' + filename + ': ' + truncate(codeSample)); } - var filename = extracted[1]; - var content = extracted[2].replace(/\*\*/g, ''); - fs.writeFileSync(argv.dest + '/' + filename, content); + var codeSampleFilename = extracted[1]; + var codeSampleContent = extracted[2].replace(/\*\*/g, ''); + fs.writeFileSync(argv.dest + '/' + codeSampleFilename, codeSampleContent); }); }); }