@eturnity/eturnity_maths 7.30.0 → 7.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.js CHANGED
@@ -1,28 +1,187 @@
1
1
  module.exports = {
2
+ root: true,
2
3
  env: {
3
4
  browser: true,
4
- es2021: true
5
+ node: true,
6
+ es6: true,
5
7
  },
6
- extends: 'eslint:recommended',
7
- overrides: [
8
- {
9
- env: {
10
- node: true
11
- },
12
- files: ['.eslintrc.{js,cjs}'],
13
- parserOptions: {
14
- sourceType: 'script'
15
- }
16
- }
8
+ extends: [
9
+ 'eslint:recommended',
10
+ 'eslint:recommended',
11
+ 'plugin:vue/vue3-recommended',
12
+ 'plugin:prettier/recommended',
17
13
  ],
14
+ plugins: ['vue', 'prettier'],
18
15
  parserOptions: {
19
- ecmaVersion: 'latest',
20
- sourceType: 'module'
16
+ ecmaVersion: 2020,
17
+ sourceType: 'module',
21
18
  },
22
19
  rules: {
23
- indent: ['error', 'tab'],
24
- 'linebreak-style': ['error', 'unix'],
25
- quotes: ['error', 'single'],
26
- semi: ['error', 'never']
27
- }
20
+ 'vue/component-name-in-template-casing': [
21
+ 'warn',
22
+ 'PascalCase',
23
+ {
24
+ registeredComponentsOnly: false,
25
+ ignores: [],
26
+ },
27
+ ],
28
+ 'vue/multi-word-component-names': [
29
+ 'warn',
30
+ {
31
+ ignores: [],
32
+ },
33
+ ],
34
+ 'vue/html-closing-bracket-newline': [
35
+ 'warn',
36
+ {
37
+ singleline: 'never',
38
+ multiline: 'always',
39
+ },
40
+ ],
41
+ 'vue/html-closing-bracket-spacing': [
42
+ 'warn',
43
+ {
44
+ startTag: 'never',
45
+ endTag: 'never',
46
+ selfClosingTag: 'always',
47
+ },
48
+ ],
49
+ 'vue/no-multi-spaces': [
50
+ 'warn',
51
+ {
52
+ ignoreProperties: false,
53
+ },
54
+ ],
55
+ 'vue/html-end-tags': 'warn',
56
+ 'keyword-spacing': [
57
+ 'warn',
58
+ {
59
+ before: true, // Require a space before keywords
60
+ after: true, // Require a space after keywords
61
+ },
62
+ ],
63
+ // Enforce one space after comma
64
+ 'comma-spacing': [
65
+ 'warn',
66
+ {
67
+ before: false, // No space before comma
68
+ after: true, // Require a space after comma
69
+ },
70
+ ],
71
+ 'func-call-spacing': ['warn', 'never'],
72
+ // Enforce one space around binary operators (+, -, *, /, etc.)
73
+ 'space-infix-ops': 'warn',
74
+ // Enforce no space inside parentheses
75
+ 'space-in-parens': ['warn', 'never'],
76
+ // Enforce one space before block statements (if, else, for, etc.)
77
+ 'space-before-blocks': 'warn',
78
+ // Enforce no spaces inside square brackets
79
+ 'array-bracket-spacing': ['warn', 'never'],
80
+ // Enforce one space before function parentheses
81
+ 'space-before-function-paren': ['warn', 'never'],
82
+ // Enforce one space inside braces of object literals
83
+ 'object-curly-spacing': ['warn', 'always'],
84
+ // Enforce one space before and after arrow functions (optional)
85
+ 'arrow-spacing': ['warn', { before: true, after: true }],
86
+ // Enforce one space after colon in object literals
87
+ 'key-spacing': [
88
+ 'warn',
89
+ {
90
+ beforeColon: false, // No space before colon
91
+ afterColon: true, // Require one space after colon
92
+ mode: 'strict', // Enforce spacing between key and value
93
+ },
94
+ ],
95
+ 'vue/html-indent': 'off',
96
+ 'vue/html-quotes': ['warn', 'double'],
97
+ 'vue/html-self-closing': [
98
+ 'warn',
99
+ {
100
+ html: {
101
+ void: 'always',
102
+ normal: 'never',
103
+ component: 'always',
104
+ },
105
+ svg: 'always',
106
+ math: 'always',
107
+ },
108
+ ],
109
+ 'vue/require-default-prop': 'warn',
110
+ 'vue/require-prop-types': 'warn',
111
+ 'vue/v-on-event-hyphenation': [
112
+ 'warn',
113
+ 'always',
114
+ {
115
+ autofix: true,
116
+ ignore: [],
117
+ },
118
+ ],
119
+ 'vue/prop-name-casing': ['warn', 'camelCase'],
120
+ 'vue/order-in-components': 'warn',
121
+ 'vue/this-in-template': ['warn', 'never'],
122
+ 'vue/attributes-order': [
123
+ 'warn',
124
+ {
125
+ order: [
126
+ 'DEFINITION',
127
+ 'LIST_RENDERING',
128
+ 'CONDITIONALS',
129
+ 'RENDER_MODIFIERS',
130
+ 'GLOBAL',
131
+ ['UNIQUE', 'SLOT'],
132
+ 'TWO_WAY_BINDING',
133
+ 'OTHER_DIRECTIVES',
134
+ 'OTHER_ATTR',
135
+ 'EVENTS',
136
+ 'CONTENT',
137
+ ],
138
+ alphabetical: true,
139
+ },
140
+ ],
141
+ 'vue/no-unused-vars': 'warn',
142
+ 'vue/no-use-v-if-with-v-for': [
143
+ 'warn',
144
+ {
145
+ allowUsingIterationVar: false,
146
+ },
147
+ ],
148
+ 'no-unused-vars': 'warn',
149
+ 'no-undef': 'warn',
150
+ 'no-console': 'warn',
151
+ 'no-debugger': 'warn',
152
+ 'no-multi-spaces': 'warn',
153
+ 'no-mixed-spaces-and-tabs': 'warn',
154
+ 'no-redeclare': 'warn',
155
+ 'no-prototype-builtins': 'warn',
156
+ 'no-unsafe-finally': 'warn',
157
+ 'max-len': [
158
+ 'warn',
159
+ {
160
+ code: 120,
161
+ tabWidth: 2,
162
+ ignoreUrls: true,
163
+ ignoreComments: true,
164
+ ignoreTrailingComments: true,
165
+ ignorePattern: '^import\\s.+\\sfrom\\s.+;$',
166
+ },
167
+ ],
168
+ 'prettier/prettier': [
169
+ 'warn',
170
+ 2,
171
+ 2,
172
+ {
173
+ semi: false,
174
+ singleQuote: true,
175
+ trailingComma: 'es5',
176
+ printWidth: 80,
177
+ tabWidth: 2,
178
+ useTabs: false,
179
+ endOfLine: 'auto',
180
+ },
181
+ ],
182
+ 'vue/script-indent': ['warn', 2, { baseIndent: 1 }],
183
+ },
184
+ globals: {
185
+ _: true,
186
+ },
28
187
  }
