Skip to content

Commit

Permalink
Use prettier for code formatting (#847)
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 authored Dec 1, 2021
1 parent d6b09b1 commit aed6ba0
Show file tree
Hide file tree
Showing 22 changed files with 161 additions and 108 deletions.
18 changes: 4 additions & 14 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
module.exports = {
root: true,
extends: [
'simplabs',
'simplabs/plugins/ember',
],
extends: ['simplabs', 'simplabs/plugins/ember', 'plugin:prettier/recommended'],
rules: {
'ember/avoid-leaking-state-in-components': 'off',
'ember/local-modules': 'off',
Expand All @@ -21,12 +18,7 @@ module.exports = {
'config/**/*.js',
'tests/dummy/config/**/*.js',
],
excludedFiles: [
'addon/**',
'addon-test-support/**',
'app/**',
'tests/dummy/app/**',
],
excludedFiles: ['addon/**', 'addon-test-support/**', 'app/**', 'tests/dummy/app/**'],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2015,
Expand All @@ -38,12 +30,10 @@ module.exports = {
},
// node test files
{
files: [
'node-tests/*.js',
],
files: ['node-tests/*.js'],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2015
ecmaVersion: 2015,
},
env: {
browser: false,
Expand Down
8 changes: 8 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

module.exports = {
arrowParens: 'avoid',
printWidth: 100,
singleQuote: true,
trailingComma: 'es5',
};
30 changes: 15 additions & 15 deletions config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

const getChannelURL = require('ember-source-channel-url');

module.exports = function() {
module.exports = function () {
return Promise.all([
getChannelURL('release'),
getChannelURL('beta'),
getChannelURL('canary'),
]).then((urls) => {
]).then(urls => {
return {
usePnpm: true,
command: 'pnpm test',
Expand Down Expand Up @@ -67,33 +67,33 @@ module.exports = function() {
name: 'ember-release',
npm: {
devDependencies: {
'ember-source': urls[0]
}
}
'ember-source': urls[0],
},
},
},
{
name: 'ember-beta',
npm: {
devDependencies: {
'ember-source': urls[1]
}
}
'ember-source': urls[1],
},
},
},
{
name: 'ember-canary',
npm: {
devDependencies: {
'ember-source': urls[2]
}
}
'ember-source': urls[2],
},
},
},
{
name: 'ember-default',
npm: {
devDependencies: {}
}
}
]
devDependencies: {},
},
},
],
};
});
};
4 changes: 2 additions & 2 deletions config/environment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-env node */
'use strict';

