-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: set up eslint 9 and gitattributes (#135)
The latter for cross-platform support
- Loading branch information
Showing
22 changed files
with
836 additions
and
658 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import prettierConfig from "eslint-config-prettier"; | ||
import prettierPlugin from "eslint-plugin-prettier/recommended"; | ||
import globals from "globals"; | ||
import js from "@eslint/js"; | ||
|
||
export default [ | ||
js.configs.recommended, | ||
prettierConfig, | ||
prettierPlugin, | ||
{ | ||
languageOptions: { | ||
globals: { | ||
...globals.node, | ||
...globals.browser, | ||
global: true, | ||
}, | ||
}, | ||
}, | ||
{ | ||
ignores: [ | ||
"tap-snapshots/*", | ||
"node_modules/*", | ||
"modules/*", | ||
"utils/*", | ||
"dist/*", | ||
"tmp/*", | ||
], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
// import _ from 'lodash'; | ||
|
||
import { h, Component, render } from 'https://unpkg.com/preact?module'; | ||
import foo from './module.js'; | ||
import { h, render } from "https://unpkg.com/preact?module"; | ||
import foo from "./module.js"; | ||
|
||
|
||
function component() { | ||
const element = document.createElement('div'); | ||
function component() { | ||
const element = document.createElement("div"); | ||
|
||
// Lodash, currently included via a script, is required for this line to work | ||
// Lodash, now imported by this script | ||
element.innerHTML = ['Hello', 'webpack', foo()].join(' '); | ||
|
||
element.innerHTML = ["Hello", "webpack", foo()].join(" "); | ||
|
||
// Create your app | ||
const app = h('h1', null, 'Hello World!'); | ||
const app = h("h1", null, "Hello World!"); | ||
|
||
render(app, document.body); | ||
|
||
return element; | ||
} | ||
return element; | ||
} | ||
|
||
document.body.appendChild(component()); | ||
document.body.appendChild(component()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
const foo = () => { | ||
return 'foo'; | ||
} | ||
return "foo"; | ||
}; | ||
|
||
export default foo | ||
export default foo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { html } from 'lit-element'; | ||
import { html } from "lit-element"; | ||
|
||
const render = (world) => { | ||
return html`<p>Hello ${world}!</p>`; | ||
return html`<p>Hello ${world}!</p>`; | ||
}; | ||
render(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
import { html } from 'lit-html/lit-html'; | ||
import { css } from 'lit-html'; | ||
import { LitElement } from 'lit-element'; | ||
import { html } from "lit-html/lit-html"; | ||
import { css } from "lit-html"; | ||
import { LitElement } from "lit-element"; | ||
|
||
export default class Inner extends LitElement { | ||
static get styles() { | ||
return [css`:host { color: red; }`]; | ||
} | ||
static get styles() { | ||
return [ | ||
css` | ||
:host { | ||
color: red; | ||
} | ||
`, | ||
]; | ||
} | ||
|
||
render(world) { | ||
return html`<p>Hello ${world}!</p>`; | ||
} | ||
render(world) { | ||
return html`<p>Hello ${world}!</p>`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
import { replaceElement } from '../utils/dom.js'; | ||
import view from './views.js'; | ||
import data from '../data/data.js'; | ||
import { replaceElement } from "../utils/dom.js"; | ||
import view from "./views.js"; | ||
import data from "../data/data.js"; | ||
|
||
export default class App { | ||
constructor(root) { | ||
this.root = root; | ||
} | ||
constructor(root) { | ||
this.root = root; | ||
} | ||
|
||
render() { | ||
const items = data(); | ||
const el = view(items); | ||
this.root = replaceElement(this.root, el); | ||
} | ||
render() { | ||
const items = data(); | ||
const el = view(items); | ||
this.root = replaceElement(this.root, el); | ||
} | ||
|
||
update() { | ||
setInterval(() => { | ||
this.render(); | ||
}, 1000); | ||
} | ||
update() { | ||
setInterval(() => { | ||
this.render(); | ||
}, 1000); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { html, css } from 'lit-element'; | ||
import { html } from "lit-element"; | ||
|
||
export default function view(items) { | ||
return html`<p>Hello ${items[0]}!</p>`; | ||
return html`<p>Hello ${items[0]}!</p>`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
function random(min, max) { | ||
return Math.floor(min + Math.random() * (max + 1 - min)); | ||
return Math.floor(min + Math.random() * (max + 1 - min)); | ||
} | ||
|
||
export default function data() { | ||
return [ | ||
random(0, 20), | ||
random(20, 40), | ||
random(40, 60), | ||
random(60, 80), | ||
random(80, 100), | ||
]; | ||
return [ | ||
random(0, 20), | ||
random(20, 40), | ||
random(40, 60), | ||
random(60, 80), | ||
random(80, 100), | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import { firstElement } from './utils/dom.js'; | ||
import App from './app/app.js'; | ||
import { firstElement } from "./utils/dom.js"; | ||
import App from "./app/app.js"; | ||
|
||
const ready = () => { | ||
return new Promise((resolve) => { | ||
document.addEventListener('DOMContentLoaded', () => { | ||
const el = document.getElementById('app'); | ||
resolve(firstElement(el)); | ||
}); | ||
return new Promise((resolve) => { | ||
document.addEventListener("DOMContentLoaded", () => { | ||
const el = document.getElementById("app"); | ||
resolve(firstElement(el)); | ||
}); | ||
}); | ||
}; | ||
|
||
const start = async () => { | ||
const el = await ready(); | ||
const app = new App(el); | ||
app.render(); | ||
app.update(); | ||
const el = await ready(); | ||
const app = new App(el); | ||
app.render(); | ||
app.update(); | ||
}; | ||
start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
export function replaceElement(target, element) { | ||
target.replaceWith(element); | ||
return element; | ||
target.replaceWith(element); | ||
return element; | ||
} | ||
|
||
export function firstElement(element) { | ||
return element.firstElementChild; | ||
return element.firstElementChild; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,22 @@ | ||
module.exports = { | ||
plugins: [ | ||
'@semantic-release/commit-analyzer', | ||
'@semantic-release/release-notes-generator', | ||
'@semantic-release/changelog', | ||
[ | ||
'@semantic-release/npm', | ||
{ | ||
tarballDir: 'release', | ||
}, | ||
], | ||
[ | ||
'@semantic-release/github', | ||
{ | ||
assets: 'release/*.tgz', | ||
}, | ||
], | ||
'@semantic-release/git', | ||
plugins: [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/changelog", | ||
[ | ||
"@semantic-release/npm", | ||
{ | ||
tarballDir: "release", | ||
}, | ||
], | ||
preset: 'angular', | ||
branches: [ | ||
{ name: 'main' }, | ||
{ name: 'next', prerelease: true }, | ||
[ | ||
"@semantic-release/github", | ||
{ | ||
assets: "release/*.tgz", | ||
}, | ||
], | ||
"@semantic-release/git", | ||
], | ||
preset: "angular", | ||
branches: [{ name: "main" }, { name: "next", prerelease: true }], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,47 @@ | ||
const parsers = require('./parsers.cjs'); | ||
const parsers = require("./parsers.cjs"); | ||
|
||
const RX_SIDE_EFFECTS_IMPORT = parsers.sideEffectsImport(); | ||
const RX_STANDARD_IMPORT = parsers.standardImport(); | ||
const RX_DYNAMIC_IMPORT = parsers.dynamicImport(); | ||
|
||
const standardImport = ({ dictionary = new Map(), source = '' }) => { | ||
const result = source.replace(RX_STANDARD_IMPORT, (replacer, g1, g2, g3, g4) => { | ||
const dep = dictionary.get(g4) || g4; | ||
return `${g1} ${g2} ${g3} '${dep}'`; | ||
}); | ||
const standardImport = ({ dictionary = new Map(), source = "" }) => { | ||
const result = source.replace( | ||
RX_STANDARD_IMPORT, | ||
(replacer, g1, g2, g3, g4) => { | ||
const dep = dictionary.get(g4) || g4; | ||
return `${g1} ${g2} ${g3} '${dep}'`; | ||
}, | ||
); | ||
|
||
return { | ||
source: result, | ||
dictionary, | ||
}; | ||
return { | ||
source: result, | ||
dictionary, | ||
}; | ||
}; | ||
module.exports.standardImport = standardImport; | ||
|
||
const dynamicImport = ({ dictionary = new Map(), source = '' }) => { | ||
const result = source.replace(RX_DYNAMIC_IMPORT, (replacer, g1, g2) => { | ||
const dep = dictionary.get(g2) || g2; | ||
return `${g1}('${dep}')`; | ||
}); | ||
const dynamicImport = ({ dictionary = new Map(), source = "" }) => { | ||
const result = source.replace(RX_DYNAMIC_IMPORT, (replacer, g1, g2) => { | ||
const dep = dictionary.get(g2) || g2; | ||
return `${g1}('${dep}')`; | ||
}); | ||
|
||
return { | ||
source: result, | ||
dictionary, | ||
}; | ||
return { | ||
source: result, | ||
dictionary, | ||
}; | ||
}; | ||
module.exports.dynamicImport = dynamicImport; | ||
|
||
const sideEffectsImport = ({ dictionary = new Map(), source = '' }) => { | ||
const result = source.replace(RX_SIDE_EFFECTS_IMPORT, (replacer, g1, g2) => { | ||
const dep = dictionary.get(g2) || g2; | ||
return `${g1} '${dep}'`; | ||
}); | ||
const sideEffectsImport = ({ dictionary = new Map(), source = "" }) => { | ||
const result = source.replace(RX_SIDE_EFFECTS_IMPORT, (replacer, g1, g2) => { | ||
const dep = dictionary.get(g2) || g2; | ||
return `${g1} '${dep}'`; | ||
}); | ||
|
||
return { | ||
source: result, | ||
dictionary, | ||
}; | ||
return { | ||
source: result, | ||
dictionary, | ||
}; | ||
}; | ||
module.exports.sideEffectsImport = sideEffectsImport; |
Oops, something went wrong.