package/.prettierrc CHANGED
@@ -1,7 +1,9 @@
1
1
  {
2
- "semi": false,
3
- "singleQuote": true,
4
- "useTabs": false,
5
- "trailingComma": "none",
6
- "printWidth": 80
7
- }
2
+ "semi": false,
3
+ "singleQuote": true,
4
+ "printWidth": 80,
5
+ "tabWidth": 2,
6
+ "trailingComma": "es5",
7
+ "bracketSpacing": true,
8
+ "vueIndentScriptAndStyle": true
9
+ }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_maths",
3
- "version": "7.30.0",
3
+ "version": "7.32.0",
4
4
  "author": "Eturnity Team",
5
5
  "main": "src/index.js",
6
6
  "private": false,
7
7
  "scripts": {
8
- "test": "jest",
9
- "prettier": "prettier --write \"**/*.js\""
8
+ "lint": "eslint --fix --debug --ext .js,.vue .",
9
+ "test": "jest"
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
@@ -28,8 +28,16 @@
28
28
  "@babel/core": "7.21.4",
29
29
  "@babel/preset-env": "7.21.4",
30
30
  "babel-jest": "29.5.0",
31
+ "@vue/eslint-config-standard": "8.0.1",
32
+ "babel-eslint": "10.1.0",
33
+ "easygettext": "2.17.0",
34
+ "eslint": "8.0.1",
35
+ "eslint-config-prettier": "8.8.0",
36
+ "eslint-plugin-prettier": "4.2.1",
37
+ "eslint-plugin-vue": "9.14.1",
31
38
  "jest": "29.5.0",
32
- "prettier": "2.8.8"
39
+ "prettier": "^2.8.4",
40
+ "prettier-plugin-vue": "^1.1.6"
33
41
  },
34
42
  "description": ""
35
43
  }
