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

feat: Add Node.JS/browser globals for node/react configs #23

Merged
merged 6 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .changeset/gorgeous-birds-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ktam/lint-react': patch
---

Add browser globals when parsing without TypeScript
5 changes: 5 additions & 0 deletions .changeset/red-cheetahs-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ktam/lint-node': patch
---

Add Node.js globals when parsing without TypeScript
8 changes: 7 additions & 1 deletion packages/lint-node/eslint.config.node.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// @ts-check

import globals from 'globals';

import prettierConfig from './eslint-configs/prettier.js';
import { generateTypescriptEslintConfig } from './eslint-configs/typescript.js';

/** @type {import('@typescript-eslint/utils/ts-eslint').FlatConfig.ConfigArray} */
export default [...generateTypescriptEslintConfig(), prettierConfig];
export default [
...generateTypescriptEslintConfig(),
{ languageOptions: { globals: globals.node } },
prettierConfig,
];
1 change: 1 addition & 0 deletions packages/lint-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"eslint-plugin-import-x": "4.6.1",
"eslint-plugin-perfectionist": "4.3.0",
"eslint-plugin-unicorn": "56.0.1",
"globals": "^15.14.0",
"prettier-plugin-packagejson": "2.5.6",
"typescript-eslint": "8.18.1"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/lint-react/eslint-configs/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import reactPlugin from 'eslint-plugin-react';
// @ts-ignore eslint-plugin-react-hooks does not have typings
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import tailwindPlugin from 'eslint-plugin-tailwindcss';
import globals from 'globals';
import tsEslint from 'typescript-eslint';

/** @type {GenerateTypescriptEslintConfigOptions} */
Expand All @@ -27,6 +28,7 @@ export const reactEslintConfig = tsEslint.config(
/** @type { Config } */ (reactPlugin.configs.flat?.['jsx-runtime']),
reactJsxA11yPlugin.flatConfigs.recommended,
],
languageOptions: { globals: globals.browser },
settings: {
react: {
version: 'detect',
Expand Down
1 change: 1 addition & 0 deletions packages/lint-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"eslint-plugin-react-hooks": "5.1.0",
"eslint-plugin-storybook": "0.11.1",
"eslint-plugin-tailwindcss": "3.17.5",
"globals": "^15.14.0",
"prettier-plugin-astro": "0.14.1",
"prettier-plugin-tailwindcss": "0.6.9",
"typescript-eslint": "8.18.1"
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading