Skip to content

Commit

Permalink
chore: upgrade eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud committed Jul 10, 2024
1 parent d79b74d commit ccf7323
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 239 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

16 changes: 0 additions & 16 deletions .eslintrc

This file was deleted.

31 changes: 31 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import prettierConfig from "eslint-config-prettier";
import prettierPlugin from "eslint-plugin-prettier";
import globals from "globals";
import js from "@eslint/js";

export default [
js.configs.recommended,
prettierConfig,
{
plugins: {
prettier: prettierPlugin,
},
languageOptions: {
globals: {
...globals.node,
...globals.browser,
global: true,
},
},
},
{
ignores: [
"tap-snapshots/*",
"node_modules/*",
"modules/*",
"utils/*",
"dist/*",
"tmp/*",
],
},
];
4 changes: 2 additions & 2 deletions fixtures/modules/simple/app/views.js
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>`;
}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
],
"scripts": {
"test": "tap --disable-coverage --allow-empty-coverage",
"lint": "eslint . --ext=js",
"lint:fix": "eslint . --fix --ext=js"
"lint": "eslint ."
},
"repository": {
"type": "git",
Expand All @@ -37,10 +36,11 @@
"@semantic-release/changelog": "6.0.3",
"@semantic-release/git": "10.0.1",
"esbuild": "0.22.0",
"eslint": "8.57.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-plugin-import": "2.29.1",
"eslint": "9.6.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.1.3",
"fastify": "4.28.1",
"globals": "15.8.0",
"semantic-release": "23.1.1",
"tap": "20.0.3"
},
Expand Down
75 changes: 35 additions & 40 deletions src/plugin.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,51 @@
/* eslint-disable no-restricted-syntax */

import * as importMapPlugin from 'esbuild-plugin-import-map';
import { helpers } from '@eik/common';
import { request } from 'undici';
import * as importMapPlugin from "esbuild-plugin-import-map";
import { helpers } from "@eik/common";
import { request } from "undici";

const fetchImportMaps = async (urls = []) => {
try {
const maps = urls.map(async (map) => {
const {
statusCode,
body,
} = await request(map, { maxRedirections: 2 });

if (statusCode === 404) {
throw new Error('Import map could not be found on server');
} else if (statusCode >= 400 && statusCode < 500) {
throw new Error('Server rejected client request');
} else if (statusCode >= 500) {
throw new Error('Server error');
}
return body.json();
});
return await Promise.all(maps);
} catch (err) {
throw new Error(
`Unable to load import map file from server: ${err.message}`,
);
}
try {
const maps = urls.map(async (map) => {
const { statusCode, body } = await request(map, { maxRedirections: 2 });

if (statusCode === 404) {
throw new Error("Import map could not be found on server");
} else if (statusCode >= 400 && statusCode < 500) {
throw new Error("Server rejected client request");
} else if (statusCode >= 500) {
throw new Error("Server error");
}
return body.json();
});
return await Promise.all(maps);
} catch (err) {
throw new Error(
`Unable to load import map file from server: ${err.message}`
);
}
};

export async function load({
path = process.cwd(),
maps = [],
urls = [],
path = process.cwd(),
maps = [],
urls = [],
} = {}) {
const pMaps = Array.isArray(maps) ? maps : [maps];
const pUrls = Array.isArray(urls) ? urls : [urls];
const pMaps = Array.isArray(maps) ? maps : [maps];
const pUrls = Array.isArray(urls) ? urls : [urls];

const config = await helpers.getDefaults(path);
const config = await helpers.getDefaults(path);

const fetched = await fetchImportMaps([...config.map, ...pUrls]);
const mappings = pMaps.concat(fetched);
const fetched = await fetchImportMaps([...config.map, ...pUrls]);
const mappings = pMaps.concat(fetched);

await importMapPlugin.load(mappings);
await importMapPlugin.load(mappings);
}

export function clear() {
importMapPlugin.clear();
importMapPlugin.clear();
}

export function plugin() {
const obj = importMapPlugin.plugin();
obj.name = '@eik/esbuild-plugin';
return obj;
const obj = importMapPlugin.plugin();
obj.name = "@eik/esbuild-plugin";
return obj;
}
Loading

0 comments on commit ccf7323

Please sign in to comment.