Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
Merge pull request #47 from PrecisionNutrition/use-prettier
Browse files Browse the repository at this point in the history
Use Prettier
  • Loading branch information
jherdman committed Dec 22, 2020
2 parents b8a46c7 + a6567fe commit 45857df
Show file tree
Hide file tree
Showing 22 changed files with 510 additions and 264 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# dependencies
/bower_components/
/node_modules/
/.nix-node/

# misc
/coverage/
Expand Down
18 changes: 4 additions & 14 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,14 @@ module.exports = {
legacyDecorators: true,
},
},
plugins: [
'ember',
],
extends: [
'eslint:recommended',
'plugin:ember/recommended',
'@precision-nutrition',
],
plugins: ['ember'],
extends: ['eslint:recommended', 'plugin:ember/recommended', 'plugin:prettier/recommended'],
env: {
browser: true,
},
rules: {
'ember/no-jquery': 'error',
'prettier/prettier': 'error',
},
overrides: [
// node files
Expand All @@ -37,12 +32,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',
},
Expand Down
29 changes: 29 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/.circleci/
/.env*
/.pnp*
/.sass-cache
/connect.lock
/coverage/
/libpeerconnection.log
/npm-debug.log*
/testem.log
/yarn-error.log

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try

/**/*.hbs
/**/*.html
/jsconfig.json
/package.json
3 changes: 1 addition & 2 deletions .template-lintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const pending = [
];
const pending = [];

