Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epidemian
GitHub Repository: epidemian/eslint-plugin-import
Path: blob/main/src/rules/no-absolute-path.js
829 views
1
import moduleVisitor, { makeOptionsSchema } from 'eslint-module-utils/moduleVisitor';
2
import { isAbsolute } from '../core/importType';
3
import docsUrl from '../docsUrl';
4
5
module.exports = {
6
meta: {
7
type: 'suggestion',
8
docs: {
9
url: docsUrl('no-absolute-path'),
10
},
11
schema: [ makeOptionsSchema() ],
12
},
13
14
create(context) {
15
function reportIfAbsolute(source) {
16
if (isAbsolute(source.value)) {
17
context.report(source, 'Do not import modules using an absolute path');
18
}
19
}
20
21
const options = Object.assign({ esmodule: true, commonjs: true }, context.options[0]);
22
return moduleVisitor(reportIfAbsolute, options);
23
},
24
};
25
26