Skip to content

Commit

Permalink
ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed May 6, 2024
1 parent 461926e commit f34211f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# https://github.com/eslint/eslint/issues/17964#issuecomment-1879772142
tests/format/**/*.*
!tests/format/**/format.test.js
# TODO: Remove this in 2025
!tests/format/**/jsfmt.spec.js
tests/integration/cli/
test*.*
scripts/release/node_modules
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";

const path = require("path");

const legacyRunFormatTestCall = [
"CallExpression",
'[callee.type="Identifier"]',
Expand Down Expand Up @@ -34,6 +36,7 @@ const dirnamePropertySelector = [
const MESSAGE_ID_LEGACY_FUNCTION_NAME = "legacy-function-name";
const MESSAGE_ID_ARGUMENT = "dirname-argument";
const MESSAGE_ID_PROPERTY = "dirname-property";
const MESSAGE_ID_LEGACY_FILENAME = "legacy-filename";

module.exports = {
meta: {
Expand All @@ -47,6 +50,7 @@ module.exports = {
[MESSAGE_ID_ARGUMENT]: "Use `import.meta` instead of `__dirname`.",
[MESSAGE_ID_PROPERTY]:
"Use `importMeta: import.meta` instead of `dirname: __dirname`.",
[MESSAGE_ID_LEGACY_FILENAME]: "File should be named as 'format.test.js'.",
},
fixable: "code",
hasSuggestions: true,
Expand Down Expand Up @@ -78,6 +82,18 @@ module.exports = {
],
});
},
Program(node) {
const filename = path.basename(context.physicalFilename);
console.log({ filename });
if (filename === "format.test.js") {
return;
}

context.report({
node,
messageId: MESSAGE_ID_LEGACY_FILENAME,
});
},
};
},
};

0 comments on commit f34211f

Please sign in to comment.