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

Fix doc parser #2

Merged
merged 24 commits into from
Sep 20, 2024
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
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
max_ram=$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes)
max_ram=4294967296 #$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes)
max_ram=$((max_ram / 1024 / 1024))
old_space_size=$((max_ram - 356))

Expand Down
62 changes: 26 additions & 36 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,33 @@ import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
//import prettier from 'eslint-config-prettier';


export default tseslint.config(
{
// config with just ignores is the replacement for `.eslintignore`
ignores: ['dist/**'],
},
//prettier,
eslint.configs.recommended,
{
files: ['**/*.ts'],
plugins: {
'@typescript-eslint': tseslint.plugin,
{
ignores: [
"node_modules/",
"dist/",
"tests/",
"tsconfig.json",
"eslint.config.*"
],
},
languageOptions: {
parser: tseslint.parser,
globals: globals.node,
parserOptions: {
project: true,
sourceType: 'module',
programs: null
},
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
{
files: ['**/*.ts'],
languageOptions: {
parser: tseslint.parser,
globals: globals.node,
parserOptions: {
project: true,
sourceType: 'module',
programs: null
}
},
},
rules: {
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
{
files: ['**/*.js'],
...tseslint.configs.disableTypeChecked,
},
},
{
// disable type-aware linting on JS files
files: ['**/*.js'],
...tseslint.configs.disableTypeChecked,
},
// {
// // enable jest rules on test files
// files: ['tests/**'],
// ...jestPlugin.configs['flat/recommended'],
// },
);
);
39 changes: 38 additions & 1 deletion lib/models/blacklist.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
const blacklistRegexes: RegExp[] = [
/@lwc\/lwc\/no-async-operation/,
/@lwc\/lwc\/no-leaky-event-listeners/,
/@lwc\/lwc\/no-unexpected-wire-adapter-usages/,
/@lwc\/lwc\/no-unknown-wire-adapters/,
/@lwc\/lwc\/no-restricted-browser-globals-during-ssr/,
/@lwc\/lwc\/no-node-env-in-ssr/,
/@salesforce\/lightning\/valid-apex-method-invocation/,
/@typescript-eslint\/consistent-type-imports/,
/@typescript-eslint\/ban-types/,
/angular\/service-name/,
/ember\/no-restricted-property-modifications/,
/ember\/template-indent/,
/backbone\/event-scope/,
/backbone\/no-silent/,
/filenames\/match-regex/,
/filenames\/match-exported/,
/filenames\/no-index/,
/functional\/functional-parameters/,
/functional\/immutable-data/,
/functional\/no-conditional-statements/,
Expand All @@ -17,12 +27,39 @@ const blacklistRegexes: RegExp[] = [
/functional\/no-try-statements/,
/functional\/prefer-immutable-types/,
/functional\/type-declaration-immutability/,
/import\/newline-after-import/,
/import\/no-amd/,
/import\/no-commonjs/,
/xss\/no-mixed-html/,
/unused-imports\/.*-ts/,
/yml\/sort-sequence-values/
]

const documentationBlacklistRegexes: RegExp[] = [
/@shopify\/no-debugger/
/@shopify\/no-debugger/,
/react-redux\/mapStateToProps-prefer-parameters-names/,
/react-redux\/prefer-separate-component-file/,
/react-redux\/mapStateToProps-prefer-hoisted/,
/react-redux\/connect-prefer-named-arguments/,
/react-redux\/mapDispatchToProps-prefer-parameters-names/,
/react-redux\/mapDispatchToProps-returns-object/,
/react-redux\/mapDispatchToProps-prefer-shorthand/,
/react-redux\/connect-prefer-minimum-two-arguments/,
/react-redux\/mapStateToProps-no-store/,
/jasmine\/named-spy/,
/jasmine\/no-unsafe-spy/,
/jasmine\/no-focused-tests/,
/jasmine\/no-assign-spyon/,
/jasmine\/no-describe-variables/,
/jasmine\/expect-matcher/,
/jasmine\/no-pending-tests/,
/jasmine\/no-suite-callback-args/,
/jasmine\/prefer-toHaveBeenCalledWith/,
/jasmine\/no-disabled-tests/,
/jasmine\/prefer-jasmine-matcher/,
/jasmine\/no-global-setup/,
/jasmine\/expect-single-argument/,
/jasmine\/valid-expect/
]

function testRegex (regexes: RegExp[], value: string): boolean {
Expand Down
2 changes: 1 addition & 1 deletion lib/models/patterns.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Category, Level, ScanType, SecuritySubcategory } from "codacy-seed"

const securityPlugins = [
export const securityPlugins = [
"scanjs-rules",
"security",
"security-node",
Expand Down
76 changes: 38 additions & 38 deletions lib/models/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,94 +20,94 @@ export interface Plugin {

const packageNames: string[] = [
"@angular-eslint/eslint-plugin",
"@babel/eslint-plugin",
// "@babel/eslint-plugin", no rule description found
"@lwc/eslint-plugin-lwc",
"@salesforce/eslint-plugin-aura",
// "@salesforce/eslint-plugin-aura",
"@salesforce/eslint-plugin-lightning",
"@shopify/eslint-plugin",
"@stylistic/eslint-plugin",
"@tanstack/eslint-plugin-query",
"@typescript-eslint/eslint-plugin",
"eslint-plugin-awscdk",
"eslint",
// "eslint-plugin-awscdk", no rule description
"eslint-plugin-backbone",
"eslint-plugin-cdk",
"eslint-plugin-chai-expect",
"eslint-plugin-chai-friendly",
"eslint-plugin-codeceptjs",
// "eslint-plugin-cdk", deprecated
// "eslint-plugin-chai-expect", no rule description
// "eslint-plugin-chai-friendly", no rule description
// "eslint-plugin-codeceptjs", deprecated
"eslint-plugin-compat",
"eslint-plugin-css-modules",
// "eslint-plugin-css-modules", no rule description
"eslint-plugin-cypress",
"eslint-plugin-deprecation",
"eslint-plugin-ember",
"eslint-plugin-ember-suave",
"eslint-plugin-es-x",
"eslint-plugin-eslint-plugin",
"eslint-plugin-filenames",
"eslint-plugin-flowtype",
"eslint-plugin-formatjs",
// "eslint-plugin-flowtype",
// "eslint-plugin-formatjs",
"eslint-plugin-fp",
"eslint-plugin-functional",
"eslint-plugin-i18next",
"eslint-plugin-import",
"eslint-plugin-import-alias",
"eslint-plugin-import-newlines",
// "eslint-plugin-import-alias",
// "eslint-plugin-import-newlines",
"eslint-plugin-jasmine",
"eslint-plugin-jest",
"eslint-plugin-jest-dom",
"eslint-plugin-jest-extended",
"eslint-plugin-jest-formatting",
"eslint-plugin-jira-ticket-todo-comment",
// "eslint-plugin-jira-ticket-todo-comment",
"eslint-plugin-jsdoc",
"eslint-plugin-json",
"eslint-plugin-jsonc",
"eslint-plugin-jsx",
// "eslint-plugin-jsx",
"eslint-plugin-jsx-a11y",
"eslint-plugin-lit",
"eslint-plugin-lodash",
"eslint-plugin-lodash-fp",
"eslint-plugin-meteor",
"eslint-plugin-mocha",
"eslint-plugin-monorepo",
// "eslint-plugin-monorepo", deprecated
"eslint-plugin-n",
"eslint-plugin-no-only-tests",
// "eslint-plugin-no-only-tests", no rule description
"eslint-plugin-no-unsanitized",
"eslint-plugin-nuxt",
"eslint-plugin-perfectionist",
"eslint-plugin-playwright",
"eslint-plugin-prefer-arrow",
"eslint-plugin-prefer-object-spread",
"eslint-plugin-prettier",
"eslint-plugin-prettier-vue",
// "eslint-plugin-prefer-arrow", deprecated
// "eslint-plugin-prefer-object-spread", deprecated
// "eslint-plugin-prettier", no rule description
// "eslint-plugin-prettier-vue", no rule description
"eslint-plugin-promise",
"eslint-plugin-ramda",
// "eslint-plugin-ramda", No rule description, only implementation
"eslint-plugin-react",
"eslint-plugin-react-hooks",
// "eslint-plugin-react-hooks", no rule description found
"eslint-plugin-react-native",
"eslint-plugin-react-perf",
"eslint-plugin-react-redux",
"eslint-plugin-react-refresh",
// "eslint-plugin-react-refresh", no rule description
"eslint-plugin-redux-saga",
"eslint-plugin-regexp",
"eslint-plugin-relay",
"eslint-plugin-rxjs",
"eslint-plugin-rxjs-angular",
// "eslint-plugin-relay",
// "eslint-plugin-rxjs",
// "eslint-plugin-rxjs-angular",
"eslint-plugin-security",
"eslint-plugin-security-node",
"eslint-plugin-simple-import-sort",
"eslint-plugin-sonarjs",
// "eslint-plugin-simple-import-sort",
// Not yet supported by ESLint 9: https://www.npmjs.com/package/eslint-plugin-sonarjs?activeTab=readme
// "eslint-plugin-sonarjs",
"eslint-plugin-sort",
"eslint-plugin-sort-destructure-keys",
"eslint-plugin-sort-imports-es6-autofix",
"eslint-plugin-sort-keys-custom-order-fix",
"eslint-plugin-sort-keys-fix",
"eslint-plugin-spellcheck",
// "eslint-plugin-sort-imports-es6-autofix",
// "eslint-plugin-sort-keys-custom-order-fix", deprecated
// "eslint-plugin-sort-keys-fix", deprecated
// "eslint-plugin-spellcheck", deprecated
"eslint-plugin-storybook",
"eslint-plugin-suitescript",
"eslint-plugin-tailwindcss",
"eslint-plugin-test-selectors",
"eslint-plugin-testing-library",
"eslint-plugin-tsdoc",
"eslint-plugin-turbo",
// "eslint-plugin-tsdoc", no rule description
// "eslint-plugin-turbo", TO-DO: Build a rule parser for this plugin
"eslint-plugin-typescript-sort-keys",
"eslint-plugin-unicorn",
"eslint-plugin-unused-imports",
Expand All @@ -117,7 +117,7 @@ const packageNames: string[] = [
"eslint-plugin-wdio",
"eslint-plugin-xss",
"eslint-plugin-yml",
"eslint-plugin-you-dont-need-lodash-underscore"
// "eslint-plugin-you-dont-need-lodash-underscore"
]

const baseRules: Map<string, Rule.RuleModule> = new Linter({configType: "eslintrc"}).getRules();
Expand All @@ -127,7 +127,7 @@ const plugins: Promise<Plugin[]> = Promise.all(packageNames.map(async (packageNa
const module: TSESLint.Linter.Plugin = moduleRaw.default ?? moduleRaw;
const name = convertFromPackageName(packageName);

if (module?.rules === undefined) {
if (packageName !== "eslint" && module?.rules === undefined) {
console.log(wrapConsoleTextInColor(`No rules found for ${packageName}`, TerminalColor.Red), module);
}

Expand Down
9 changes: 8 additions & 1 deletion lib/utils/rulesToUnnamedParametersDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ import { JSONSchema4Type } from "json-schema"
export const rulesToUnnamedParametersDefaults = new Map<string, JSONSchema4Type>([
["@stylistic/array-bracket-spacing", "never"],
["@stylistic/arrow-parens", "always"],
["flowtype/arrow-parens", "always"],
// ["flowtype/arrow-parens", "always"],
["arrow-parens", "always"],
["@stylistic/block-spacing", "always"],
["@stylistic/brace-style", "1tbs"],
["vue/brace-style", "1tbs"],
["brace-style", "1tbs"],
["jsdoc/check-line-alignment", "never"],
["@stylistic/comma-dangle", "never"],
["@stylistic/comma-style", "last"],
["complexity", 4],
["@stylistic/computed-property-spacing", "never"],
["computed-property-spacing", "never"],
["consistent-this", "self"],
["curly", "all"],
["@stylistic/dot-location", "property"],
Expand All @@ -26,6 +29,7 @@ export const rulesToUnnamedParametersDefaults = new Map<string, JSONSchema4Type>
["init-declarations", "always"],
["@stylistic/jsx-quotes", "prefer-double"],
["@stylistic/lines-between-class-members", "always"],
["lines-between-class-members", "always"],
["max-nested-callbacks", 5],
["@stylistic/multiline-ternary", "always"],
["newline-after-var", "always"],
Expand All @@ -41,12 +45,15 @@ export const rulesToUnnamedParametersDefaults = new Map<string, JSONSchema4Type>
["@stylistic/semi", "always"],
["sort-keys", "asc"],
["vue/sort-keys", "asc"],
["@stylistic_indent", 2],
["indent", 2],
["@stylistic/space-before-blocks", "always"],
["@stylistic/space-before-function-paren", "always"],
["@stylistic/space-in-parens", "never"],
["@stylistic/spaced-comment", "always"],
["strict", "function"],
["@stylistic/wrap-iife", "outside"],
["wrap-iife", "outside"],
["vue/multiline-ternary", "always"],
["yoda", "never"]
])
Expand Down
Loading