@jobscale/eslint-plugin-standard 0.1.0 → 0.1.2

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.
@@ -5,7 +5,7 @@ name: Docker
5
5
  # separate terms of service, privacy policy, and support
6
6
  # documentation.
7
7
 
8
- # The workflow was triggered 412 times via automatically.
8
+ # The workflow was triggered 467 times via automatically.
9
9
 
10
10
  on:
11
11
  # schedule:
@@ -23,7 +23,7 @@ jobs:
23
23
  grep MH /proc/cpuinfo
24
24
  free -h
25
25
  curl https://inet-ip.info/ip
26
- npm i
26
+ npm i --force
27
27
  npm run build --if-present
28
28
  npm run lint --if-present
29
29
  npm test
package/Dockerfile CHANGED
@@ -3,7 +3,7 @@ SHELL ["bash", "-c"]
3
3
  WORKDIR /home/node
4
4
  USER node
5
5
  COPY --chown=node:staff package.json .
6
- RUN npm i --omit=dev
6
+ RUN npm i --omit=dev --legacy-peer-deps
7
7
  COPY --chown=node:staff eslint.config.js .
8
8
  COPY --chown=node:staff rules rules
9
9
  COPY --chown=node:staff index.js .
package/app/index.cjs ADDED
@@ -0,0 +1,54 @@
1
+ const https = require('https');
2
+ const http = require('http');
3
+ const { HttpsProxyAgent } = require('https-proxy-agent');
4
+ const { HttpProxyAgent } = require('http-proxy-agent');
5
+
6
+ class App {
7
+ get logger() {
8
+ const logger = {};
9
+ Object.entries(console).forEach(([key, value]) => {
10
+ logger[key] = (...argv) => value(`[${key.toUpperCase()}]`, ...argv);
11
+ });
12
+ return logger;
13
+ }
14
+
15
+ promiseGen() {
16
+ const prom = {};
17
+ prom.pending = new Promise((...argv) => { [prom.resolve, prom.reject] = argv; });
18
+ return prom;
19
+ }
20
+
21
+ async fetch(url, options) {
22
+ const instanceOptions = {};
23
+ Object.assign(instanceOptions, options);
24
+ const [protocol] = url.split(':');
25
+ const proxy = process.env[`${protocol}_proxy`];
26
+ if (proxy) {
27
+ const Agent = { https: HttpsProxyAgent, http: HttpProxyAgent };
28
+ instanceOptions.agent = new Agent[protocol](proxy);
29
+ }
30
+ const prom = this.promiseGen();
31
+ const fetch = { https, http };
32
+ fetch[protocol].get(url, instanceOptions, res => {
33
+ const { statusCode, statusMessage } = res;
34
+ const chunked = [];
35
+ res.on('data', chunk => {
36
+ chunked.push(chunk);
37
+ });
38
+ res.on('end', () => {
39
+ prom.resolve({
40
+ statusCode, statusMessage, body: chunked.join(''),
41
+ });
42
+ });
43
+ res.on('error', e => {
44
+ prom.reject(e);
45
+ });
46
+ });
47
+ return prom.pending;
48
+ }
49
+ }
50
+
51
+ export default {
52
+ app: new App(),
53
+ App,
54
+ };
package/app/index.js CHANGED
@@ -1,54 +1,50 @@
1
- const https = require('https');
2
- const http = require('http');
3
- const { HttpsProxyAgent } = require('https-proxy-agent');
4
- const { HttpProxyAgent } = require('http-proxy-agent');
1
+ import fs from 'fs';
2
+ import { ProxyAgent, fetch } from 'undici';
5
3
 
