Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

6.6 KB
Raw Blame
import { defineConfig } from '@apify/oxlint-config';

export default defineConfig({
    ignorePatterns: [
        '**/node_modules',
        '**/dist',
        '**/coverage',
        '**/.turbo',
        '**/website/build',
        '**/website/.docusaurus',
        '**/*.d.ts',
        'packages/templates/templates/**',
        'packages/templates/scripts/**',
        'test/e2e/**',
    ],
    jsPlugins: ['./scripts/oxlint-plugin.ts'],
    globals: {
        vi: 'readonly',
        vitest: 'readonly',
        describe: 'readonly',
        it: 'readonly',
        test: 'readonly',
        expect: 'readonly',
        expectTypeOf: 'readonly',
        beforeAll: 'readonly',
        afterAll: 'readonly',
        beforeEach: 'readonly',
        afterEach: 'readonly',
    },
    rules: {
        'import/extensions': ['error', 'always', { ignorePackages: true, checkTypeImports: true }],
        'no-undef': 'off',
        'no-console': 'off',
        'no-throw-literal': 'error',
        eqeqeq: ['error', 'smart'],
        yoda: 'error',
        // Enforces the naming convention from #3108: no `_`-prefixed members; private
        // properties use native `#` fields instead. The allow list covers the template-method
        // hooks that collide with their public wrappers, platform contracts (`Readable._read`),
        // and documented internals (`__crawlee`, `__purged`).
        'no-underscore-dangle': [
            'error',
            {
                enforceInClassFields: true,
                enforceInMethodNames: true,
                allow: [
                    '_launch',
                    '_close',
                    '_kill',
                    '_newPage',
                    '_getCookies',
                    '_setCookies',
                    '_read',
                    '__crawlee',
                    '__purged',
                    '__originalHistory__',
                ],
            },
        ],
        // Counterpart to `no-underscore-dangle` above: private members should be native `#` fields,
        // not the TypeScript `private` modifier.
        'crawlee/prefer-private-fields': 'error',

        'typescript/consistent-type-imports': ['error', { disallowTypeAnnotations: false }],
        'typescript/consistent-type-definitions': ['error', 'interface'],
        'typescript/no-explicit-any': 'off',
        'typescript/ban-ts-comment': 'off',
        'typescript/no-unused-vars': 'off',
        'typescript/no-empty-function': 'off',
        'typescript/no-empty-object-type': 'off',
        'typescript/no-empty-interface': 'off',
        'typescript/no-useless-constructor': 'off',
        'typescript/no-namespace': ['error', { allowDeclarations: true }],
        'typescript/no-this-alias': 'error',
        'typescript/no-var-requires': 'error',
        'typescript/no-require-imports': 'off',
        'typescript/consistent-type-assertions': 'error',
        'typescript/no-unnecessary-qualifier': 'error',
        'typescript/no-inferrable-types': 'off',
        'typescript/no-unsafe-declaration-merging': 'off',
        'typescript/no-mixed-enums': 'error',
        'typescript/no-unsafe-unary-minus': 'error',
        'typescript/related-getter-setter-pairs': 'error',
        'typescript/only-throw-error': 'error',
        'typescript/no-deprecated': 'warn',
        'typescript/prefer-find': 'error',
        'typescript/prefer-string-starts-ends-with': 'error',
        'typescript/no-duplicate-type-constituents': 'error',
        'typescript/consistent-type-exports': 'error',
        'typescript/prefer-optional-chain': 'error',
        'typescript/prefer-regexp-exec': 'error',
        'typescript/no-misused-promises': ['error', { checksVoidReturn: { arguments: false } }],
        'typescript/no-unnecessary-template-expression': 'error',
        'typescript/no-unnecessary-boolean-literal-compare': 'error',
        'typescript/no-array-delete': 'error',
        'typescript/return-await': 'off',
        'typescript/use-unknown-in-catch-callback-variable': 'off',
        'typescript/no-unnecessary-condition': 'off',
        'typescript/no-confusing-void-expression': 'off',
        'typescript/switch-exhaustiveness-check': 'off',
        'typescript/no-unnecessary-type-assertion': 'off',
        'typescript/no-unsafe-enum-comparison': 'off',
        'typescript/no-unsafe-type-assertion': 'off',
        'typescript/promise-function-async': 'off',
        'typescript/require-await': 'off',
        'typescript/strict-void-return': 'off',
        'typescript/prefer-readonly-parameter-types': 'off',
        'typescript/no-use-before-define': 'off',

        'import/no-duplicates': 'error',
        'import/no-default-export': 'off',

        'unicorn/no-empty-file': 'off',
        'unicorn/filename-case': ['error', { case: 'kebabCase' }],

        // Rules pulled in by `@apify/oxlint-config` that the codebase does not
        // currently satisfy. Disabled here to keep this migration scoped to a
        // config refactor; flip them back on in follow-up cleanup PRs.
        'prefer-destructuring': 'off',
        'no-unassigned-vars': 'off',
        'vitest/expect-expect': 'off',
        'promise/valid-params': 'off',
    },
    overrides: [
        {
            files: ['test/**/*'],
            rules: {
                'no-underscore-dangle': 'off',
                'typescript/consistent-type-imports': 'off',
                'typescript/no-floating-promises': 'off',
                'typescript/only-throw-error': 'off',
                'typescript/await-thenable': 'off',
                'typescript/no-deprecated': 'off',
                'typescript/no-array-delete': 'off',
                'typescript/no-mixed-enums': 'off',
                'typescript/no-implied-eval': 'off',
                'no-console': 'off',
                'no-control-regex': 'off',
                'no-empty': 'off',
                'import/no-duplicates': 'off',
                'jest/no-conditional-expect': 'off',
                'jest/no-disabled-tests': 'off',
                'vitest/no-conditional-expect': 'off',
                'vitest/no-disabled-tests': 'off',
                'vitest/no-conditional-tests': 'off',
                'vitest/hoisted-apis-on-top': 'off',
            },
        },
        {
            files: ['packages/templates/**/*'],
            rules: {
                'typescript/no-unused-vars': 'off',
                'no-unused-vars': 'off',
            },
        },
        {
            // docs resolve `crawlee` to its unbuilt `dist`, so crawlee types are unknown when linting
            files: ['docs/**/*'],
            rules: {
                'typescript/await-thenable': 'off',
            },
        },
    ],
});