@agilebot/eslint-plugin 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/index.js +59 -59
- package/lib/rules/import/monorepo.js +49 -49
- package/lib/rules/intl/id-unused.js +117 -117
- package/lib/rules/react/better-exhaustive-deps.js +1921 -1921
- package/lib/rules/react/prefer-named-property-access.js +105 -105
- package/lib/rules/tss/class-naming.js +43 -43
- package/lib/rules/tss/no-color-value.js +58 -58
- package/lib/rules/tss/unused-classes.js +108 -108
- package/lib/util/intl.js +127 -127
- package/lib/util/translations.js +66 -66
- package/lib/util/tss.js +109 -109
- package/package.json +2 -5
- package/lib/util/import.js +0 -71
package/lib/util/import.js
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
const path = require('node:path');
|
2
|
-
const jiti = require('jiti');
|
3
|
-
const { transform } = require('sucrase');
|
4
|
-
const { getTsconfig } = require('get-tsconfig');
|
5
|
-
|
6
|
-
/**
|
7
|
-
* import ts module, like require, but support ts
|
8
|
-
* @param {*} modulePath - module path
|
9
|
-
*/
|
10
|
-
function tsImport(modulePath) {
|
11
|
-
if (!modulePath) {
|
12
|
-
return;
|
13
|
-
}
|
14
|
-
/** try to delete cache first */
|
15
|
-
try {
|
16
|
-
if (require.cache[modulePath]) {
|
17
|
-
delete require.cache[modulePath];
|
18
|
-
}
|
19
|
-
} catch (err) {
|
20
|
-
/* empty */
|
21
|
-
}
|
22
|
-
|
23
|
-
try {
|
24
|
-
return require(modulePath);
|
25
|
-
} catch (err) {
|
26
|
-
const tsconfig = getTsconfig(modulePath);
|
27
|
-
const { paths, baseUrl } = tsconfig.config.compilerOptions;
|
28
|
-
let basePath = path.dirname(tsconfig.path);
|
29
|
-
basePath = path.resolve(basePath, baseUrl);
|
30
|
-
|
31
|
-
const alias = resolveTsconfigPathsToAlias(paths, basePath);
|
32
|
-
|
33
|
-
return jiti(__filename, {
|
34
|
-
interopDefault: true,
|
35
|
-
cache: false,
|
36
|
-
debug: !!process.env.DEBUG,
|
37
|
-
transform: options => {
|
38
|
-
return transform(options.source, {
|
39
|
-
transforms: ['imports', 'typescript']
|
40
|
-
});
|
41
|
-
},
|
42
|
-
alias
|
43
|
-
})(modulePath);
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
|
-
/**
|
48
|
-
* Resolve tsconfig.json paths to Webpack aliases
|
49
|
-
* @param {string} paths - tsconfig.json paths
|
50
|
-
* @param {string} basePath - Path from tsconfig to Webpack config to create absolute aliases
|
51
|
-
* @return {object} - Webpack alias config
|
52
|
-
*/
|
53
|
-
function resolveTsconfigPathsToAlias(paths, basePath = __dirname) {
|
54
|
-
const aliases = {};
|
55
|
-
|
56
|
-
Object.keys(paths).forEach(item => {
|
57
|
-
const key = item.replace('/*', '');
|
58
|
-
const value = path.resolve(
|
59
|
-
basePath,
|
60
|
-
paths[item][0].replace('/*', '').replace('*', '')
|
61
|
-
);
|
62
|
-
|
63
|
-
aliases[key] = value;
|
64
|
-
});
|
65
|
-
|
66
|
-
return aliases;
|
67
|
-
}
|
68
|
-
|
69
|
-
module.exports = {
|
70
|
-
tsImport
|
71
|
-
};
|