Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-ssr-friendly

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-ssr-friendly - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

2

package.json
{
"name": "eslint-plugin-ssr-friendly",
"version": "1.0.3",
"version": "1.0.4",
"license": "MIT",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

# eslint-plugin-ssr-friendly
ESLint plugin that detects incorrect use of DOM globals properties in your code in
order to properly do Server-Side-Rendering.
ESLint plugin that detects incorrect use of DOM globals in order to properly do SSR and in general share code between client-side JS and Node.js modules.

@@ -6,0 +5,0 @@ [![npm version](https://badge.fury.io/js/eslint-plugin-ssr-friendly.svg)](https://badge.fury.io/js/eslint-plugin-ssr-friendly)

@@ -1,2 +0,2 @@

const { browser, node } = require("globals");
const { browser: browserGlobals, node: nodeGlobals } = require("globals");
const pkg = require("../package.json");

@@ -7,3 +7,3 @@

const isDOMGlobalName = (name) => {
return name in browser && !(name in node);
return name in browserGlobals && !(name in nodeGlobals);
};

@@ -54,6 +54,5 @@

const node = reference.identifier;
const { name } = node;
const { parent } = node;
const { name, parent } = node;
// Make sure that `typeof window` is always allowed
// Make sure that `typeof MYVAR` is always allowed
if (parent.type === "UnaryExpression" && parent.operator === "typeof") {

@@ -144,63 +143,43 @@ return;

const rules = {
"no-dom-globals-in-module-scope": {
meta: {
type: "problem",
docs: {
description: "disallow use of DOM globals in module scope",
recommended: true,
const createRule = (name, description, defaultMessage) => {
return {
[name]: {
meta: {
type: "problem",
docs: {
description,
recommended: true,
},
messages: {
defaultMessage,
},
},
messages: {
defaultMessage:
"Use of DOM global '{{name}}' is forbidden in module scope",
},
create: createFn(name),
},
create: createFn("no-dom-globals-in-module-scope"),
},
"no-dom-globals-in-constructor": {
meta: {
type: "problem",
docs: {
description: "disallow use of DOM globals in class constructors",
recommended: true,
},
messages: {
defaultMessage:
"Use of DOM global '{{name}}' is forbidden in class constructors, consider moving this to componentDidMount() or equivalent for non React components",
},
},
create: createFn("no-dom-globals-in-constructor"),
},
"no-dom-globals-in-react-cc-render": {
meta: {
type: "problem",
docs: {
description:
"disallow use of DOM globals in render() method of a React class-component",
recommended: true,
},
messages: {
defaultMessage:
"Use of DOM global '{{name}}' is forbidden in render(), consider moving this to componentDidMount()",
},
},
create: createFn("no-dom-globals-in-react-cc-render"),
},
"no-dom-globals-in-react-fc": {
meta: {
type: "problem",
docs: {
description:
"disallow use of DOM globals in the render-cycle of a React FC",
recommended: true,
},
messages: {
defaultMessage:
"Use of DOM global '{{name}}' is forbidden in the render-cycle of a React FC, consider moving this inside useEffect()",
},
},
create: createFn("no-dom-globals-in-react-fc"),
},
};
};
const rules = {
...createRule(
"no-dom-globals-in-module-scope",
"disallow use of DOM globals in module scope",
"Use of DOM global '{{name}}' is forbidden in module scope"
),
...createRule(
"no-dom-globals-in-constructor",
"disallow use of DOM globals in class constructors",
"Use of DOM global '{{name}}' is forbidden in class constructors, consider moving this to componentDidMount() or equivalent for non React components"
),
...createRule(
"no-dom-globals-in-react-cc-render",
"disallow use of DOM glsobals in render() method of a React class-component",
"Use of DOM global '{{name}}' is forbidden in render(), consider moving this to componentDidMount()"
),
...createRule(
"no-dom-globals-in-react-fc",
"disallow use of DOM globals in the render-cycle of a React FC",
"Use of DOM global '{{name}}' is forbidden in the render-cycle of a React FC, consider moving this inside useEffect()"
),
};
module.exports = {

@@ -207,0 +186,0 @@ configs: {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc