chore: update lint scripts

This commit is contained in:
Benjy Cui 2016-04-14 11:27:31 +08:00
parent 9d95313d03
commit 7a6485d1ab
9 changed files with 30 additions and 36 deletions

View File

@ -133,10 +133,10 @@
"deploy": "rm -rf node_modules && node scripts/install.js && npm run just-deploy",
"just-deploy": "npm run site && node scripts/deploy.js",
"lint": "npm run srclint && npm run demolint && npm run lesshint",
"srclint": "ANTD=SRC eslint components test site index.js --ext '.js,.jsx'",
"srclint": "ANTD=SRC eslint components test site scripts ./*.js --ext '.js,.jsx'",
"demolint": "ANTD=DEMO eslint components/*/demo/*.md --ext '.md'",
"lesshint": "lesshint style/ -e 'style/+(core|mixins)/+(base|iconfont|normalize|layouts|compatibility|grid).less'",
"eslint-fix": "eslint --fix components test site index.js --ext '.js,.jsx' && eslint-tinker ./components/*/demo/*.md",
"eslint-fix": "eslint --fix components test site scripts ./*.js --ext '.js,.jsx' && eslint-tinker ./components/*/demo/*.md",
"test": "npm run lint && atool-build && npm run jest",
"jest": "jest",
"pub": "sh ./scripts/publish.sh",

View File

@ -1,8 +1,5 @@
'use strict';
const fs = require('fs');
const path = require('path');
const R = require('ramda');
const utils = require('./utils');
module.exports = function buildCommon(dirs, outputFile) {

View File

@ -1,5 +1,3 @@
'use strict';
const fs = require('fs');
const path = require('path');
const R = require('ramda');
@ -23,10 +21,10 @@ module.exports = function buildDemosList(dirs, outputPath) {
Object.keys(groupedDemos).forEach((key) => {
content += `\n '${key}': [`;
groupedDemos[key].forEach((fileName) => {
const requirePath = path.relative(path.dirname(outputPath), fileName)
const requirePath = path.relative(path.dirname(outputPath), fileName);
content += `\n require('${requirePath}'),`;
});
content += '\n ],'
content += '\n ],';
});
content += '\n};\n';

View File

@ -1,7 +1,5 @@
#! /usr/bin/env node
'use strict';
// Ensure that data directory exist.
require('mkdirp').sync('./_data');

View File

@ -1,11 +1,11 @@
var ghPages = require('gh-pages');
var path = require('path');
const ghPages = require('gh-pages');
const path = require('path');
ghPages.publish(path.join(process.cwd(), '_site'), {
depth: 1,
logger: function (message) {
logger(message) {
console.log(message);
}
}, function (err) {
}, (err) => {
if (err) {
throw err;
}

View File

@ -1,23 +1,23 @@
function runCmd(cmd, args, fn) {
args = args || [];
var runner = require('child_process').spawn(cmd, args, {
const runner = require('child_process').spawn(cmd, args, {
// keep color
stdio: "inherit"
stdio: 'inherit'
});
runner.on('close', function (code) {
runner.on('close', (code) => {
if (fn) {
fn(code);
}
});
}
runCmd('which', ['tnpm'], function (code) {
var npm = 'npm';
runCmd('which', ['tnpm'], (code) => {
let npm = 'npm';
if (!code) {
npm = 'tnpm';
}
console.log(npm + ' installing');
runCmd(npm, ['install'], function () {
console.log(npm + ' install end');
console.log(`${npm} installing`);
runCmd(npm, ['install'], () => {
console.log(`${npm} install end`);
});
});
});

View File

@ -1,11 +1,11 @@
var fs = require('fs');
var cwd = process.cwd();
var path = require('path');
var originalIndex = fs.readFileSync(path.join(cwd, 'lib/index.js'), 'utf-8');
var newIndex = originalIndex
const fs = require('fs');
const cwd = process.cwd();
const path = require('path');
const originalIndex = fs.readFileSync(path.join(cwd, 'lib/index.js'), 'utf-8');
const newIndex = originalIndex
.replace(/\/components\//g, '/');
fs.writeFileSync(path.join(cwd, 'lib/index.js'), newIndex, 'utf-8');
var antdCss = path.join(cwd, 'dist/antd.css');
const antdCss = path.join(cwd, 'dist/antd.css');
fs.createReadStream(antdCss)
.pipe(fs.createWriteStream(path.join(cwd, 'lib/index.css')));
console.log('prenpm done');

View File

@ -1,9 +1,9 @@
'use strict';
const fs = require('fs');
const path = require('path');
const R = require('ramda');
function noop() {}
const isMDFile = R.compose(R.equals('.md'), path.extname);
exports.findMDFile = function findMDFile(fileName, shallow) {
const filePaths = Array.isArray(fileName) ? fileName : [fileName];
@ -19,7 +19,7 @@ exports.findMDFile = function findMDFile(fileName, shallow) {
let hasIndexFile = false;
try {
hasIndexFile = fs.statSync(indexFile).isFile();
} catch (e) {}
} catch (e) { noop(); }
if (shallow && hasIndexFile) {
mds.push(indexFile);
@ -34,6 +34,7 @@ exports.findMDFile = function findMDFile(fileName, shallow) {
return mds;
};
/* eslint prefer-template: 0 */
exports.stringify = function stringify(data, d) {
const depth = d || 1;
const indent = ' '.repeat(depth);

View File

@ -1,6 +1,6 @@
const webpack = require('atool-build/lib/webpack');
module.exports = function(webpackConfig) {
module.exports = function (webpackConfig) {
// remove common.js
webpackConfig.plugins = webpackConfig.plugins.filter((plugin) => {
return !(plugin instanceof webpack.optimize.CommonsChunkPlugin);
@ -38,7 +38,7 @@ module.exports = function(webpackConfig) {
webpackConfig.module.loaders.push({
test: /\.md$/,
exclude: [/node_modules/, componentRegExp],
loader: `babel!antd-md`,
loader: 'babel!antd-md',
});
}
}
@ -49,7 +49,7 @@ module.exports = function(webpackConfig) {
'antd.min': entry,
};
webpackConfig.externals = {
'react': {
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',