@jamesblanksby/toolkit 1.3.0 → 1.4.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/build/sass.js +9 -4
- package/build/script.js +5 -2
- package/eslint.config.mjs +36 -0
- package/package.json +1 -1
- package/.eslintrc.json +0 -18
package/build/sass.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import url from 'url';
|
|
3
4
|
|
|
4
5
|
import * as sass from 'sass';
|
|
5
6
|
|
|
@@ -13,7 +14,7 @@ async function findMainPaths(source) {
|
|
|
13
14
|
|
|
14
15
|
const matchedFiles = files.filter((file) => !file.startsWith('_') && file.endsWith('.scss'));
|
|
15
16
|
const fullPaths = matchedFiles.map((file) => path.join(directory, file));
|
|
16
|
-
|
|
17
|
+
|
|
17
18
|
matches.push(...fullPaths);
|
|
18
19
|
|
|
19
20
|
const parentDir = path.dirname(directory);
|
|
@@ -39,21 +40,25 @@ async function createCssAndMapFile(css, map, source) {
|
|
|
39
40
|
|
|
40
41
|
const sassDir = path.resolve(source, './../..');
|
|
41
42
|
map.sources = map.sources.map((source) => source.replace(`file://${sassDir}`, '..'));
|
|
42
|
-
|
|
43
|
+
|
|
43
44
|
await fs.writeFile(mapPath, JSON.stringify(map));
|
|
44
45
|
|
|
45
46
|
return file;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
|
|
49
49
|
export default async function* sassCompile(files) {
|
|
50
50
|
for await (const file of files) {
|
|
51
51
|
const sassPaths = await findMainPaths(file.path);
|
|
52
52
|
|
|
53
|
+
const modulesDir = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), './../../..');
|
|
54
|
+
|
|
53
55
|
for (const sassPath of sassPaths) {
|
|
54
56
|
let result;
|
|
55
57
|
try {
|
|
56
|
-
result = sass.compile(sassPath, {
|
|
58
|
+
result = sass.compile(sassPath, {
|
|
59
|
+
loadPaths: [modulesDir,],
|
|
60
|
+
sourceMap: true,
|
|
61
|
+
});
|
|
57
62
|
} catch (error) {
|
|
58
63
|
throw new Error(error.message);
|
|
59
64
|
}
|
package/build/script.js
CHANGED
|
@@ -6,11 +6,14 @@ import uglifyjs from 'uglify-js';
|
|
|
6
6
|
|
|
7
7
|
import { MemoryFile } from './../src/file.js';
|
|
8
8
|
|
|
9
|
+
const { PWD, } = process.env;
|
|
10
|
+
|
|
9
11
|
async function scriptLint(files) {
|
|
10
12
|
const configDir = path.dirname(url.fileURLToPath(import.meta.url));
|
|
11
13
|
|
|
12
14
|
const eslint = new ESLint({
|
|
13
|
-
|
|
15
|
+
cwd: PWD,
|
|
16
|
+
overrideConfigFile: `${configDir}/../eslint.config.mjs`,
|
|
14
17
|
});
|
|
15
18
|
|
|
16
19
|
let results = [];
|
|
@@ -19,7 +22,7 @@ async function scriptLint(files) {
|
|
|
19
22
|
file = await file.read();
|
|
20
23
|
|
|
21
24
|
const fileResult = await eslint.lintText(file.contents, { filePath: file.path, });
|
|
22
|
-
results
|
|
25
|
+
results.push(...fileResult);
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
const formatter = await eslint.loadFormatter();
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import globals from 'globals';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import js from '@eslint/js';
|
|
5
|
+
import { FlatCompat } from '@eslint/eslintrc';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
const compat = new FlatCompat({
|
|
10
|
+
baseDirectory: __dirname,
|
|
11
|
+
recommendedConfig: js.configs.recommended,
|
|
12
|
+
allConfig: js.configs.all
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export default [...compat.extends('eslint:recommended'), {
|
|
16
|
+
ignores: [
|
|
17
|
+
'node_modules/*',
|
|
18
|
+
],
|
|
19
|
+
|
|
20
|
+
languageOptions: {
|
|
21
|
+
globals: {
|
|
22
|
+
...globals.browser,
|
|
23
|
+
...globals.jquery,
|
|
24
|
+
...globals.node,
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
ecmaVersion: 'latest',
|
|
28
|
+
sourceType: 'module',
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
rules: {
|
|
32
|
+
'no-async-promise-executor': 'off',
|
|
33
|
+
'no-empty': 'off',
|
|
34
|
+
'no-unused-vars': 'warn',
|
|
35
|
+
},
|
|
36
|
+
}];
|
package/package.json
CHANGED
package/.eslintrc.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": true,
|
|
4
|
-
"es2021": true,
|
|
5
|
-
"jquery": true,
|
|
6
|
-
"node": true
|
|
7
|
-
},
|
|
8
|
-
"extends": "eslint:recommended",
|
|
9
|
-
"parserOptions": {
|
|
10
|
-
"ecmaVersion": "latest",
|
|
11
|
-
"sourceType": "module"
|
|
12
|
-
},
|
|
13
|
-
"rules": {
|
|
14
|
-
"no-async-promise-executor": "off",
|
|
15
|
-
"no-empty": "off",
|
|
16
|
-
"no-unused-vars": "warn"
|
|
17
|
-
}
|
|
18
|
-
}
|