@bedrockio/eslint-plugin 1.4.9 → 1.5.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/dist/cjs/imports.js +63 -0
- package/dist/cjs/index.js +16 -9
- package/dist/cjs/jest.js +1 -1
- package/dist/cjs/mdx.js +4 -2
- package/dist/cjs/node.js +29 -0
- package/dist/cjs/react.js +2 -1
- package/dist/cjs/recommended.js +2 -8
- package/dist/cjs/resolvers/vite.js +175 -0
- package/dist/cjs/typescript.js +18 -22
- package/dist/cjs/vite.js +29 -0
- package/dist/cjs/webpack.js +36 -0
- package/dist/esm/imports.js +56 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/jest.js +17 -0
- package/dist/esm/mdx.js +21 -0
- package/dist/esm/node.js +22 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/react.js +37 -0
- package/dist/esm/recommended.js +17 -0
- package/dist/esm/resolvers/vite.js +167 -0
- package/dist/esm/typescript.js +27 -0
- package/dist/esm/vite.js +22 -0
- package/dist/esm/webpack.js +29 -0
- package/package.json +13 -11
- package/src/imports.js +79 -0
- package/src/index.js +8 -6
- package/src/jest.js +1 -2
- package/src/mdx.js +4 -2
- package/src/{node-imports.js → node.js} +4 -5
- package/src/react.js +2 -1
- package/src/recommended.js +1 -7
- package/src/resolvers/vite.js +193 -0
- package/src/typescript.js +18 -21
- package/src/vite.js +23 -0
- package/src/{webpack-imports.js → webpack.js} +4 -6
- package/dist/cjs/importRules.js +0 -50
- package/dist/cjs/node-imports.js +0 -31
- package/dist/cjs/vite-imports.js +0 -47
- package/dist/cjs/webpack-imports.js +0 -39
- package/src/importRules.js +0 -65
- package/src/vite-imports.js +0 -45
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var plugin = _interopRequireWildcard(require("eslint-plugin-import"));
|
|
8
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
9
|
+
var _default = exports.default = {
|
|
10
|
+
...plugin.flatConfigs.recommended,
|
|
11
|
+
name: 'imports',
|
|
12
|
+
ignores: ['node_modules/**/*', '**/dist/**/*', '**/*.d.ts'],
|
|
13
|
+
languageOptions: {
|
|
14
|
+
ecmaVersion: 'latest',
|
|
15
|
+
sourceType: 'module'
|
|
16
|
+
},
|
|
17
|
+
rules: {
|
|
18
|
+
...plugin.flatConfigs.recommended.rules,
|
|
19
|
+
'import/namespace': 'off',
|
|
20
|
+
'import/no-unresolved': 'warn',
|
|
21
|
+
'import/no-named-as-default-member': 'off',
|
|
22
|
+
'import/first': 'warn',
|
|
23
|
+
'import/order': ['warn', {
|
|
24
|
+
'newlines-between': 'always-and-inside-groups',
|
|
25
|
+
sortTypesGroup: true,
|
|
26
|
+
alphabetize: {
|
|
27
|
+
order: 'asc',
|
|
28
|
+
caseInsensitive: false
|
|
29
|
+
},
|
|
30
|
+
named: true,
|
|
31
|
+
warnOnUnassignedImports: true,
|
|
32
|
+
consolidateIslands: 'inside-groups',
|
|
33
|
+
groups: ['builtin', 'unknown', 'external', 'internal', ['parent', 'sibling'], 'index', 'object', 'type'],
|
|
34
|
+
pathGroups: [{
|
|
35
|
+
pattern: 'semantic',
|
|
36
|
+
group: 'external'
|
|
37
|
+
}, {
|
|
38
|
+
pattern: '+(stores|helpers|layouts|@stores|@helpers|@layouts){,/**}',
|
|
39
|
+
group: 'internal',
|
|
40
|
+
position: 'before'
|
|
41
|
+
}, {
|
|
42
|
+
pattern: '+(screens|modals|components|@screens|@modals|@components){,/**}',
|
|
43
|
+
group: 'internal'
|
|
44
|
+
}, {
|
|
45
|
+
pattern: '+(hooks|@hooks|utils|@utils){,/**}',
|
|
46
|
+
group: 'internal',
|
|
47
|
+
position: 'after'
|
|
48
|
+
}, {
|
|
49
|
+
pattern: '+(assets|@assets){,**}',
|
|
50
|
+
group: 'sibling',
|
|
51
|
+
position: 'after'
|
|
52
|
+
}, {
|
|
53
|
+
pattern: '**/*.+(css|less|scss|png|jpg|svg|json)',
|
|
54
|
+
group: 'type',
|
|
55
|
+
position: 'after'
|
|
56
|
+
}, {
|
|
57
|
+
pattern: './**/*.+(css|less|scss|png|jpg|svg|json)',
|
|
58
|
+
group: 'type',
|
|
59
|
+
position: 'after'
|
|
60
|
+
}]
|
|
61
|
+
}]
|
|
62
|
+
}
|
|
63
|
+
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "imports", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _imports.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "jest", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function () {
|
|
@@ -15,10 +21,10 @@ Object.defineProperty(exports, "mdx", {
|
|
|
15
21
|
return _mdx.default;
|
|
16
22
|
}
|
|
17
23
|
});
|
|
18
|
-
Object.defineProperty(exports, "
|
|
24
|
+
Object.defineProperty(exports, "node", {
|
|
19
25
|
enumerable: true,
|
|
20
26
|
get: function () {
|
|
21
|
-
return
|
|
27
|
+
return _node.default;
|
|
22
28
|
}
|
|
23
29
|
});
|
|
24
30
|
Object.defineProperty(exports, "react", {
|
|
@@ -39,16 +45,16 @@ Object.defineProperty(exports, "typescript", {
|
|
|
39
45
|
return _typescript.default;
|
|
40
46
|
}
|
|
41
47
|
});
|
|
42
|
-
Object.defineProperty(exports, "
|
|
48
|
+
Object.defineProperty(exports, "vite", {
|
|
43
49
|
enumerable: true,
|
|
44
50
|
get: function () {
|
|
45
|
-
return
|
|
51
|
+
return _vite.default;
|
|
46
52
|
}
|
|
47
53
|
});
|
|
48
|
-
Object.defineProperty(exports, "
|
|
54
|
+
Object.defineProperty(exports, "webpack", {
|
|
49
55
|
enumerable: true,
|
|
50
56
|
get: function () {
|
|
51
|
-
return
|
|
57
|
+
return _webpack.default;
|
|
52
58
|
}
|
|
53
59
|
});
|
|
54
60
|
var _recommended = _interopRequireDefault(require("./recommended.js"));
|
|
@@ -56,7 +62,8 @@ var _react = _interopRequireDefault(require("./react.js"));
|
|
|
56
62
|
var _jest = _interopRequireDefault(require("./jest.js"));
|
|
57
63
|
var _mdx = _interopRequireDefault(require("./mdx.js"));
|
|
58
64
|
var _typescript = _interopRequireDefault(require("./typescript.js"));
|
|
59
|
-
var
|
|
60
|
-
var
|
|
61
|
-
var
|
|
65
|
+
var _node = _interopRequireDefault(require("./node.js"));
|
|
66
|
+
var _vite = _interopRequireDefault(require("./vite.js"));
|
|
67
|
+
var _webpack = _interopRequireDefault(require("./webpack.js"));
|
|
68
|
+
var _imports = _interopRequireDefault(require("./imports.js"));
|
|
62
69
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
package/dist/cjs/jest.js
CHANGED
|
@@ -8,7 +8,7 @@ var _eslintPluginJest = _interopRequireDefault(require("eslint-plugin-jest"));
|
|
|
8
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
var _default = exports.default = {
|
|
10
10
|
..._eslintPluginJest.default.configs['flat/recommended'],
|
|
11
|
-
|
|
11
|
+
name: 'jest',
|
|
12
12
|
files: ['**/test*/**/*.{js,jsx,ts,tsx}', '**/__tests__/**/*.{js,jsx,ts,tsx}', '**/__mocks__/**/*.{js,jsx,ts,tsx}', '**/*.test.js', '**/*.spec.js'],
|
|
13
13
|
languageOptions: {
|
|
14
14
|
globals: _eslintPluginJest.default.environments.globals.globals
|
package/dist/cjs/mdx.js
CHANGED
|
@@ -8,6 +8,7 @@ var mdx = _interopRequireWildcard(require("eslint-plugin-mdx"));
|
|
|
8
8
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
9
9
|
const plugin = {
|
|
10
10
|
...mdx.flat,
|
|
11
|
+
name: 'mdx',
|
|
11
12
|
files: ['**/*.mdx'],
|
|
12
13
|
ignores: ['node_modules/**/*', '**/dist/**/*', '**/*.d.ts'],
|
|
13
14
|
processor: mdx.createRemarkProcessor({
|
|
@@ -15,8 +16,9 @@ const plugin = {
|
|
|
15
16
|
}),
|
|
16
17
|
rules: {
|
|
17
18
|
...mdx.flat.rules,
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
// Note this seems to be causing
|
|
20
|
+
// issues in the resolve so disable it.
|
|
21
|
+
'import/named': 'off',
|
|
20
22
|
'no-unused-expressions': 'off'
|
|
21
23
|
}
|
|
22
24
|
};
|
package/dist/cjs/node.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _globals = _interopRequireDefault(require("globals"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
var _default = exports.default = {
|
|
10
|
+
name: 'node',
|
|
11
|
+
files: ['**/*.{js,jsx}'],
|
|
12
|
+
ignores: ['node_modules/**/*', '**/dist/**/*', '**/*.d.ts'],
|
|
13
|
+
languageOptions: {
|
|
14
|
+
ecmaVersion: 'latest',
|
|
15
|
+
sourceType: 'module'
|
|
16
|
+
},
|
|
17
|
+
languageOptions: {
|
|
18
|
+
globals: _globals.default.node
|
|
19
|
+
},
|
|
20
|
+
settings: {
|
|
21
|
+
'import/resolver': {
|
|
22
|
+
exports: true,
|
|
23
|
+
node: {
|
|
24
|
+
moduleDirectory: ['node_modules', 'src'],
|
|
25
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json', '.css', '.less', '.png', '.jpg', '.jpeg', '.gif', '.svg', '.webp', '.webm', '.mp4']
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
package/dist/cjs/react.js
CHANGED
|
@@ -7,7 +7,8 @@ exports.default = void 0;
|
|
|
7
7
|
var _eslintPluginReact = _interopRequireDefault(require("eslint-plugin-react"));
|
|
8
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
var _default = exports.default = {
|
|
10
|
-
|
|
10
|
+
name: 'react',
|
|
11
|
+
files: ['**/*.{js,jsx,ts,tsx,mdx}'],
|
|
11
12
|
ignores: ['node_modules/**/*', '**/dist/**/*', '**/*.d.ts'],
|
|
12
13
|
plugins: {
|
|
13
14
|
react: _eslintPluginReact.default
|
package/dist/cjs/recommended.js
CHANGED
|
@@ -5,22 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _js = _interopRequireDefault(require("@eslint/js"));
|
|
8
|
-
var _globals = _interopRequireDefault(require("globals"));
|
|
9
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
9
|
var _default = exports.default = {
|
|
11
|
-
|
|
10
|
+
name: 'recommended',
|
|
12
11
|
ignores: ['node_modules/**/*', '**/dist/**/*', '**/*.d.ts'],
|
|
13
12
|
languageOptions: {
|
|
14
13
|
ecmaVersion: 'latest',
|
|
15
|
-
sourceType: 'module'
|
|
16
|
-
globals: {
|
|
17
|
-
..._globals.default.node,
|
|
18
|
-
..._globals.default.browser
|
|
19
|
-
}
|
|
14
|
+
sourceType: 'module'
|
|
20
15
|
},
|
|
21
16
|
rules: {
|
|
22
17
|
..._js.default.configs.recommended.rules,
|
|
23
|
-
semi: 'error',
|
|
24
18
|
'no-console': 'warn',
|
|
25
19
|
curly: ['error', 'multi-line', 'consistent'],
|
|
26
20
|
'no-unused-vars': ['warn', {
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createViteImportResolver = createViteImportResolver;
|
|
7
|
+
exports.interfaceVersion = void 0;
|
|
8
|
+
exports.resolve = resolveImport;
|
|
9
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
10
|
+
var _resolve = _interopRequireDefault(require("resolve"));
|
|
11
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
12
|
+
var _nodeFs = require("node:fs");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
/**
|
|
15
|
+
* Patched Vite resolver for eslint-plugin-import.
|
|
16
|
+
*
|
|
17
|
+
* Based on `eslint-import-resolver-vite`:
|
|
18
|
+
* https://github.com/pzmosquito/eslint-import-resolver-vite
|
|
19
|
+
*
|
|
20
|
+
* The upstream resolver replaces every matching path segment when applying
|
|
21
|
+
* aliases. This breaks imports like `docs/components/...` when both `docs`
|
|
22
|
+
* and `components` are aliases, producing invalid paths.
|
|
23
|
+
*
|
|
24
|
+
* This version fixes the behavior so aliases only match the **leading prefix**
|
|
25
|
+
* of the import specifier, which matches how Vite/Rollup aliasing works.
|
|
26
|
+
*
|
|
27
|
+
* Additional improvements
|
|
28
|
+
* -----------------------
|
|
29
|
+
* - Supports both object and array alias forms used by Vite
|
|
30
|
+
* - Supports RegExp `find` entries in array aliases
|
|
31
|
+
* - Avoids rewriting absolute paths incorrectly
|
|
32
|
+
* - Cleans up root/publicDir resolution logic
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
const namespace = 'eslint-plugin-import:resolver:vite';
|
|
37
|
+
const log = (0, _debug.default)(namespace);
|
|
38
|
+
function loadViteConfig(config) {
|
|
39
|
+
if (!config) {
|
|
40
|
+
throw new Error("'config' option must be a path to a vite config file.");
|
|
41
|
+
}
|
|
42
|
+
const file = _nodePath.default.resolve(process.cwd(), config);
|
|
43
|
+
if (!(0, _nodeFs.existsSync)(file)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const mod = require(file);
|
|
47
|
+
return mod.default || mod;
|
|
48
|
+
}
|
|
49
|
+
function tryResolve(source, resolveOptions, label) {
|
|
50
|
+
log('resolving:\t', `(${label})`, source);
|
|
51
|
+
const resolvedPath = _resolve.default.sync(source, resolveOptions);
|
|
52
|
+
log('resolved:\t', resolvedPath);
|
|
53
|
+
return {
|
|
54
|
+
found: true,
|
|
55
|
+
path: resolvedPath
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function normalizeAliasEntries(alias) {
|
|
59
|
+
if (!alias) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
if (Array.isArray(alias)) {
|
|
63
|
+
return alias.filter(Boolean).map(entry => ({
|
|
64
|
+
find: entry.find,
|
|
65
|
+
replacement: entry.replacement
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
if (typeof alias === 'object') {
|
|
69
|
+
return Object.entries(alias).map(([find, replacement]) => ({
|
|
70
|
+
find,
|
|
71
|
+
replacement
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
throw new Error('The alias must be either an object, or an array of objects.');
|
|
75
|
+
}
|
|
76
|
+
function applyStringAlias(source, find, replacement) {
|
|
77
|
+
if (source === find) {
|
|
78
|
+
return replacement;
|
|
79
|
+
}
|
|
80
|
+
if (source.startsWith(find + '/')) {
|
|
81
|
+
return replacement + source.slice(find.length);
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
function processAlias(alias, source) {
|
|
86
|
+
const entries = normalizeAliasEntries(alias);
|
|
87
|
+
for (const {
|
|
88
|
+
find,
|
|
89
|
+
replacement
|
|
90
|
+
} of entries) {
|
|
91
|
+
if (!find || !replacement) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (find instanceof RegExp) {
|
|
95
|
+
if (find.test(source)) {
|
|
96
|
+
return source.replace(find, replacement);
|
|
97
|
+
}
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (typeof find === 'string') {
|
|
101
|
+
const resolved = applyStringAlias(source, find, replacement);
|
|
102
|
+
if (resolved) {
|
|
103
|
+
return resolved;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return source;
|
|
108
|
+
}
|
|
109
|
+
function resolveRoot(root) {
|
|
110
|
+
if (!root) {
|
|
111
|
+
return process.cwd();
|
|
112
|
+
}
|
|
113
|
+
if (_nodePath.default.isAbsolute(root)) {
|
|
114
|
+
return root;
|
|
115
|
+
}
|
|
116
|
+
return _nodePath.default.resolve(process.cwd(), root);
|
|
117
|
+
}
|
|
118
|
+
const interfaceVersion = exports.interfaceVersion = 2;
|
|
119
|
+
function resolveImport(source, file, config) {
|
|
120
|
+
log('\nin file:\t', file);
|
|
121
|
+
if (_resolve.default.isCore(source)) {
|
|
122
|
+
log('resolved:\t', source);
|
|
123
|
+
return {
|
|
124
|
+
found: true,
|
|
125
|
+
path: null
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const viteConfig = loadViteConfig(config?.config);
|
|
129
|
+
if (!viteConfig) {
|
|
130
|
+
return {
|
|
131
|
+
found: false
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
const defaultExtensions = ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json'];
|
|
135
|
+
const viteResolve = viteConfig.resolve || {};
|
|
136
|
+
const extensions = viteResolve.extensions || defaultExtensions;
|
|
137
|
+
const resolveOptions = {
|
|
138
|
+
basedir: _nodePath.default.dirname(file),
|
|
139
|
+
extensions
|
|
140
|
+
};
|
|
141
|
+
try {
|
|
142
|
+
return tryResolve(source, resolveOptions, 'as is');
|
|
143
|
+
} catch {}
|
|
144
|
+
const parsedSource = processAlias(viteResolve.alias, source);
|
|
145
|
+
if (parsedSource !== source) {
|
|
146
|
+
try {
|
|
147
|
+
return tryResolve(parsedSource, resolveOptions, 'with alias');
|
|
148
|
+
} catch {}
|
|
149
|
+
}
|
|
150
|
+
if (_nodePath.default.isAbsolute(parsedSource)) {
|
|
151
|
+
try {
|
|
152
|
+
return tryResolve(parsedSource, resolveOptions, 'absolute path');
|
|
153
|
+
} catch {}
|
|
154
|
+
}
|
|
155
|
+
if (viteConfig.publicDir !== false) {
|
|
156
|
+
const rootDir = resolveRoot(viteConfig.root);
|
|
157
|
+
const publicDir = viteConfig.publicDir || 'public';
|
|
158
|
+
const publicBase = _nodePath.default.isAbsolute(publicDir) ? publicDir : _nodePath.default.resolve(rootDir, publicDir);
|
|
159
|
+
const publicSource = _nodePath.default.resolve(publicBase, parsedSource);
|
|
160
|
+
try {
|
|
161
|
+
return tryResolve(publicSource, resolveOptions, 'in public directory');
|
|
162
|
+
} catch {}
|
|
163
|
+
}
|
|
164
|
+
log('ERROR:\t', 'Unable to resolve');
|
|
165
|
+
return {
|
|
166
|
+
found: false
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function createViteImportResolver(config) {
|
|
170
|
+
return {
|
|
171
|
+
interfaceVersion: 3,
|
|
172
|
+
name: 'eslint-import-resolver-vite',
|
|
173
|
+
resolve: (source, file) => resolveImport(source, file, config)
|
|
174
|
+
};
|
|
175
|
+
}
|
package/dist/cjs/typescript.js
CHANGED
|
@@ -4,35 +4,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
let importError;
|
|
10
|
-
try {
|
|
11
|
-
// This is to make this package optional.
|
|
12
|
-
ts = await Promise.resolve().then(() => _interopRequireWildcard(require('typescript-eslint')));
|
|
13
|
-
} catch (err) {
|
|
14
|
-
// Package not installed. Capture error to
|
|
15
|
-
// allow re-throwing if plugin is accessed,
|
|
16
|
-
// otherwise allow it to export silently.
|
|
17
|
-
importError = err;
|
|
18
|
-
}
|
|
7
|
+
var _typescriptEslint = _interopRequireDefault(require("typescript-eslint"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
9
|
var _default = exports.default = {
|
|
10
|
+
name: 'typescript',
|
|
20
11
|
files: ['**/*.{ts,tsx}'],
|
|
21
12
|
ignores: ['node_modules/**/*', '**/dist/**/*', '**/*.d.ts'],
|
|
22
13
|
languageOptions: {
|
|
23
|
-
|
|
14
|
+
ecmaVersion: 'latest',
|
|
15
|
+
sourceType: 'module',
|
|
16
|
+
parser: _typescriptEslint.default.parser
|
|
24
17
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
throw importError;
|
|
28
|
-
}
|
|
29
|
-
return {
|
|
30
|
-
'@typescript-eslint': ts?.plugin
|
|
31
|
-
};
|
|
18
|
+
plugins: {
|
|
19
|
+
'@typescript-eslint': _typescriptEslint.default.plugin
|
|
32
20
|
},
|
|
33
21
|
rules: {
|
|
34
|
-
|
|
22
|
+
// Pull in `eslint-recommended` adjustments from typescript-eslint.
|
|
23
|
+
// This disables core ESLint rules that conflict with TypeScript (e.g. no-undef).
|
|
24
|
+
..._typescriptEslint.default.plugin.configs['eslint-recommended'].overrides[0].rules,
|
|
25
|
+
// Pull in the TypeScript recommended rules themselves.
|
|
26
|
+
// Avoid the flat config version as it's an array.
|
|
27
|
+
..._typescriptEslint.default.plugin.configs.recommended.rules,
|
|
35
28
|
'@typescript-eslint/no-unused-vars': 'warn',
|
|
36
|
-
'@typescript-eslint/no-explicit-any': 'off'
|
|
29
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
30
|
+
// The above configs try to slip this rule in there despite it
|
|
31
|
+
// not being part of eslint-recommended so force it off again.
|
|
32
|
+
'prefer-const': 'off'
|
|
37
33
|
}
|
|
38
34
|
};
|
package/dist/cjs/vite.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _globals = _interopRequireDefault(require("globals"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
var _default = exports.default = {
|
|
10
|
+
name: 'vite',
|
|
11
|
+
files: ['**/*.{js,jsx,ts,tsx,mdx}'],
|
|
12
|
+
ignores: ['node_modules/**/*', '**/dist/**/*', '**/*.d.ts'],
|
|
13
|
+
languageOptions: {
|
|
14
|
+
ecmaVersion: 'latest',
|
|
15
|
+
sourceType: 'module',
|
|
16
|
+
globals: _globals.default.browser
|
|
17
|
+
},
|
|
18
|
+
settings: {
|
|
19
|
+
'import/resolver': {
|
|
20
|
+
exports: true,
|
|
21
|
+
['@bedrockio/eslint-plugin/resolvers/vite']: {
|
|
22
|
+
config: './vite.config.js'
|
|
23
|
+
},
|
|
24
|
+
node: {
|
|
25
|
+
moduleDirectory: ['node_modules', 'src']
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _globals = _interopRequireDefault(require("globals"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
var _default = exports.default = {
|
|
10
|
+
name: 'webpack',
|
|
11
|
+
files: ['**/*.{js,jsx,ts,tsx,mdx}'],
|
|
12
|
+
ignores: ['node_modules/**/*', '**/dist/**/*', '**/*.d.ts'],
|
|
13
|
+
languageOptions: {
|
|
14
|
+
ecmaVersion: 'latest',
|
|
15
|
+
sourceType: 'module',
|
|
16
|
+
globals: _globals.default.browser
|
|
17
|
+
},
|
|
18
|
+
rules: {
|
|
19
|
+
'import/no-unresolved': ['warn', {
|
|
20
|
+
// package.json "style" may be used here which
|
|
21
|
+
// will resolve for webpack but not within the
|
|
22
|
+
// eslint plugin
|
|
23
|
+
ignore: ['\\.css$']
|
|
24
|
+
}]
|
|
25
|
+
},
|
|
26
|
+
settings: {
|
|
27
|
+
'import/resolver': {
|
|
28
|
+
webpack: {
|
|
29
|
+
config: './webpack.config.js'
|
|
30
|
+
},
|
|
31
|
+
node: {
|
|
32
|
+
moduleDirectory: ['node_modules', 'src']
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as plugin from 'eslint-plugin-import';
|
|
2
|
+
export default {
|
|
3
|
+
...plugin.flatConfigs.recommended,
|
|
4
|
+
name: 'imports',
|
|
5
|
+
ignores: ['node_modules/**/*', '**/dist/**/*', '**/*.d.ts'],
|
|
6
|
+
languageOptions: {
|
|
7
|
+
ecmaVersion: 'latest',
|
|
8
|
+
sourceType: 'module'
|
|
9
|
+
},
|
|
10
|
+
rules: {
|
|
11
|
+
...plugin.flatConfigs.recommended.rules,
|
|
12
|
+
'import/namespace': 'off',
|
|
13
|
+
'import/no-unresolved': 'warn',
|
|
14
|
+
'import/no-named-as-default-member': 'off',
|
|
15
|
+
'import/first': 'warn',
|
|
16
|
+
'import/order': ['warn', {
|
|
17
|
+
'newlines-between': 'always-and-inside-groups',
|
|
18
|
+
sortTypesGroup: true,
|
|
19
|
+
alphabetize: {
|
|
20
|
+
order: 'asc',
|
|
21
|
+
caseInsensitive: false
|
|
22
|
+
},
|
|
23
|
+
named: true,
|
|
24
|
+
warnOnUnassignedImports: true,
|
|
25
|
+
consolidateIslands: 'inside-groups',
|
|
26
|
+
groups: ['builtin', 'unknown', 'external', 'internal', ['parent', 'sibling'], 'index', 'object', 'type'],
|
|
27
|
+
pathGroups: [{
|
|
28
|
+
pattern: 'semantic',
|
|
29
|
+
group: 'external'
|
|
30
|
+
}, {
|
|
31
|
+
pattern: '+(stores|helpers|layouts|@stores|@helpers|@layouts){,/**}',
|
|
32
|
+
group: 'internal',
|
|
33
|
+
position: 'before'
|
|
34
|
+
}, {
|
|
35
|
+
pattern: '+(screens|modals|components|@screens|@modals|@components){,/**}',
|
|
36
|
+
group: 'internal'
|
|
37
|
+
}, {
|
|
38
|
+
pattern: '+(hooks|@hooks|utils|@utils){,/**}',
|
|
39
|
+
group: 'internal',
|
|
40
|
+
position: 'after'
|
|
41
|
+
}, {
|
|
42
|
+
pattern: '+(assets|@assets){,**}',
|
|
43
|
+
group: 'sibling',
|
|
44
|
+
position: 'after'
|
|
45
|
+
}, {
|
|
46
|
+
pattern: '**/*.+(css|less|scss|png|jpg|svg|json)',
|
|
47
|
+
group: 'type',
|
|
48
|
+
position: 'after'
|
|
49
|
+
}, {
|
|
50
|
+
pattern: './**/*.+(css|less|scss|png|jpg|svg|json)',
|
|
51
|
+
group: 'type',
|
|
52
|
+
position: 'after'
|
|
53
|
+
}]
|
|
54
|
+
}]
|
|
55
|
+
}
|
|
56
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as recommended } from './recommended.js';
|
|
2
|
+
import { default as react } from './react.js';
|
|
3
|
+
import { default as jest } from './jest.js';
|
|
4
|
+
import { default as mdx } from './mdx.js';
|
|
5
|
+
import { default as typescript } from './typescript.js';
|
|
6
|
+
import { default as node } from './node.js';
|
|
7
|
+
import { default as vite } from './vite.js';
|
|
8
|
+
import { default as webpack } from './webpack.js';
|
|
9
|
+
import { default as imports } from './imports.js';
|
|
10
|
+
export { mdx, jest, react, node, vite, webpack, imports, typescript, recommended };
|
package/dist/esm/jest.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import plugin from 'eslint-plugin-jest';
|
|
2
|
+
export default {
|
|
3
|
+
...plugin.configs['flat/recommended'],
|
|
4
|
+
name: 'jest',
|
|
5
|
+
files: ['**/test*/**/*.{js,jsx,ts,tsx}', '**/__tests__/**/*.{js,jsx,ts,tsx}', '**/__mocks__/**/*.{js,jsx,ts,tsx}', '**/*.test.js', '**/*.spec.js'],
|
|
6
|
+
languageOptions: {
|
|
7
|
+
globals: plugin.environments.globals.globals
|
|
8
|
+
},
|
|
9
|
+
rules: {
|
|
10
|
+
'jest/expect-expect': ['error', {
|
|
11
|
+
assertFunctionNames: ['expect*', 'assert*']
|
|
12
|
+
}],
|
|
13
|
+
'jest/no-focused-tests': 'off',
|
|
14
|
+
'jest/no-disabled-tests': 'off',
|
|
15
|
+
'jest/no-conditional-expect': 'off'
|
|
16
|
+
}
|
|
17
|
+
};
|
package/dist/esm/mdx.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as mdx from 'eslint-plugin-mdx';
|
|
2
|
+
const plugin = {
|
|
3
|
+
...mdx.flat,
|
|
4
|
+
name: 'mdx',
|
|
5
|
+
files: ['**/*.mdx'],
|
|
6
|
+
ignores: ['node_modules/**/*', '**/dist/**/*', '**/*.d.ts'],
|
|
7
|
+
processor: mdx.createRemarkProcessor({
|
|
8
|
+
lintCodeBlocks: true
|
|
9
|
+
}),
|
|
10
|
+
rules: {
|
|
11
|
+
...mdx.flat.rules,
|
|
12
|
+
// Note this seems to be causing
|
|
13
|
+
// issues in the resolve so disable it.
|
|
14
|
+
'import/named': 'off',
|
|
15
|
+
'no-unused-expressions': 'off'
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(plugin, 'codeBlocks', {
|
|
19
|
+
value: mdx.flatCodeBlocks
|
|
20
|
+
});
|
|
21
|
+
export default plugin;
|
package/dist/esm/node.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import globals from 'globals';
|
|
2
|
+
export default {
|
|
3
|
+
name: 'node',
|
|
4
|
+
files: ['**/*.{js,jsx}'],
|
|
5
|
+
ignores: ['node_modules/**/*', '**/dist/**/*', '**/*.d.ts'],
|
|
6
|
+
languageOptions: {
|
|
7
|
+
ecmaVersion: 'latest',
|
|
8
|
+
sourceType: 'module'
|
|
9
|
+
},
|
|
10
|
+
languageOptions: {
|
|
11
|
+
globals: globals.node
|
|
12
|
+
},
|
|
13
|
+
settings: {
|
|
14
|
+
'import/resolver': {
|
|
15
|
+
exports: true,
|
|
16
|
+
node: {
|
|
17
|
+
moduleDirectory: ['node_modules', 'src'],
|
|
18
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json', '.css', '.less', '.png', '.jpg', '.jpeg', '.gif', '.svg', '.webp', '.webm', '.mp4']
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "module" }
|