Skip to content

Commit

Permalink
feat(eslint-plugin): register @nx plugin internally in order to be ab…
Browse files Browse the repository at this point in the history
…le to consume our custom @nx/workspace-* lint rules (#30337)
  • Loading branch information
Hotell committed Jan 18, 2024
1 parent 400c92a commit 28dc770
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "chore(eslint-plugin): register @nx plugin internally in order to be able to consume our custom @nx/workspace-* lint rules",
"packageName": "@fluentui/eslint-plugin",
"email": "martinhochel@microsoft.com",
"dependentChangeType": "none"
}
12 changes: 11 additions & 1 deletion packages/eslint-plugin/src/configs/core.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @ts-check
const { __internal } = require('../internal');
const configHelpers = require('../utils/configHelpers');

/** @type {import("eslint").Linter.Config} */
Expand All @@ -13,7 +14,16 @@ const config = {
'prettier',
],
parser: '@typescript-eslint/parser',
plugins: ['import', '@fluentui', '@rnx-kit', '@typescript-eslint', 'deprecation', 'jest', 'jsdoc'],
plugins: [
'import',
'@fluentui',
'@rnx-kit',
'@typescript-eslint',
'deprecation',
'jest',
'jsdoc',
...__internal.plugins,
],
settings: {
'import/resolver': {
// @see https://github.com/alexgorbatchev/eslint-import-resolver-typescript#configuration
Expand Down
26 changes: 26 additions & 0 deletions packages/eslint-plugin/src/internal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function shouldRegisterInternal() {
try {
const hasNxEslintPlugin = require.resolve('@nx/eslint-plugin');
return Boolean(hasNxEslintPlugin);
} catch (err) {
return false;
}
}

const shouldRegister = shouldRegisterInternal();

/**
* @internal
*
* this will be removed after https://github.com/microsoft/fluentui/issues/30332
*
* expands this with rulesets/overrides that are necessary for specific configs
*/
const __internal = {
/**
* `@nx/eslint-plugin` is necessary in order to register custom lint rules that live within tools/eslint-rules
*/
plugins: shouldRegister ? ['@nx'] : [],
};

exports.__internal = __internal;

0 comments on commit 28dc770

Please sign in to comment.