Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prettier to linting configuration. #16440

Merged
merged 4 commits into from
Mar 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 5 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ module.exports = {
root: true,
extends: [
'eslint:recommended',
'prettier',
],
plugins: [
"ember-internal"
'ember-internal',
'prettier',
],

rules: {
'semi': 'error',
'no-unused-vars': 'error',
'no-useless-escape': 'off', // TODO: bring this back
'prettier/prettier': 'error',
},

overrides: [
Expand All @@ -23,7 +26,7 @@ module.exports = {
},

globals: {
// A safe subset of "browser:true":
// A safe subset of 'browser:true':
'window': true,
'document': true,
'setTimeout': true,
Expand Down
7 changes: 7 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

module.exports = {
singleQuote: true,
trailingComma: 'es5',
printWidth: 100,
};
21 changes: 14 additions & 7 deletions bin/build-for-publishing.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ function updatePackageJSONVersion() {
pkg._versionPreviouslyCalculated = true;
pkg._originalVersion = pkg.version;
pkg.version = VERSION;
fs.writeFileSync(packageJSONPath, JSON.stringify(pkg, null, 2), { encoding: 'utf-8' });
fs.writeFileSync(packageJSONPath, JSON.stringify(pkg, null, 2), {
encoding: 'utf-8'
});
}

/*
Expand All @@ -43,11 +45,12 @@ function updateDocumentationVersion() {
let contents = fs.readFileSync(docsPath, { encoding: 'utf-8' });
let docs = JSON.parse(contents);
docs.project.version = VERSION;
fs.writeFileSync(docsPath, JSON.stringify(docs, null, 2), { encoding: 'utf-8' });
fs.writeFileSync(docsPath, JSON.stringify(docs, null, 2), {
encoding: 'utf-8'
});
}

Promise
.resolve()
Promise.resolve()
.then(() => {
updatePackageJSONVersion();
// ensures that we tag this correctly
Expand All @@ -69,9 +72,13 @@ Promise
version: VERSION,
buildType: process.env.BUILD_TYPE,
SHA: process.env.TRAVIS_COMMIT,
assetPath: `/${process.env.BUILD_TYPE}/shas/${process.env.TRAVIS_COMMIT}.tgz`,
assetPath: `/${process.env.BUILD_TYPE}/shas/${
process.env.TRAVIS_COMMIT
}.tgz`
};
fs.writeFileSync('build-metadata.json', JSON.stringify(metadata, null, 2), { encoding: 'utf-8' });
fs.writeFileSync('build-metadata.json', JSON.stringify(metadata, null, 2), {
encoding: 'utf-8'
});

// using npm pack here because `yarn pack` does not honor the `package.json`'s `files`
// property properly, and therefore the tarball generated is quite large (~7MB).
Expand All @@ -80,7 +87,7 @@ Promise
.then(
// eslint-disable-next-line
() => console.log('build-for-publishing completed succesfully!'),
(error) => {
error => {
// eslint-disable-next-line
console.error(error);
// eslint-disable-next-line
Expand Down
2 changes: 1 addition & 1 deletion bin/feature-flag-yuidoc-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function updateClassReferencesInNamespaces(data) {
}
}

module.exports = function (data) {
module.exports = function(data) {
var featuresToFilter = gatherFeatures();
data.classes = gatherClassesToDocument(data, featuresToFilter);
updateClassReferencesInNamespaces(data);
Expand Down
21 changes: 13 additions & 8 deletions bin/publish_to_s3.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

// To invoke this from the commandline you need the following to env vars to exist:
//
// S3_BUCKET_NAME
Expand All @@ -14,17 +13,23 @@
// ./bin/publish_to_s3.js
// ```
var S3Publisher = require('ember-publisher');
var configPath = require('path').join(__dirname, '../config/s3ProjectConfig.js');
var configPath = require('path').join(
__dirname,
'../config/s3ProjectConfig.js'
);

var publisher = new S3Publisher({ projectConfigPath: configPath });

publisher.currentBranch = function() {
return process.env.BUILD_TYPE || {
master: 'canary',
beta: 'beta',
release: 'release',
'lts-2-4': 'lts-2-4',
}[this.CURRENT_BRANCH];
return (
process.env.BUILD_TYPE ||
{
master: 'canary',
beta: 'beta',
release: 'release',
'lts-2-4': 'lts-2-4'
}[this.CURRENT_BRANCH]
);
};

publisher.publish();
18 changes: 13 additions & 5 deletions bin/run-browserstack-tests.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

/* eslint-disable no-console */

var RSVP = require('rsvp');
var RSVP = require('rsvp');
var spawn = require('child_process').spawn;

function run(command, _args) {
Expand Down Expand Up @@ -36,13 +35,21 @@ function run(command, _args) {

RSVP.resolve()
.then(function() {
return run('./node_modules/.bin/ember', [ 'browserstack:connect' ]);
return run('./node_modules/.bin/ember', ['browserstack:connect']);
})
.then(function() {
// Calling testem directly here instead of `ember test` so that
// we do not have to do a double build (by the time this is run
// we have already ran `ember build`).
return run('./node_modules/.bin/testem', [ 'ci', '-f', 'testem.dist.js', '--host', '127.0.0.1', '--port', '7774' ]);
return run('./node_modules/.bin/testem', [
'ci',
'-f',
'testem.dist.js',
'--host',
'127.0.0.1',
'--port',
'7774'
]);
})
.finally(function() {
var promise = RSVP.resolve();
Expand All @@ -57,7 +64,8 @@ RSVP.resolve()
console.log('error');
console.log(error);
process.exit(1);
}).then(function() {
})
.then(function() {
console.log('success');
process.exit(0);
});
69 changes: 42 additions & 27 deletions bin/run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'use strict';

var execa = require('execa');
var RSVP = require('rsvp');
var RSVP = require('rsvp');
var execFile = require('child_process').execFile;
var chalk = require('chalk');
var FEATURES = require('../broccoli/features');
Expand All @@ -16,7 +16,7 @@ var http = require('http');
var serveStatic = require('serve-static');

// Serve up public/ftp folder.
var serve = serveStatic('./dist/', { 'index': ['index.html', 'index.htm'] });
var serve = serveStatic('./dist/', { index: ['index.html', 'index.htm'] });

// Create server.
var server = http.createServer(function(req, res) {
Expand All @@ -36,7 +36,7 @@ function run(queryString) {
}

function runInBrowser(url, retries, resolve, reject) {
var result = {output: [], errors: [], code: null};
var result = { output: [], errors: [], code: null };

console.log('Running Chrome headless: ' + url);

Expand Down Expand Up @@ -71,7 +71,7 @@ function runInBrowser(url, retries, resolve, reject) {
var testsFailed = 0;
var currentTestAssertions = [];

QUnit.log(function (details) {
QUnit.log(function(details) {
var response;

// Ignore passing assertions
Expand All @@ -86,7 +86,11 @@ function runInBrowser(url, retries, resolve, reject) {
response += ', ';
}

response += 'expected: ' + details.expected + ', but was: ' + details.actual;
response +=
'expected: ' +
details.expected +
', but was: ' +
details.actual;
}

if (details.source) {
Expand All @@ -96,10 +100,10 @@ function runInBrowser(url, retries, resolve, reject) {
currentTestAssertions.push('Failed assertion: ' + response);
});

QUnit.testDone(function (result) {
QUnit.testDone(function(result) {
var i,
len,
name = '';
len,
name = '';

if (result.module) {
name += result.module + ': ';
Expand All @@ -122,13 +126,24 @@ function runInBrowser(url, retries, resolve, reject) {
currentTestAssertions.length = 0;
});

QUnit.done(function (result) {
console.log('\n' + 'Took ' + result.runtime + 'ms to run ' + testsTotal + ' tests. ' + testsPassed + ' passed, ' + testsFailed + ' failed.');
QUnit.done(function(result) {
console.log(
'\n' +
'Took ' +
result.runtime +
'ms to run ' +
testsTotal +
' tests. ' +
testsPassed +
' passed, ' +
testsFailed +
' failed.'
);

if (typeof window.callPhantom === 'function') {
window.callPhantom({
'name': 'QUnit.done',
'data': result
name: 'QUnit.done',
data: result
});
}
});
Expand All @@ -141,7 +156,9 @@ function runInBrowser(url, retries, resolve, reject) {
var failed = !result || !result.total || result.failed;

if (!result.total) {
console.error('No tests were executed. Are you loading tests asynchronously?');
console.error(
'No tests were executed. Are you loading tests asynchronously?'
);
}

var code = failed ? 1 : 0;
Expand All @@ -153,11 +170,15 @@ function runInBrowser(url, retries, resolve, reject) {
console.log(chalk.red('Browser crashed with exit code ' + code));

if (retries > 1) {
console.log(chalk.yellow('Retrying... ¯\_(ツ)_/¯'));
console.log(chalk.yellow('Retrying... ¯_(ツ)_/¯'));
runInBrowser(url, retries - 1, resolve, reject);
} else {
console.log(chalk.red('Giving up! (╯°□°)╯︵ ┻━┻'));
console.log(chalk.yellow('This might be a known issue with Chrome headless, skipping for now'));
console.log(
chalk.yellow(
'This might be a known issue with Chrome headless, skipping for now'
)
);
resolve(result);
}
} else {
Expand All @@ -180,7 +201,9 @@ function generateEachPackageTests() {
var packages = getPackages(features);

Object.keys(packages).forEach(function(packageName) {
if (packages[packageName].skipTests) { return; }
if (packages[packageName].skipTests) {
return;
}

testFunctions.push(function() {
return run('package=' + packageName);
Expand All @@ -196,7 +219,6 @@ function generateEachPackageTests() {
testFunctions.push(function() {
return run('package=' + packageName + '&enableoptionalfeatures=true');
});

});
}

Expand Down Expand Up @@ -253,19 +275,13 @@ function runChecker(bin, args) {

function codeQualityChecks() {
var checkers = [
runChecker('node', [
require.resolve('typescript/bin/tsc'),
'--noEmit'
]),
runChecker('node', [require.resolve('typescript/bin/tsc'), '--noEmit']),
runChecker('node', [
require.resolve('tslint/bin/tslint'),
'-p',
'tsconfig.json'
]),
runChecker('node', [
require.resolve('eslint/bin/eslint'),
'.'
])
runChecker('node', [require.resolve('eslint/bin/eslint'), '.'])
];
return RSVP.Promise.all(checkers).then(function(results) {
results.forEach(result => {
Expand All @@ -276,7 +292,7 @@ function codeQualityChecks() {
}
});
if (!results.every(result => result.ok)) {
throw new Error("Some quality checks failed");
throw new Error('Some quality checks failed');
}
});
}
Expand All @@ -293,7 +309,6 @@ function runAndExit() {
});
}


switch (process.env.TEST_SUITE) {
case 'built-tests':
console.log('suite: built-tests');
Expand Down
12 changes: 8 additions & 4 deletions bin/run-travis-browser-tests.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

/* eslint-disable no-console */

var RSVP = require('rsvp');
var RSVP = require('rsvp');
var spawn = require('child_process').spawn;

function run(command, _args) {
Expand Down Expand Up @@ -35,13 +34,18 @@ function run(command, _args) {
});
}


RSVP.resolve()
.then(function() {
return run('./node_modules/.bin/testem', ['launchers']);
})
.then(function() {
return run('./node_modules/.bin/testem', ['ci', '--file', 'testem.travis-browsers.js', '--port', '7000']);
return run('./node_modules/.bin/testem', [
'ci',
'--file',
'testem.travis-browsers.js',
'--port',
'7000'
]);
})
.catch(function(error) {
console.error(error.stack);
Expand Down
Loading