package/src/geometry.js CHANGED
@@ -1061,7 +1061,6 @@ export function getIndexesOfBiggestTriangleWithTwoFixedIndexes(
1061
1061
  preferedAndFixedIndexes = [...new Set(preferedAndFixedIndexes)]
1062
1062
  if (points.length < 3 || fixedIndexes.length < 3) {
1063
1063
  throw new Error('not enough points to make a triangle')
1064
- return
1065
1064
  }
1066
1065
  let minArea = calculateArea(points) / areaMinFactor
1067
1066
  let maxArea = minArea
@@ -609,7 +609,7 @@ function findPointInsidePolygon(point, polygon) {
609
609
  var classify
610
610
  var org, dest
611
611
  for (var i = 0; i < edges.length; i++) {
612
- ;[org, dest] = edges[i]
612
+ [org, dest] = edges[i]
613
613
  classify = classifyPoint(point, [org, dest])
614
614
  if (
615
615
  (classify.loc === 'RIGHT' && org.y < point.y && dest.y >= point.y) ||
@@ -20,7 +20,7 @@ export default function concaveman(points, concavity, lengthThreshold) {
20
20
 
21
21
  // index the points with an R-tree
22
22
  var tree = new RBush(16)
23
- tree.toBBox = function (a) {
23
+ tree.toBBox = function(a) {
24
24
  return {
25
25
  minX: a[0],
26
26
  minY: a[1],
@@ -28,10 +28,10 @@ export default function concaveman(points, concavity, lengthThreshold) {
28
28
  maxY: a[1]
29
29
  }
30
30
  }
31
- tree.compareMinX = function (a, b) {
31
+ tree.compareMinX = function(a, b) {
32
32
  return a[0] - b[0]
33
33
  }
34
- tree.compareMinY = function (a, b) {
34
+ tree.compareMinY = function(a, b) {
35
35
  return a[1] - b[1]
36
36
  }
37
37
 
@@ -205,7 +205,7 @@ export class Line {
205
205
  }
206
206
  const polygon0 = polygons.find((p) => p.id == this.belongsTo[0].polygonId)
207
207
  const polygon1 = polygons.find((p) => p.id == this.belongsTo[1].polygonId)
208
- if(!polygon0 || !polygon1){
208
+ if (!polygon0 || !polygon1) {
209
209
  return false
210
210
  }
211
211
  let A, B, C, D
@@ -213,14 +213,14 @@ export class Line {
213
213
  A = polygon0.outline[this.belongsTo[0].index]
214
214
  B =
215
215
  polygon0.outline[
216
- (this.belongsTo[0].index + 1) % polygon0.outline.length
216
+ (this.belongsTo[0].index + 1) % polygon0.outline.length
217
217
  ]
218
218
  }
219
219
  if (this.belongsTo[1].index !== null) {
220
- C = polygon1.outline[this.belongsTo[1].index]
220
+ C = polygon1.outline[this.belongsTo[1].index]
221
221
  D =
222
222
  polygon1.outline[
223
- (this.belongsTo[1].index + 1) % polygon1.outline.length
223
+ (this.belongsTo[1].index + 1) % polygon1.outline.length
224
224
  ]
225
225
  }
226
226
  if (!A || !B) {
@@ -150,8 +150,8 @@ export class Polygon {
150
150
  }
151
151
  translate(vectorInMm) {
152
152
  this.version++
153
- if(this.roofs){
154
- this.roofs.forEach(r=>r.version++)
153
+ if (this.roofs) {
154
+ this.roofs.forEach(r => r.version++)
155
155
  }
156
156
  this.positionOffset.x += vectorInMm.x
157
157
  this.positionOffset.y += vectorInMm.y
@@ -1,7 +1,7 @@
1
1
  import { Graph } from './DFS'
2
2
  import { isSameSegment2D } from '../../geometry'
3
3
 
4
- export function generateGraph(polygons, {includingRoofOnRoofs = true} = {}) {
4
+ export function generateGraph(polygons, { includingRoofOnRoofs = true } = {}) {
5
5
  const edges2D = []
6
6
  const g = new Graph()
7
7
  polygons
@@ -60,7 +60,7 @@ export function mergePolygons(polygonIdsToMerge, edges, layer, polygons) {
60
60
  if (!polygon) {
61
61
  let newPolygon = new Polygon(outlineList[k], layer)
62
62
  polygonList.push(newPolygon)
63
- }else{
63
+ } else {
64
64
  polygonList.push(polygon)
65
65
  }
66
66
  }
@@ -438,7 +438,7 @@ export function getEdgeList(
438
438
  }
439
439
  function forestRecursion(cycleTree) {
440
440
  if (cycleTree.children.length > 0) {
441
- let cycles = cycleTree.children.reduce(function (done, curr) {
441
+ let cycles = cycleTree.children.reduce(function(done, curr) {
442
442
  done.push(...forestRecursion(curr))
443
443
  return done
444
444
  }, [])