6
- class App {
7
- get logger() {
8
- const logger = {};
9
- Object.entries(console).forEach(([key, value]) => {
10
- logger[key] = (...argv) => value(`[${key.toUpperCase()}]`, ...argv);
11
- });
12
- return logger;
4
+ const operate = {
5
+ proxy: process.env.HTTPS_PROXY || process.env.https_proxy
6
+ || process.env.HTTP_PROXY || process.env.http_proxy,
7
+ };
8
+ if (operate.proxy) {
9
+ if (!operate.proxy.match('://')) operate.proxy = `http://${operate.proxy}`;
10
+ operate.dispatcher = new ProxyAgent(operate.proxy);
11
+ delete operate.proxy;
12
+ }
13
+ const certificate = () => {
14
+ if (!certificate.cache) {
15
+ certificate.cache = {
16
+ cert: fs.existsSync('certs/client-cert.pem') && fs.readFileSync('certs/client-cert.pem'),
17
+ key: fs.existsSync('certs/client-cert.key') && fs.readFileSync('certs/client-cert.key'),
18
+ ca: fs.existsSync('certs/ca-cert.pem') && fs.readFileSync('certs/ca-cert.pem'),
19
+ };
13
20
  }
21
+ return certificate.cache;
22
+ };
14
23
 
15
- promiseGen() {
16
- const prom = {};
17
- prom.pending = new Promise((...argv) => { [prom.resolve, prom.reject] = argv; });
18
- return prom;
24
+ export class Fetch {
25
+ fetch(input, opts = {}) {
26
+ const { timeout = 6_000, ...init } = opts;
27
+ const ac = new AbortController();
28
+ ac.terminate = () => clearTimeout(ac.terminate.tid);
29
+ ac.terminate.tid = setTimeout(() => ac.abort(), timeout);
30
+ return fetch(input, { ...init, signal: ac.signal })
31
+ .finally(() => ac.terminate());
19
32
  }
20
33
 
21
- async fetch(url, options) {
22
- const instanceOptions = {};
23
- Object.assign(instanceOptions, options);
24
- const [protocol] = url.split(':');
25
- const proxy = process.env[`${protocol}_proxy`];
26
- if (proxy) {
27
- const Agent = { https: HttpsProxyAgent, http: HttpProxyAgent };
28
- instanceOptions.agent = new Agent[protocol](proxy);
34
+ async customFetch(url, opts = {}, extra = { certificate }) {
35
+ if (extra.useCert) {
36
+ if (typeof extra.certificate === 'function') {
37
+ operate.certificate = extra.certificate();
38
+ } else {
39
+ operate.certificate = extra.certificate;
40
+ }
29
41
  }
30
- const prom = this.promiseGen();
31
- const fetch = { https, http };
32
- fetch[protocol].get(url, instanceOptions, res => {
33
- const { statusCode, statusMessage } = res;
34
- const chunked = [];
35
- res.on('data', chunk => {
36
- chunked.push(chunk);
37
- });
38
- res.on('end', () => {
39
- prom.resolve({
40
- statusCode, statusMessage, body: chunked.join(''),
41
- });
42
- });
43
- res.on('error', e => {
44
- prom.reject(e);
45
- });
42
+ return this.fetch(url, {
43
+ ...operate,
44
+ ...opts,
46
45
  });
47
- return prom.pending;
48
46
  }
49
47
  }
50
48
 
51
- export default {
52
- app: new App(),
53
- App,
54
- };
49
+ const customFetch = (...args) => new Fetch().customFetch(...args);
50
+ export default customFetch;
package/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import globals from 'globals';
2
2
  import pluginJs from '@eslint/js';
3
- import importPlugin from 'eslint-plugin-import';
4
3
  import airbnbPractices from './rules/best-practices.js';
5
4
  import airbnbStrict from './rules/strict.js';
6
5
  import airbnbEs6 from './rules/es6.js';
@@ -61,15 +60,6 @@ const rules = {
61
60
  enforceForSequenceExpressions: true,
62
61
  enforceForNewInMemberExpressions: true,
63
62
  }],
64
-
65
- // --- import rule ---
66
- 'import/named': ['error'],
67
- 'import/default': ['error'],
68
- 'import/order': ['error'],
69
- 'import/no-duplicates': ['error'],
70
- 'import/newline-after-import': ['error'],
71
- 'import/no-mutable-exports': ['error'],
72
- 'import/extensions': ['error', 'always', { ignorePackages: true }],
73
63
  };
74
64
 
75
65
  const recommended = {
@@ -80,9 +70,6 @@ const recommended = {
80
70
  ecmaVersion: 'latest',
81
71
  sourceType: 'module',
82
72
  },
83
- plugins: {
84
- import: importPlugin,
85
- },
86
73
  rules: {
87
74
  ...airbnbPractices.rules,
88
75
  ...airbnbStrict.rules,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobscale/eslint-plugin-standard",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "eslint plugin standard",
5
5
  "keywords": [
6
6
  "eslint",
@@ -22,7 +22,8 @@
22
22
  "test"
23
23
  ],
24
24
  "dependencies": {
25
- "eslint-plugin-import": "^2.32.0"
25
+ "@eslint/js": "^10.0.1",
26
+ "globals": "^17.11.0"
26
27
  },
27
28
  "devDependencies": {
28
29
  "eslint": "^10.5.0",