Skip to content

Commit

Permalink
fix(prettier): Add usage of prettier for formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Jan 4, 2018
1 parent ef9ce0e commit 2a30cb1
Show file tree
Hide file tree
Showing 297 changed files with 17,447 additions and 8,601 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

59 changes: 19 additions & 40 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,35 @@
var prettierConf = require('./prettier.config.js');

module.exports = {
extends: ['airbnb'], // , 'prettier'
extends: ['airbnb', 'prettier'],
rules: {
'max-len': ["warn", 160, 4, {"ignoreUrls": true}],
'no-multi-spaces': ["error", { exceptions: { "ImportDeclaration": true } }],
'no-param-reassign': ["error", { props: false }],
'no-unused-vars': ["error", { args: 'none' }],
'react/jsx-filename-extension': ["error", { "extensions": [".js"] }],
'no-mixed-operators': ["error", {"allowSamePrecedence": true}],
// 'no-mixed-operators': 'error',

// Should fix that at some point but too much work...
'react/no-is-mounted': "warn",
'no-var': 0,
'one-var': 0,
'react/prefer-es6-class': 0,
// Should fix that at some point
'no-nested-ternary': 0,

// Not for us ;-)
'jsx-a11y/label-has-for': 0,
'no-console': 0,
'no-plusplus': 0,
'linebreak-style': 0,

// Not for vtk.js
// 'import/no-extraneous-dependencies': ["error", { "devDependencies": true }],
'import/no-extraneous-dependencies': 0,
'import/no-unresolved': 0,
'import/extensions': 0,
'prefer-destructuring': 0,
'import/no-named-as-default': 0,
'import/no-named-as-default-member': 0,

// May want to remove at some point
'no-restricted-properties': 0,
'function-paren-newline': 0,
'indent': 0,
'no-multi-spaces': 0,
'object-curly-newline': 0,
'prefer-destructuring': 0,
'prefer-promise-reject-errors': 0,
'switch-colon-spacing': 0,
'spaced-comment': 0,
'no-var': 0,
'import/extensions': 0,

// Not for us ;-)
'jsx-a11y/label-has-for': 0,
'no-console': 0,
'no-plusplus': 0,

'prettier/prettier': ['error', prettierConf],
},
// plugins: [
// 'prettier'
// ],
plugins: [
'prettier'
],
globals: {
__BASE_PATH__: false,
VRFrameData: true,
Expand All @@ -51,15 +38,7 @@ module.exports = {
'import/resolver': 'webpack'
},
env: {
es6: true,
browser: true,
},
// rules: {
// 'prettier/prettier': [
// 'error', {
// printWidth: 100,
// singleQuote: true,
// trailingComma: "es5"
// }
// ],
// }
};
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ cache:
script:
- npm install
- npm run build:release
- npm run validate
- npm run test:travis
- git config --global user.name "Travis CI"
- git config --global user.email "[email protected]"
Expand Down
4 changes: 2 additions & 2 deletions Sources/Common/Core/CellArray/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import macro from 'vtk.js/Sources/macro';
import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray';
import macro from 'vtk.js/Sources/macro';
import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray';
import { VtkDataTypes } from 'vtk.js/Sources/Common/Core/DataArray/Constants';

// ----------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions Sources/Common/Core/DataArray/Constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const DataTypeByteSize = {
const DataTypeByteSize = {
Int8Array: 1,
Uint8Array: 1,
Uint8ClampedArray: 1,
Expand All @@ -10,7 +10,7 @@ export const DataTypeByteSize = {
Float64Array: 8,
};

export const VtkDataTypes = {
const VtkDataTypes = {
VOID: '', // FIXME not sure to know what that shoud be
CHAR: 'Int8Array',
SIGNED_CHAR: 'Int8Array',
Expand All @@ -23,7 +23,7 @@ export const VtkDataTypes = {
DOUBLE: 'Float64Array',
};

export const DefaultDataType = VtkDataTypes.FLOAT;
const DefaultDataType = VtkDataTypes.FLOAT;

export default {
DefaultDataType,
Expand Down
56 changes: 36 additions & 20 deletions Sources/Common/Core/DataArray/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import macro from 'vtk.js/Sources/macro';
import macro from 'vtk.js/Sources/macro';
import Constants from 'vtk.js/Sources/Common/Core/DataArray/Constants';

const { DefaultDataType } = Constants;
Expand Down Expand Up @@ -42,7 +42,10 @@ function ensureRangeSize(rangeArray, size = 0) {
}

function getDataType(typedArray) {
return Object.prototype.toString.call(typedArray).split(' ')[1].slice(0, -1);
return Object.prototype.toString
.call(typedArray)
.split(' ')[1]
.slice(0, -1);
}

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -73,7 +76,7 @@ function vtkDataArray(publicAPI, model) {
// Return the data component at the location specified by tupleIdx and
// compIdx.
publicAPI.getComponent = (tupleIdx, compIdx = 0) =>
model.values[(tupleIdx * model.numberOfComponents) + compIdx];
model.values[tupleIdx * model.numberOfComponents + compIdx];

// Description:
// Set the data component at the location specified by tupleIdx and compIdx
Expand All @@ -82,16 +85,17 @@ function vtkDataArray(publicAPI, model) {
// NumberOfComponents. Make sure enough memory has been allocated
// (use SetNumberOfTuples() and SetNumberOfComponents()).
publicAPI.setComponent = (tupleIdx, compIdx, value) => {
if (value !== model.values[(tupleIdx * model.numberOfComponents) + compIdx]) {
model.values[(tupleIdx * model.numberOfComponents) + compIdx] = value;
if (value !== model.values[tupleIdx * model.numberOfComponents + compIdx]) {
model.values[tupleIdx * model.numberOfComponents + compIdx] = value;
dataChange();
}
};

publicAPI.getData = () => model.values;

publicAPI.getRange = (componentIndex = 0) => {
const rangeIdx = componentIndex < 0 ? model.numberOfComponents : componentIndex;
const rangeIdx =
componentIndex < 0 ? model.numberOfComponents : componentIndex;
let range = null;

if (!model.ranges) {
Expand All @@ -106,7 +110,11 @@ function vtkDataArray(publicAPI, model) {
}

// Need to compute ranges...
range = computeRange(model.values, componentIndex, model.numberOfComponents);
range = computeRange(
model.values,
componentIndex,
model.numberOfComponents
);
model.ranges[rangeIdx] = range;
model.rangeTuple[0] = range.min;
model.rangeTuple[1] = range.max;
Expand Down Expand Up @@ -135,15 +143,17 @@ function vtkDataArray(publicAPI, model) {
publicAPI.getTupleLocation = (idx = 1) => idx * model.numberOfComponents;
publicAPI.getNumberOfComponents = () => model.numberOfComponents;
publicAPI.getNumberOfValues = () => model.values.length;
publicAPI.getNumberOfTuples = () => model.values.length / model.numberOfComponents;
publicAPI.getNumberOfTuples = () =>
model.values.length / model.numberOfComponents;
publicAPI.getDataType = () => model.dataType;
/* eslint-disable no-use-before-define */
publicAPI.newClone = () => newInstance({
empty: true,
name: model.name,
dataType: model.dataType,
numberOfComponents: model.numberOfComponents,
});
publicAPI.newClone = () =>
newInstance({
empty: true,
name: model.name,
dataType: model.dataType,
numberOfComponents: model.numberOfComponents,
});
/* eslint-enable no-use-before-define */

publicAPI.getName = () => {
Expand Down Expand Up @@ -173,7 +183,9 @@ function vtkDataArray(publicAPI, model) {

// Override serialization support
publicAPI.getState = () => {
const jsonArchive = Object.assign({}, model, { vtkClass: publicAPI.getClassName() });
const jsonArchive = Object.assign({}, model, {
vtkClass: publicAPI.getClassName(),
});

// Convert typed array to regular array
jsonArchive.values = Array.from(jsonArchive.values);
Expand All @@ -188,9 +200,11 @@ function vtkDataArray(publicAPI, model) {

// Sort resulting object by key name
const sortedObj = {};
Object.keys(jsonArchive).sort().forEach((name) => {
sortedObj[name] = jsonArchive[name];
});
Object.keys(jsonArchive)
.sort()
.forEach((name) => {
sortedObj[name] = jsonArchive[name];
});

// Remove mtime
if (sortedObj.mtime) {
Expand Down Expand Up @@ -220,8 +234,10 @@ const DEFAULT_VALUES = {
export function extend(publicAPI, model, initialValues = {}) {
Object.assign(model, DEFAULT_VALUES, initialValues);

if ((!model.empty && !model.values && !model.size)) {
throw new TypeError('Cannot create vtkDataArray object without: size > 0, values');
if (!model.empty && !model.values && !model.size) {
throw new TypeError(
'Cannot create vtkDataArray object without: size > 0, values'
);
}

if (!model.values) {
Expand Down
12 changes: 10 additions & 2 deletions Sources/Common/Core/ImageHelper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,22 @@ import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray';
function canvasToImageData(canvas, boundingBox = [0, 0, 0, 0]) {
const [top, left, width, height] = boundingBox;
const ctxt = canvas.getContext('2d');
const idata = ctxt.getImageData(top, left, width || canvas.width, height || canvas.height);
const idata = ctxt.getImageData(
top,
left,
width || canvas.width,
height || canvas.height
);

const imageData = vtkImageData.newInstance({ type: 'vtkImageData' });
imageData.setOrigin(0, 0, 0);
imageData.setSpacing(1, 1, 1);
imageData.setExtent(0, canvas.width - 1, 0, canvas.height - 1, 0, 0);

const scalars = vtkDataArray.newInstance({ numberOfComponents: 4, values: idata.data });
const scalars = vtkDataArray.newInstance({
numberOfComponents: 4,
values: idata.data,
});
scalars.setName('scalars');
imageData.getPointData().setScalars(scalars);

Expand Down
Loading

0 comments on commit 2a30cb1

Please sign in to comment.