Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only apply to modules #3

Merged
merged 3 commits into from
Jan 31, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
const { existsSync } = require('fs')
const { dirname, resolve } = require('path')

const extensions = ['js', 'ts', 'jsx', 'tsx']
tpluscode marked this conversation as resolved.
Show resolved Hide resolved

module.exports = {
configs: {
recommended: {
Expand All @@ -17,9 +22,9 @@ module.exports = {
const source = node.source;
if (!source) return;
const value = source.value;
if (!value) return;
if (!value || !value.startsWith('.') || value.endsWith('.js')) return;

if (value.startsWith('.') && !value.endsWith('.js')) {
if (!existsSync(resolve(dirname(context.getFilename()), value))) {
jordaaash marked this conversation as resolved.
Show resolved Hide resolved
context.report({
node,
message: 'Relative imports and exports must end with .js',
Expand Down