123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- const legacyCode = {
- 'default-param-last': 'off',
- 'no-continue': 'off',
- 'no-else-return': 'off',
- 'no-restricted-syntax': 'off',
- };
- module.exports = {
- extends: [
- '@wagtail/eslint-config-wagtail',
- 'plugin:@typescript-eslint/recommended',
- ],
- parser: '@typescript-eslint/parser',
- plugins: ['@typescript-eslint'],
- env: {
- jest: true,
- browser: true,
- },
- rules: {
- '@typescript-eslint/explicit-function-return-type': 'off',
- '@typescript-eslint/explicit-member-accessibility': 'off',
- '@typescript-eslint/explicit-module-boundary-types': 'off',
- '@typescript-eslint/no-explicit-any': 'off',
- '@typescript-eslint/no-use-before-define': ['error'],
-
- 'class-methods-use-this': 'off',
- 'import/extensions': [
- 'error',
- 'always',
- {
- ignorePackages: true,
- pattern: {
- js: 'never',
- jsx: 'never',
- ts: 'never',
- tsx: 'never',
- },
- },
- ],
-
- 'import/prefer-default-export': 'off',
-
- 'lines-between-class-members': [
- 'error',
- 'always',
- { exceptAfterSingleLine: true },
- ],
- 'max-classes-per-file': 'off',
-
- 'no-use-before-define': 'off',
- 'react/jsx-filename-extension': ['error', { extensions: ['.js', '.tsx'] }],
- 'no-underscore-dangle': [
- 'error',
- { allow: ['__REDUX_DEVTOOLS_EXTENSION__'] },
- ],
-
- 'prefer-destructuring': 'off',
- },
- settings: {
- 'import/core-modules': ['jquery'],
- 'import/resolver': { node: { extensions: ['.js', '.ts', '.tsx'] } },
- },
- overrides: [
-
- {
- files: [
- 'client/src/entrypoints/admin/core.js',
- 'client/src/entrypoints/admin/page-editor.js',
- 'client/src/entrypoints/admin/telepath/widgets.js',
- 'client/src/entrypoints/contrib/typed_table_block/typed_table_block.js',
- 'client/src/utils/version.js',
- ],
- rules: legacyCode,
- },
-
- {
- files: ['client/src/components/**'],
- rules: {
- ...legacyCode,
- 'jsx-a11y/click-events-have-key-events': 'off',
- 'jsx-a11y/interactive-supports-focus': 'off',
- 'jsx-a11y/no-noninteractive-element-interactions': 'off',
- 'jsx-a11y/role-supports-aria-props': 'off',
- 'react-hooks/exhaustive-deps': 'off',
- 'react-hooks/rules-of-hooks': 'off',
- 'react/button-has-type': 'off',
- 'react/destructuring-assignment': 'off',
- 'react/forbid-prop-types': 'off',
- 'react/function-component-definition': 'off',
- 'react/jsx-props-no-spreading': 'off',
- 'react/no-danger': 'off',
- 'react/no-deprecated': 'off',
- 'react/require-default-props': 'off',
- },
- },
-
- {
- files: ['*Controller.ts'],
- rules: {
- '@typescript-eslint/member-ordering': [
- 'error',
- {
- classes: {
- memberTypes: ['signature', 'field', 'method'],
- },
- },
- ],
- '@typescript-eslint/naming-convention': [
- 'error',
- {
- selector: 'method',
- format: ['camelCase'],
- custom: {
-
- regex: '^(constructor|render|update)$',
- match: false,
- },
- },
- {
- selector: 'property',
- format: ['camelCase'],
- custom: {
-
- regex: '^(state)$',
- match: false,
- },
- },
- ],
- 'no-restricted-properties': [
- 'error',
- {
- object: 'window',
- property: 'Stimulus',
- message:
- "Please import the base Controller or only access the Stimulus instance via the controller's `this.application` attribute.",
- },
- ],
- },
- },
-
- {
- files: [
- 'client/extract-translatable-strings.js',
- 'client/tests/**',
- 'webpack.config.js',
- 'tailwind.config.js',
- 'storybook/**/*',
- '*.test.ts',
- '*.test.tsx',
- '*.test.js',
- '*.stories.js',
- '*.stories.tsx',
- ],
- rules: {
- '@typescript-eslint/no-empty-function': 'off',
- '@typescript-eslint/no-unused-vars': 'off',
- '@typescript-eslint/no-var-requires': 'off',
- 'global-require': 'off',
- 'import/first': 'off',
- 'import/no-extraneous-dependencies': 'off',
- 'no-unused-expressions': 'off',
- 'react/function-component-definition': 'off',
- 'react/jsx-props-no-spreading': 'off',
- },
- },
-
- {
- files: [
- 'docs/_static/**',
- 'wagtail/contrib/modeladmin/static_src/wagtailmodeladmin/js/prepopulate.js',
- 'wagtail/contrib/search_promotions/templates/wagtailsearchpromotions/includes/searchpromotions_formset.js',
- 'wagtail/contrib/settings/static_src/wagtailsettings/js/site-switcher.js',
- 'wagtail/documents/static_src/wagtaildocs/js/add-multiple.js',
- 'wagtail/embeds/static_src/wagtailembeds/js/embed-chooser-modal.js',
- 'wagtail/images/static_src/wagtailimages/js/add-multiple.js',
- 'wagtail/images/static_src/wagtailimages/js/focal-point-chooser.js',
- 'wagtail/images/static_src/wagtailimages/js/image-url-generator.js',
- 'wagtail/search/static_src/wagtailsearch/js/query-chooser-modal.js',
- 'wagtail/search/templates/wagtailsearch/queries/chooser_field.js',
- 'wagtail/snippets/static_src/wagtailsnippets/js/snippet-multiple-select.js',
- 'wagtail/users/static_src/wagtailusers/js/group-form.js',
- ],
- globals: { $: 'readonly', jQuery: 'readonly' },
- },
-
- {
- files: ['wagtail/**/**'],
- globals: {
- addMessage: 'readonly',
- buildExpandingFormset: 'readonly',
- cancelSpinner: 'readonly',
- escapeHtml: 'readonly',
- jsonData: 'readonly',
- ModalWorkflow: 'readonly',
- DOCUMENT_CHOOSER_MODAL_ONLOAD_HANDLERS: 'writable',
- EMBED_CHOOSER_MODAL_ONLOAD_HANDLERS: 'writable',
- IMAGE_CHOOSER_MODAL_ONLOAD_HANDLERS: 'writable',
- QUERY_CHOOSER_MODAL_ONLOAD_HANDLERS: 'writable',
- SNIPPET_CHOOSER_MODAL_ONLOAD_HANDLERS: 'writable',
- },
- rules: {
- '@typescript-eslint/no-unused-vars': 'off',
- '@typescript-eslint/no-use-before-define': 'off',
- 'camelcase': [
- 'error',
- {
- allow: [
- '__unused_webpack_module',
- '__webpack_modules__',
- '__webpack_require__',
- ],
- properties: 'never',
- },
- ],
- 'consistent-return': 'off',
- 'func-names': 'off',
- 'id-length': 'off',
- 'indent': 'off',
- 'key-spacing': 'off',
- 'new-cap': 'off',
- 'newline-per-chained-call': 'off',
- 'no-param-reassign': 'off',
- 'no-underscore-dangle': 'off',
- 'object-shorthand': 'off',
- 'prefer-arrow-callback': 'off',
- 'quote-props': 'off',
- 'space-before-function-paren': 'off',
- 'vars-on-top': 'off',
- },
- },
- ],
- };
|