no-atomics.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * @author Toru Nagashima <https://github.com/mysticatea>
  3. * See LICENSE file in root directory for full license.
  4. */
  5. "use strict"
  6. const { READ, ReferenceTracker } = require("eslint-utils")
  7. module.exports = {
  8. meta: {
  9. docs: {
  10. description: "disallow the `Atomics` class.",
  11. category: "ES2017",
  12. recommended: false,
  13. url:
  14. "http://mysticatea.github.io/eslint-plugin-es/rules/no-atomics.html",
  15. },
  16. fixable: null,
  17. schema: [],
  18. messages: {
  19. forbidden: "ES2017 '{{name}}' class is forbidden.",
  20. },
  21. },
  22. create(context) {
  23. return {
  24. "Program:exit"() {
  25. const tracker = new ReferenceTracker(context.getScope())
  26. for (const { node, path } of tracker.iterateGlobalReferences({
  27. Atomics: { [READ]: true },
  28. })) {
  29. context.report({
  30. node,
  31. messageId: "forbidden",
  32. data: { name: path.join(".") },
  33. })
  34. }
  35. },
  36. }
  37. },
  38. }