module.exports = function(/* environment, appConfig */) {
return { };
module.exports = function (/* environment, appConfig */) {
return {};
};
7 changes: 1 addition & 6 deletions config/targets.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
/* eslint-env node */

module.exports = {
browsers: [
'ie 9',
'last 1 Chrome versions',
'last 1 Firefox versions',
'last 1 Safari versions',
],
browsers: ['ie 9', 'last 1 Chrome versions', 'last 1 Firefox versions', 'last 1 Safari versions'],
};
6 changes: 3 additions & 3 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

module.exports = function(defaults) {
module.exports = function (defaults) {
let stripTestSelectors = process.env['STRIP_TEST_SELECTORS'];

let app = new EmberAddon(defaults, {
Expand All @@ -13,8 +13,8 @@ module.exports = function(defaults) {
},

'ember-test-selectors': {
strip: Boolean(stripTestSelectors)
}
strip: Boolean(stripTestSelectors),
},
});

/*
Expand Down
36 changes: 25 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,26 @@ module.exports = {
let addonOptions = appOptions['ember-test-selectors'] || {};

if (addonOptions.environments) {
ui.writeDeprecateLine('The "environments" option in "ember-test-selectors" has been replaced ' +
'with the "strip" option. Use e.g. "strip: EmberApp.env() === \'production\'" instead to ' +
'recreate the old behavior.', false);

this._stripTestSelectors = (addonOptions.environments.indexOf(app.env) !== -1);
ui.writeDeprecateLine(
'The "environments" option in "ember-test-selectors" has been replaced ' +
'with the "strip" option. Use e.g. "strip: EmberApp.env() === \'production\'" instead to ' +
'recreate the old behavior.',
false
);

this._stripTestSelectors = addonOptions.environments.indexOf(app.env) !== -1;
} else if ('strip' in addonOptions) {
this._stripTestSelectors = addonOptions.strip;
} else {
this._stripTestSelectors = !app.tests;
}

if ('patchClassicComponent' in addonOptions) {
ui.writeDeprecateLine('[ember-test-selectors] The `patchClassicComponent` option is obsolete. ' +
'You can remove it from your `ember-cli-build.js` file.', false);
ui.writeDeprecateLine(
'[ember-test-selectors] The `patchClassicComponent` option is obsolete. ' +
'You can remove it from your `ember-cli-build.js` file.',
false
);
}
},

Expand Down Expand Up @@ -65,10 +71,14 @@ module.exports = {
if (checker.satisfies('^6.0.0-beta.1') || checker.satisfies('^7.0.0')) {
appOrParent.options.babel6 = appOrParent.options.babel6 || {};
appOrParent.options.babel6.plugins = appOrParent.options.babel6.plugins || [];
appOrParent.options.babel6.plugins.push(require.resolve('./strip-data-test-properties-plugin6'));
appOrParent.options.babel6.plugins.push(
require.resolve('./strip-data-test-properties-plugin6')
);
} else {
this.ui.writeWarnLine('ember-test-selectors: You are using an unsupported ember-cli-babel version. data-test ' +
'properties are not automatically stripped from your JS code.');
this.ui.writeWarnLine(
'ember-test-selectors: You are using an unsupported ember-cli-babel version. data-test ' +
'properties are not automatically stripped from your JS code.'
);
}

this._registeredWithBabel = true;
Expand All @@ -88,7 +98,11 @@ module.exports = {
// remove the unit tests if we're testing ourself and are in strip mode.
// we do this because these tests depend on the "addon" and "app" folders being available,
// which is not the case if they are stripped out of the build.
if (type === 'test' && this._stripTestSelectors && this.project.name() === 'ember-test-selectors') {
if (
type === 'test' &&
this._stripTestSelectors &&
this.project.name() === 'ember-test-selectors'
) {
tree = require('broccoli-stew').rm(tree, 'dummy/tests/unit/**/*.js');
}
return tree;
Expand Down
2 changes: 1 addition & 1 deletion node-tests/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
env: {
mocha: true
mocha: true,
},
};
5 changes: 2 additions & 3 deletions node-tests/strip-data-test-properties-plugin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let babel7 = require('@babel/core');
let StripDataTestPropertiesPlugin6 = require('../strip-data-test-properties-plugin6');

function testFixture(name) {
it(`fixture: ${name}`, function() {
it(`fixture: ${name}`, function () {
let fixturePath = `${__dirname}/fixtures/${name}/fixture.js`;
let expectedPath = `${__dirname}/fixtures/${name}/expected7.js`;

Expand All @@ -20,7 +20,6 @@ function testFixture(name) {
});
}

describe('StripDataTestProperties plugin', function() {
describe('StripDataTestProperties plugin', function () {
testFixture('default');
});

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@
"ember-source-channel-url": "3.0.0",
"ember-try": "2.0.0",
"eslint": "8.3.0",
"eslint-config-prettier": "8.3.0",
"eslint-config-simplabs": "0.4.0",
"eslint-plugin-ember": "10.5.8",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-qunit": "7.1.0",
"lerna-changelog": "2.2.0",
"loader.js": "4.7.0",
"mocha": "9.1.3",
"prettier": "2.5.0",
"qunit": "2.17.2",
"qunit-dom": "2.0.0",
"release-it": "14.11.8",
Expand Down
49 changes: 49 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions strip-data-test-properties-plugin6.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ function StripDataTestPropertiesPlugin() {
};
}

StripDataTestPropertiesPlugin.baseDir = function() {
StripDataTestPropertiesPlugin.baseDir = function () {
return __dirname;
};

StripDataTestPropertiesPlugin.cacheKey = function() {
StripDataTestPropertiesPlugin.cacheKey = function () {
return 'ember-test-selectors.strip-data-test-properties';
};

Expand Down
Loading

0 comments on commit aed6ba0

Please sign in to comment.