Skip to content
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
30 changes: 30 additions & 0 deletions eslint-plugin-report-name-utils/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* ESLint plugin that enforces architectural constraints on ReportNameUtils.ts.
*
* `getReportName` must remain a pure read-only function — it reads from
* pre-computed `reportAttributesDerivedValue` and must never call other
* functions. All computation belongs in `computeReportName`.
*/

const noFunctionCallInGetReportName = {
meta: {
type: 'problem',
docs: {description: 'getReportName must be a pure read-only function. Move any computation to computeReportName instead.'},
messages: {noFunctionCall: 'getReportName must be a pure read-only function. Move any computation to computeReportName instead.'},
schema: [],
},
create(context) {
return {
'FunctionDeclaration[id.name="getReportName"] CallExpression': function (node) {
context.report({node, messageId: 'noFunctionCall'});
},
};
},
};

export default {
meta: {name: 'eslint-plugin-report-name-utils'},
rules: {
'no-function-call-in-get-report-name': noFunctionCallInGetReportName,
},
};
7 changes: 7 additions & 0 deletions eslint.changed.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {defineConfig} from 'eslint/config';
import reportNameUtilsPlugin from './eslint-plugin-report-name-utils/index.mjs';
import mainConfig from './eslint.config.mjs';

const restrictedIconImportPaths = [
Expand Down Expand Up @@ -106,6 +107,12 @@ const config = defineConfig([
],
},
},

{
files: ['src/libs/ReportNameUtils.ts'],
plugins: {'report-name-utils': reportNameUtilsPlugin},
rules: {'report-name-utils/no-function-call-in-get-report-name': 'error'},
},
]);

export default config;
7 changes: 7 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import path from 'node:path';
import {fileURLToPath} from 'node:url';
import typescriptEslint from 'typescript-eslint';
import reactCompilerCompat from './eslint-plugin-react-compiler-compat/index.mjs';
import reportNameUtilsPlugin from './eslint-plugin-report-name-utils/index.mjs';

const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
Expand Down Expand Up @@ -592,6 +593,12 @@ const config = defineConfig([
},
},

{
files: ['src/libs/ReportNameUtils.ts'],
plugins: {'report-name-utils': reportNameUtilsPlugin},
rules: {'report-name-utils/no-function-call-in-get-report-name': 'error'},
},

{
files: ['src/**/*'],
ignores: ['src/languages/**', 'src/CONST/index.ts', 'src/NAICS.ts'],
Expand Down
Loading