module.exports = {
extends: 'octane',
Expand Down
22 changes: 11 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

## Installation

* `git clone <repository-url>`
* `cd my-addon`
* `npm install`
- `git clone <repository-url>`
- `cd my-addon`
- `npm install`

## Linting

* `npm run lint:hbs`
* `npm run lint:js`
* `npm run lint:js -- --fix`
- `npm run lint:hbs`
- `npm run lint:js`
- `npm run lint:js -- --fix`

## Running tests

* `ember test` – Runs the test suite on the current Ember version
* `ember test --server` – Runs the test suite in "watch mode"
* `ember try:each` – Runs the test suite against multiple Ember versions
- `ember test` – Runs the test suite on the current Ember version
- `ember test --server` – Runs the test suite in "watch mode"
- `ember try:each` – Runs the test suite against multiple Ember versions

## Running the dummy application

* `ember serve`
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).
- `ember serve`
- Visit the dummy application at [http://localhost:4200](http://localhost:4200).

For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
date-picker
==============================================================================
# date-picker

First there was [shared-ember-components](https://github.com/PrecisionNutrition/shared-ember-components), Graham spoketh "This is crazy. Every time I touch a component's style, we have to update everything." And so `{{date-picker` was extracted, and so shall all of the other components.

Installation
------------------------------------------------------------------------------
## Installation

You should reopen the `DatePicker` service and override `isNativePickerDisplayed`. This controls whether or not we display a native `<input`, or the fancy picker.

But Why This?
------------------------------------------------------------------------------
## But Why This?

Whilst we wait for more desktop browsers to actually support date `<input`s with
a built in picker, we have to resort to building one for ourselves. This component
Expand Down
10 changes: 2 additions & 8 deletions addon/components/date-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,12 @@ export default class DatePicker extends Component {
return safeParse(this.args.min);
}


get center() {
const {
_center,
castValue,
max,
args: {
explicitCenter,
},
args: { explicitCenter },
} = this;

if (_center) {
Expand Down Expand Up @@ -111,10 +108,7 @@ export default class DatePicker extends Component {
}

get selectableYearOptions() {
const {
minYear,
maxYear,
} = this;
const { minYear, maxYear } = this;

const selectableYears = [];

Expand Down
2 changes: 1 addition & 1 deletion addon/components/native-date-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class NativeDatePicker extends Component {
}
}

publishChoice(action , { target: { value } }) {
publishChoice(action, { target: { value } }) {
const date = safeParse(value);

return action(date);
Expand Down
4 changes: 1 addition & 3 deletions config/dependency-lint.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

module.exports = {

};
module.exports = {};
2 changes: 1 addition & 1 deletion config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

module.exports = async function() {
module.exports = async function () {
return {
useYarn: true,
scenarios: [
Expand Down
4 changes: 2 additions & 2 deletions config/environment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

module.exports = function(/* environment, appConfig */) {
return { };
module.exports = function (/* environment, appConfig */) {
return {};
};
6 changes: 2 additions & 4 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

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

module.exports = function(defaults) {
module.exports = function (defaults) {
let app = new EmberAddon(defaults, {
'ember-composable-helpers': {
'only': [
'compute',
],
only: ['compute'],
},
});

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
contentFor(type, config) {
// https://github.com/cibernox/ember-power-select/issues/145#issuecomment-170012836
if (type === 'body-footer') {
let emberPowerDatepicker = this.addons.filter(function(addon) {
let emberPowerDatepicker = this.addons.filter(function (addon) {
return addon.name === 'ember-power-datepicker';
})[0];

Expand Down
29 changes: 28 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"devDependencies": {
"@ember/optional-features": "^1.3.0",
"@precision-nutrition/eslint-config": "^1.0.0",
"@precision-nutrition/prettier-config": "^1.1.0",
"babel-eslint": "^10.1.0",
"broccoli-asset-rev": "^3.0.0",
"ember-cli": "~3.17.0",
Expand All @@ -56,10 +56,15 @@
"ember-template-lint": "^2.4.0",
"ember-try": "^1.4.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-ember": "^7.10.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.3.0",
"husky": "^4.3.6",
"lint-staged": "^10.5.3",
"loader.js": "^4.7.0",
"npm-run-all": "^4.1.5",
"prettier": "2.2.1",
"qunit-dom": "^1.1.0"
},
"engines": {
Expand All @@ -70,5 +75,27 @@
},
"ember-addon": {
"configPath": "tests/dummy/config"
},
"prettier": "@precision-nutrition/prettier-config",
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"**/*.css": [
"stylelint --fix",
"prettier --write"
],
"**/*.{md,yml}": [
"prettier --write"
],
"**/*.js": [
"eslint --fix",
"prettier --write"
],
"**/*.hbs": [
"ember-template-lint . --quiet --fix"
]
}
}
8 changes: 2 additions & 6 deletions testem.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
module.exports = {
test_page: 'tests/index.html?hidepassed',
disable_watching: true,
launch_in_ci: [
'Chrome',
],
launch_in_dev: [
'Chrome',
],
launch_in_ci: ['Chrome'],
launch_in_dev: ['Chrome'],
browser_start_timeout: 120,
browser_args: {
Chrome: {
Expand Down
13 changes: 4 additions & 9 deletions tests/acceptance/pick-a-date-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@ import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { datepickerSelect } from 'ember-power-datepicker/test-support';

module('Acceptance | pick a date', function(hooks) {
module('Acceptance | pick a date', function (hooks) {
setupApplicationTest(hooks);

test('sanity check pick a date', async function(assert) {
test('sanity check pick a date', async function (assert) {
let inputValue = new Date(2015, 0, 2);

await visit('/');

await datepickerSelect(
'[data-test-selector="date-picker-wrapper"]',
inputValue,
);
await datepickerSelect('[data-test-selector="date-picker-wrapper"]', inputValue);

assert
.dom('[data-test-selector="current-value"]')
.includesText('Fri Jan 02 2015 00:00:00');
assert.dom('[data-test-selector="current-value"]').includesText('Fri Jan 02 2015 00:00:00');
});
});
3 changes: 1 addition & 2 deletions tests/dummy/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ export default class Router extends EmberRouter {
rootURL = config.rootURL;
}

Router.map(function() {
});
Router.map(function () {});
5 changes: 1 addition & 4 deletions tests/dummy/config/ember-cli-update.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
"outputRepo": "https://github.com/ember-cli/ember-addon-output",
"codemodsSource": "ember-addon-codemods-manifest@1",
"isBaseBlueprint": true,
"options": [
"--yarn",
"--no-welcome"
]
"options": ["--yarn", "--no-welcome"]
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

module.exports = function(environment) {
module.exports = function (environment) {
let ENV = {
modulePrefix: 'dummy',
environment,
Expand Down
6 changes: 1 addition & 5 deletions tests/dummy/config/targets.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
'use strict';

const browsers = [
'last 1 Chrome versions',
'last 1 Firefox versions',
'last 1 Safari versions',
];
const browsers = ['last 1 Chrome versions', 'last 1 Firefox versions', 'last 1 Safari versions'];

const isCI = !!process.env.CI;
const isProduction = process.env.EMBER_ENV === 'production';
Expand Down

0 comments on commit 45857df

Please sign in to comment.