mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-08 05:34:23 +08:00
feat(babel6): Initial babel conversion
This commit is contained in:
parent
bbdfa85547
commit
8db8722f74
14 changed files with 120 additions and 22 deletions
|
@ -1,7 +1,6 @@
|
|||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
os = require 'os'
|
||||
babelOptions = require '../static/babelrc'
|
||||
|
||||
# This is the main Gruntfile that manages building N1 distributions.
|
||||
# The reason it's inisde of the build/ folder is so everything can be
|
||||
|
@ -51,12 +50,10 @@ _.extend(global, require('harmony-collections')) unless global.WeakMap?
|
|||
module.exports = (grunt) ->
|
||||
grunt.loadNpmTasks('grunt-coffeelint-cjsx')
|
||||
grunt.loadNpmTasks('grunt-lesslint')
|
||||
grunt.loadNpmTasks('grunt-babel')
|
||||
grunt.loadNpmTasks('grunt-cson')
|
||||
grunt.loadNpmTasks('grunt-contrib-csslint')
|
||||
grunt.loadNpmTasks('grunt-coffee-react')
|
||||
grunt.loadNpmTasks('grunt-contrib-coffee')
|
||||
grunt.loadNpmTasks('grunt-eslint')
|
||||
grunt.loadNpmTasks('grunt-contrib-less')
|
||||
grunt.loadNpmTasks('grunt-shell')
|
||||
grunt.loadNpmTasks('grunt-markdown')
|
||||
|
@ -129,7 +126,7 @@ module.exports = (grunt) ->
|
|||
ext: '.js'
|
||||
|
||||
babelConfig =
|
||||
options: babelOptions
|
||||
options: require("../static/babelrc")
|
||||
dist:
|
||||
files: [{
|
||||
expand: true
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"parser": "babel-eslint",
|
||||
"extends": "airbnb",
|
||||
"globals": {
|
||||
"NylasEnv": false,
|
||||
|
@ -28,6 +29,5 @@
|
|||
"no-shadow": [1],
|
||||
"quotes": [0],
|
||||
"semi": [0]
|
||||
},
|
||||
"parser": "babel-eslint"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,19 +8,19 @@
|
|||
"dependencies": {
|
||||
"asar": "^0.10",
|
||||
"async": "~0.2.9",
|
||||
"babel-eslint": "^4.1.3",
|
||||
"babel-eslint": "6.x.x",
|
||||
"bluebird": "^3.0",
|
||||
"chalk": "1.x.x",
|
||||
"coffee-react-transform": "^3.1.0",
|
||||
"coffeelint-cjsx": "^2.0",
|
||||
"donna": "1.0.10",
|
||||
"escope": "3.3.0",
|
||||
"eslint": "^1.5.1",
|
||||
"eslint-config-airbnb": "^0.1.0",
|
||||
"eslint-plugin-react": "^3.4.2",
|
||||
"eslint": "2.x.x",
|
||||
"eslint-config-airbnb": "8.x.x",
|
||||
"eslint-plugin-react": "5.x.x",
|
||||
"fs-plus": "2.x",
|
||||
"github-releases": "~0.3.0",
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-babel": "^5.0.1",
|
||||
"grunt-cli": "~0.1.9",
|
||||
"grunt-coffee-react": "^2.1.0",
|
||||
"grunt-coffeelint": "git+https://github.com/atom/grunt-coffeelint.git#cfb99aa99811d52687969532bd5a98011ed95bfe",
|
||||
|
@ -31,7 +31,6 @@
|
|||
"grunt-cson": "0.14.0",
|
||||
"grunt-download-electron": "^2.1",
|
||||
"grunt-electron-installer": "1.2.1",
|
||||
"grunt-eslint": "^17.3.1",
|
||||
"grunt-lesslint": "0.13.0",
|
||||
"grunt-markdown": "^0.7.0",
|
||||
"grunt-peg": "~1.1.0",
|
||||
|
|
38
build/tasks/babel-task.es6
Normal file
38
build/tasks/babel-task.es6
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Copied from https://github.com/babel/grunt-babel to ensure we always
|
||||
// use the `babel-core` defined in our own package.json as opposed to the
|
||||
// grunt-babel dependency's
|
||||
|
||||
const path = require('path');
|
||||
const babel = require('babel-core');
|
||||
|
||||
module.exports = function babelTask(grunt) {
|
||||
grunt.registerMultiTask('babel', 'Use next generation JavaScript, today', () => {
|
||||
const options = this.options();
|
||||
|
||||
this.files.forEach((el) => {
|
||||
delete options.filename;
|
||||
delete options.filenameRelative;
|
||||
|
||||
options.sourceFileName = path.relative(path.dirname(el.dest), el.src[0]);
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
options.sourceFileName = options.sourceFileName.replace(/\\/g, '/');
|
||||
}
|
||||
|
||||
options.sourceMapTarget = path.basename(el.dest);
|
||||
|
||||
const res = babel.transformFileSync(el.src[0], options);
|
||||
let sourceMappingURL = '';
|
||||
|
||||
if (res.map) {
|
||||
sourceMappingURL = `\n//# sourceMappingURL=${path.basename(el.dest)}.map`;
|
||||
}
|
||||
|
||||
grunt.file.write(el.dest, `${res.code}${sourceMappingURL}\n`);
|
||||
|
||||
if (res.map) {
|
||||
grunt.file.write(`${el.dest}.map`, JSON.stringify(res.map));
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
71
build/tasks/eslint-task.es6
Normal file
71
build/tasks/eslint-task.es6
Normal file
|
@ -0,0 +1,71 @@
|
|||
// Copied from https://github.com/sindresorhus/grunt-eslint
|
||||
// So we can use our own eslint instead of this tasks's dependency.
|
||||
const chalk = require('chalk');
|
||||
const eslint = require('eslint');
|
||||
|
||||
module.exports = function eslintTask(grunt) {
|
||||
grunt.registerMultiTask('eslint', 'Validate files with ESLint', () => {
|
||||
const opts = this.options({
|
||||
outputFile: false,
|
||||
quiet: false,
|
||||
maxWarnings: -1,
|
||||
});
|
||||
|
||||
// legacy
|
||||
// TODO: remove in the future
|
||||
if (opts.config) {
|
||||
opts.configFile = opts.config;
|
||||
}
|
||||
if (opts.rulesdir) {
|
||||
opts.rulePaths = opts.rulesdir;
|
||||
}
|
||||
|
||||
if (this.filesSrc.length === 0) {
|
||||
grunt.log.writeln(chalk.magenta('Could not find any files to validate.'));
|
||||
return true;
|
||||
}
|
||||
|
||||
const formatter = eslint.CLIEngine.getFormatter(opts.format);
|
||||
|
||||
if (!formatter) {
|
||||
grunt.warn(`Could not find formatter ${opts.format}'.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
const engine = new eslint.CLIEngine(opts);
|
||||
|
||||
let report;
|
||||
try {
|
||||
report = engine.executeOnFiles(this.filesSrc);
|
||||
} catch (err) {
|
||||
grunt.warn(err);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (opts.fix) {
|
||||
eslint.CLIEngine.outputFixes(report);
|
||||
}
|
||||
|
||||
let results = report.results;
|
||||
|
||||
if (opts.quiet) {
|
||||
results = eslint.CLIEngine.getErrorResults(results);
|
||||
}
|
||||
|
||||
const output = formatter(results);
|
||||
|
||||
if (opts.outputFile) {
|
||||
grunt.file.write(opts.outputFile, output);
|
||||
} else if (output) {
|
||||
console.log(output);
|
||||
}
|
||||
|
||||
const tooManyWarnings = opts.maxWarnings >= 0 && report.warningCount > opts.maxWarnings;
|
||||
|
||||
if (report.errorCount === 0 && tooManyWarnings) {
|
||||
grunt.warn(`ESLint found too many warnings (maximum:${opts.maxWarnings})`);
|
||||
}
|
||||
|
||||
return report.errorCount === 0;
|
||||
});
|
||||
};
|
|
@ -1,5 +1,3 @@
|
|||
/** @babel */
|
||||
|
||||
import _ from 'underscore'
|
||||
import React from 'react';
|
||||
import {Actions, FocusedContactsStore} from 'nylas-exports'
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/** @babel */
|
||||
import _ from 'underscore'
|
||||
import React from 'react'
|
||||
import {shell} from 'electron'
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/** @babel */
|
||||
import React, {Component, PropTypes} from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import {Actions, FocusedPerspectiveStore} from 'nylas-exports';
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/** @babel */
|
||||
import _ from 'underscore';
|
||||
import React, {Component, PropTypes} from 'react';
|
||||
import {DateUtils, Actions} from 'nylas-exports'
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"electronVersion": "0.37.8",
|
||||
"dependencies": {
|
||||
"async": "^0.9",
|
||||
"babel-core": "^5.8.21",
|
||||
"babel-core": "6.8.x",
|
||||
"bluebird": "^2.9",
|
||||
"chrono-node": "^1.1.2",
|
||||
"classnames": "1.2.1",
|
||||
|
|
2
spec_integration/jasmine/bootstrap.js
vendored
2
spec_integration/jasmine/bootstrap.js
vendored
|
@ -3,7 +3,7 @@
|
|||
// argv[2] = JASMINE_CONFIG_PATH=./jasmine/config.json
|
||||
// argv[3] = NYLAS_ROOT_PATH=/path/to/nylas/root
|
||||
var babelOptions = require('../../static/babelrc.json');
|
||||
require('babel-core/register')(babelOptions);
|
||||
require('babel-register')(babelOptions);
|
||||
|
||||
var chalk = require('chalk')
|
||||
var util = require('util')
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
},
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"babel-register": "6.8.x",
|
||||
"bluebird": "^3.0.5",
|
||||
"babel-core": "^5.8.21",
|
||||
"jasmine": "^2.3.2",
|
||||
"spectron": "^0.34.1",
|
||||
"chalk": "^1.1"
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/** @babel */
|
||||
import moment from 'moment'
|
||||
|
||||
import React from 'react'
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/** @babel */
|
||||
import moment from 'moment'
|
||||
import chrono from 'chrono-node'
|
||||
import _ from 'underscore'
|
||||
|
|
Loading…
Add table
Reference in a new issue