{ lib, pkgs, ... }: name: text: pkgs.runCommand name { nativeBuildInputs = [ pkgs.eslint ]; eslintConfig = /* js */ '' // ESLint flat config for Polkit rules (Duktape 2.7) export default [ { files: [${builtins.toJSON name}], languageOptions: { ecmaVersion: 2016, sourceType: 'script', globals: { polkit: 'readonly', }, }, linterOptions: { reportUnusedDisableDirectives: true, }, rules: { 'no-unused-vars': 'warn', 'no-undef': 'error', 'no-console': 'off', 'prefer-const': 'warn', 'no-confusing-arrow': [ 'error', { allowParens: true }, ], 'no-constant-condition': 'warn', 'no-restricted-syntax': [ 'error', { selector: 'AwaitExpression', message: 'Async/await is not supported in Polkit rules.', }, { selector: 'ImportDeclaration', message: 'Modules are not supported.', }, { selector: 'ExportNamedDeclaration', message: 'Modules are not supported.', }, { selector: 'NewExpression[callee.name="Promise"]', message: 'Promises are not supported in Duktape.', }, { selector: 'ClassDeclaration', message: 'Class syntax may behave inconsistently in Duktape.', }, ] } } ]; ''; polkitRules = text; passAsFile = [ "eslintConfig" "polkitRules" ]; } /* sh */ '' name=${lib.escapeShellArg name} ln -s "$polkitRulesPath" "$name" ln -s "$eslintConfigPath" eslint.config.js eslint "$name" cp -L "$name" "$out" ''