Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

feat: add liferay-portal/no-explicit-extend rule #54

Merged
merged 1 commit into from
Jul 17, 2019

Conversation

wincent
Copy link
Contributor

@wincent wincent commented Jul 17, 2019

I wanted to put this in the repo because it is an example of a liferay-portal-specific lint that:

  • Only applies to certain files.
  • Includes an "autofix" functionality.

Test plan:

Run this in liferay-portal without:

brianchandotcom/liferay-portal#75813

See:

modules/apps/data-engine/data-engine-taglib/.eslintrc.js
  16:12  error  `liferay/portal` applies automatically and can be omitted  liferay-portal/no-explicit-extend

modules/apps/dynamic-data-mapping/dynamic-data-mapping-form-builder/.eslintrc.js
  16:12  error  `liferay/portal` applies automatically and can be omitted  liferay-portal/no-explicit-extend

modules/apps/dynamic-data-mapping/dynamic-data-mapping-form-web/.eslintrc.js
  16:12  error  `liferay/portal` applies automatically and can be omitted  liferay-portal/no-explicit-extend

modules/apps/layout/layout-content-page-editor-web/.eslintrc.js
  16:12  error  `liferay/portal` applies automatically and can be omitted  liferay-portal/no-explicit-extend

modules/apps/segments/segments-web/.eslintrc.js
  16:12  error  `liferay/portal` applies automatically and can be omitted  liferay-portal/no-explicit-extend

✖ 5 problems (5 errors, 0 warnings)
  5 errors and 0 warnings potentially fixable with the `--fix` option.

ESLint checked 562 files, found 5 errors, found 0 warnings, 5 issues potentially fixable with lint:fix

Which are the same files reported by git grep 'extends:.+liferay':

apps/app-builder/app-builder-web/.eslintrc.js:16:       extends: ['liferay/react']
apps/data-engine/data-engine-taglib/.eslintrc.js:16:    extends: ['liferay/portal', 'liferay/metal']
apps/dynamic-data-mapping/dynamic-data-mapping-form-builder/.eslintrc.js:16:    extends: ['liferay/portal', 'liferay/metal']
apps/dynamic-data-mapping/dynamic-data-mapping-form-web/.eslintrc.js:16:        extends: ['liferay/portal', 'liferay/metal']
apps/layout/layout-content-page-editor-web/.eslintrc.js:16:     extends: ['liferay/portal', 'liferay/react'],
apps/segments/segments-web/.eslintrc.js:16:     extends: ['liferay/portal', 'liferay/react']

After running autofix, see this diff:

https://gist.github.com/wincent/6874c549f011937104266800ab724475

I wanted to put this in the repo because it is an example of a
liferay-portal-specific lint that:

- Only applies to certain files.
- Includes an "autofix" functionality.

Test plan:

Run this in liferay-portal without:

    brianchandotcom/liferay-portal#75813

See:

    modules/apps/data-engine/data-engine-taglib/.eslintrc.js
      16:12  error  `liferay/portal` applies automatically and can be omitted  liferay-portal/no-explicit-extend

    modules/apps/dynamic-data-mapping/dynamic-data-mapping-form-builder/.eslintrc.js
      16:12  error  `liferay/portal` applies automatically and can be omitted  liferay-portal/no-explicit-extend

    modules/apps/dynamic-data-mapping/dynamic-data-mapping-form-web/.eslintrc.js
      16:12  error  `liferay/portal` applies automatically and can be omitted  liferay-portal/no-explicit-extend

    modules/apps/layout/layout-content-page-editor-web/.eslintrc.js
      16:12  error  `liferay/portal` applies automatically and can be omitted  liferay-portal/no-explicit-extend

    modules/apps/segments/segments-web/.eslintrc.js
      16:12  error  `liferay/portal` applies automatically and can be omitted  liferay-portal/no-explicit-extend

    ✖ 5 problems (5 errors, 0 warnings)
      5 errors and 0 warnings potentially fixable with the `--fix` option.

    ESLint checked 562 files, found 5 errors, found 0 warnings, 5 issues potentially fixable with lint:fix

Which are the same files reported by `git grep 'extends:.+liferay'`:

    apps/app-builder/app-builder-web/.eslintrc.js:16:       extends: ['liferay/react']
    apps/data-engine/data-engine-taglib/.eslintrc.js:16:    extends: ['liferay/portal', 'liferay/metal']
    apps/dynamic-data-mapping/dynamic-data-mapping-form-builder/.eslintrc.js:16:    extends: ['liferay/portal', 'liferay/metal']
    apps/dynamic-data-mapping/dynamic-data-mapping-form-web/.eslintrc.js:16:        extends: ['liferay/portal', 'liferay/metal']
    apps/layout/layout-content-page-editor-web/.eslintrc.js:16:     extends: ['liferay/portal', 'liferay/react'],
    apps/segments/segments-web/.eslintrc.js:16:     extends: ['liferay/portal', 'liferay/react']

After running autofix, see this diff:

    https://gist.github.com/wincent/6874c549f011937104266800ab724475
@jbalsas
Copy link
Contributor

jbalsas commented Jul 17, 2019

LGTM, @andresfulla, just FYI since we talked about this this morning.

@wincent wincent merged commit 21ed2d2 into master Jul 17, 2019
@wincent wincent deleted the wincent/no-portal-config branch July 17, 2019 15:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants