Skip to content

Commit bfdf016

Browse files
Merge pull request #17 from Exabyte-io/feat/SOF-6398-1
SOF-6398-1: prettier reformat
2 parents 6542756 + 9f1d7f8 commit bfdf016

File tree

8 files changed

+72
-27
lines changed

8 files changed

+72
-27
lines changed

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"singleQuote": false,
3+
"printWidth": 100,
4+
"trailingComma": "all",
5+
"tabWidth": 4
6+
}
7+

package-lock.json

Lines changed: 33 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
"description": "Application DEfinitions",
55
"scripts": {
66
"test": "nyc --reporter=text mocha --recursive --bail --require @babel/register/lib --require tests/setup.js tests",
7-
"lint": "eslint src tests",
8-
"lint:fix": "eslint --fix --cache src tests",
7+
"lint": "eslint src tests && prettier --write src tests",
8+
"lint:fix": "eslint --fix --cache src tests && prettier --write src tests",
99
"transpile": "babel --out-dir dist src",
1010
"postinstall": "npm run transpile",
11+
"prettier": "prettier --check src tests",
1112
"prepare": "husky install"
1213
},
1314
"repository": {
@@ -45,14 +46,16 @@
4546
},
4647
"devDependencies": {
4748
"@exabyte-io/code.js": "2022.11.11-0",
48-
"@exabyte-io/eslint-config": "^2022.11.16-0",
49+
"@exabyte-io/eslint-config": "^2022.11.17-0",
4950
"@exabyte-io/made.js": "2022.6.15-0",
5051
"chai": "^4.3.4",
5152
"eslint": "7.32.0",
5253
"eslint-config-airbnb": "19.0.2",
54+
"eslint-config-prettier": "^8.5.0",
5355
"eslint-plugin-import": "2.25.3",
5456
"eslint-plugin-jsdoc": "37.1.0",
5557
"eslint-plugin-jsx-a11y": "6.5.1",
58+
"eslint-plugin-prettier": "^4.2.1",
5659
"eslint-plugin-react": "7.30.0",
5760
"eslint-plugin-simple-import-sort": "7.0.0",
5861
"husky": "^7.0.4",
@@ -69,6 +72,7 @@
6972
"node": ">=12.0.0"
7073
},
7174
"lint-staged": {
72-
"*.js": "eslint --cache --fix"
75+
"*.js": "eslint --cache --fix",
76+
"*.{js,css}": "prettier --write"
7377
}
7478
}

src/application.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ export class Application extends NamedDefaultableInMemoryEntity {
9797
get executables() {
9898
const tree = getAppTree(this.prop("name"));
9999
return Object.keys(tree).map((key) => {
100-
return new this.constructor.Executable(
101-
{ ...tree[key], name: key },
102-
);
100+
return new this.constructor.Executable({ ...tree[key], name: key });
103101
});
104102
}
105103

src/flavor.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { mix } from "mixwith";
44
import { Template } from "./template";
55

66
export class Flavor extends mix(NamedDefaultableInMemoryEntity).with(RuntimeItemsMixin) {
7-
get input() { return this.prop("input", []); }
7+
get input() {
8+
return this.prop("input", []);
9+
}
810

911
// TODO : prevent this from running in client
1012
get inputAsTemplates() {

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import {
2-
allApplications, allowedMonitors, allowedResults, allTemplates,
2+
allApplications,
3+
allowedMonitors,
4+
allowedResults,
5+
allTemplates,
36
} from "@exabyte-io/application-flavors.js";
47

58
import { Application } from "./application";

src/template.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ export class Template extends NamedInMemoryEntity {
5656

5757
render(externalContext) {
5858
const renderingContext = this.getRenderingContext(externalContext);
59-
let template,
60-
rendered;
59+
let template, rendered;
6160
if (!this.isManuallyChanged) {
6261
try {
6362
template = jinja.compile(this.content);
@@ -85,9 +84,10 @@ export class Template extends NamedInMemoryEntity {
8584

8685
static fromFlavor(appName, execName, inputName) {
8786
const filtered = allTemplates.filter(
88-
(temp) => temp.applicationName === appName
89-
&& temp.executableName === execName
90-
&& temp.name === inputName,
87+
(temp) =>
88+
temp.applicationName === appName &&
89+
temp.executableName === execName &&
90+
temp.name === inputName,
9191
);
9292
if (filtered.length !== 1) {
9393
console.log(
@@ -105,8 +105,8 @@ export class Template extends NamedInMemoryEntity {
105105
getContextProvidersAsClassInstances(providerContext) {
106106
const me = this;
107107
return this.contextProviders.map((p) => {
108-
const { constructor, config } = me.constructor.providerRegistry
109-
.findProviderInstanceByName(p.name);
108+
const { constructor, config } =
109+
me.constructor.providerRegistry.findProviderInstanceByName(p.name);
110110
const clsInstance = new constructor({
111111
...config,
112112
context: providerContext,

src/tree.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ export function getAllApplications(cls = null) {
1212
const applicationsArray = [];
1313
allApplications.forEach((appName) => {
1414
applicationsTree[appName] = {};
15-
const {
16-
versions, defaultVersion, build = "Default", ...appData
17-
} = getAppData(appName);
15+
const { versions, defaultVersion, build = "Default", ...appData } = getAppData(appName);
1816
applicationsTree[appName].defaultVersion = defaultVersion;
1917
versions.forEach((options) => {
2018
const { version } = options;
@@ -40,9 +38,7 @@ export function getAllApplications(cls = null) {
4038
* @param build {String} the build to use (optional, defaults to Default)
4139
* @return {*} an application
4240
*/
43-
export function getApplication({
44-
applicationsTree, name, version = null, build = "Default",
45-
}) {
41+
export function getApplication({ applicationsTree, name, version = null, build = "Default" }) {
4642
const app = applicationsTree[name];
4743
// eslint-disable-next-line no-param-reassign
4844
if (!version) version = app.defaultVersion;
@@ -60,7 +56,10 @@ const { applicationsTree } = getAllApplications(null);
6056
*/
6157
export function getApplicationConfig({ name, version = null, build = "Default" }) {
6258
return getApplication({
63-
applicationsTree, name, version, build,
59+
applicationsTree,
60+
name,
61+
version,
62+
build,
6463
});
6564
}
6665

@@ -72,7 +71,9 @@ export function getApplicationConfig({ name, version = null, build = "Default" }
7271
*/
7372
export function getExecutableConfig({ appName, execName }) {
7473
const appTree = getAppTree(appName);
75-
Object.entries(appTree).forEach(([name, exec]) => { exec.name = name; });
74+
Object.entries(appTree).forEach(([name, exec]) => {
75+
exec.name = name;
76+
});
7677
if (!execName) return getOneMatchFromObject(appTree, "isDefault", true);
7778
return appTree[execName];
7879
}

0 commit comments

Comments
 (0)