Skip to content

Commit 3f3e5c4

Browse files
committed
new structure
1 parent 9c8b86e commit 3f3e5c4

File tree

8 files changed

+41
-30
lines changed

8 files changed

+41
-30
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ jobs:
2323
strategy:
2424
matrix:
2525
node-version:
26-
- 18.x
2726
- 20.x
2827
- 22.x
2928

eslint.config.mjs

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
1-
import { defineConfig, globalIgnores } from "eslint/config";
2-
import globals from "globals";
1+
import globals from "globals"
32

4-
export default defineConfig([globalIgnores(["src/**/*.test.js"]), {
5-
languageOptions: {
6-
globals: {
7-
...globals.browser,
8-
...globals.node,
9-
Atomics: "readonly",
10-
SharedArrayBuffer: "readonly",
3+
export default [
4+
{
5+
ignores: [
6+
'node_modules/**',
7+
'coverage/**'
8+
],
9+
},
10+
{
11+
files: ['src/**/*.js'],
12+
languageOptions: {
13+
globals: {
14+
...globals.browser,
15+
...globals.node,
16+
Atomics: "readonly",
17+
SharedArrayBuffer: "readonly",
18+
},
1119
},
1220

13-
ecmaVersion: 8,
14-
sourceType: "commonjs",
15-
},
16-
17-
rules: {
18-
"no-unused-vars": ["warn", {
19-
argsIgnorePattern: "^_",
20-
varsIgnorePattern: "^_",
21-
}],
22-
},
23-
}]);
21+
rules: {
22+
semi: ['error', 'never'],
23+
quotes: ['error', 'single'],
24+
'no-console': 'warn',
25+
'no-unused-vars': 'warn',
26+
'no-undef': 'error'
27+
},
28+
}
29+
]

jest.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
module.exports = {
2+
collectCoverage: true,
3+
coverageDirectory: 'coverage',
24
testEnvironment: 'jsdom',
35
testEnvironmentOptions: {
46
customExportConditions: ['node']
57
},
6-
setupFilesAfterEnv: ["./jest.setup.js"],
8+
setupFilesAfterEnv: ["./test/helpers/jest.setup.js"],
79
transformIgnorePatterns: ["/node_modules/(?!lit-html).+\\.js"],
10+
testMatch: ['**/__tests__/**/*.ts?(x)', '**/?(*.)+(spec|test).ts?(x)'],
11+
roots: ['<rootDir>/src', '<rootDir>/test'],
812
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"main": "src/sourcePane.js",
66
"scripts": {
77
"build": "echo nothing to build",
8-
"lint": "eslint 'src/*.js'",
9-
"lint-fix": "eslint 'src/*.js' --fix",
10-
"test": "jest",
8+
"lint": "eslint",
9+
"test": "jest --no-coverage",
10+
"test-coverage": "jest --coverage --collectCoverageFrom=src/**/*.[jt]s",
1111
"prepublishOnly": "npm run lint && npm run test",
1212
"postpublish": "git push origin main --follow-tags"
1313
},

src/sourcePane.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ module.exports = {
131131
textArea.style.color = '#888'
132132
cancelButton.style.visibility = 'visible'
133133
saveButton.style.visibility = 'collapse'
134-
myCompactButton['style'] = "visibility: visible; width: 100px; padding: 10.2px; transform: translate(0, -30%)"
135-
if (!compactable[contentType.split(';')]) { myCompactButton.style.visibility = "collapse" }
134+
myCompactButton['style'] = 'visibility: visible; width: 100px; padding: 10.2px; transform: translate(0, -30%)'
135+
if (!compactable[contentType.split(';')]) { myCompactButton.style.visibility = 'collapse' }
136136
textArea.setAttribute('readonly', 'true')
137137
}
138138
function setEditable () {
@@ -193,6 +193,7 @@ module.exports = {
193193
function HTMLDataIsland (data) {
194194
let dataIslandContentType = ''
195195
let dataIsland = ''
196+
let pos = 0
196197
const scripts = data.split('</script')
197198
if (scripts && scripts.length) {
198199
for (let script of scripts) {
@@ -206,11 +207,12 @@ module.exports = {
206207
}
207208
}
208209
}
209-
return [dataIsland, dataIslandContentType]
210+
return [dataIsland, dataIslandContentType, pos]
210211
}
211212

212213
function checkSyntax (data, contentType, base) {
213214
if (!parseable[contentType]) return true // don't check things we don't understand
215+
let pos
214216
if (contentType === 'text/html') {
215217
[data, contentType, pos] = HTMLDataIsland(data)
216218
if (!contentType) return true
@@ -306,7 +308,7 @@ module.exports = {
306308
$rdf.parse(textArea.value, kb, subject.uri, contentType)
307309
// for jsonld serialize which is a Promise. New rdflib
308310
const serialized = Promise.resolve($rdf.serialize(kb.sym(subject.uri), kb, subject.uri, contentType))
309-
serialized.then(result => { textArea.value = result; /*return div*/ })
311+
serialized.then(result => { textArea.value = result /*return div*/ })
310312
cancelButton.style.visibility = 'visible'
311313
} catch (e) {
312314
statusRow.appendChild(UI.widgets.errorMessageBlock(dom, e))
File renamed without changes.
File renamed without changes.

src/sourcePane.test.js renamed to test/sourcePane.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { context, doc, subject } = require('./setup')
1+
const { context, doc, subject } = require('./helpers/setup')
22
const pane = require('../src/sourcePane')
33
const { findByText, fireEvent, getByTitle, waitFor } = require('@testing-library/dom')
44
const fetchMock = require('jest-fetch-mock')

0 commit comments

Comments
 (0)