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

♻️ Fixit: create src/core with eslint rule disallowing imports #32916

Merged
merged 6 commits into from
Feb 26, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion extensions/amp-accordion/1.0/base-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from './component';
import {PreactBaseElement} from '../../../src/preact/base-element';
import {childElementsByTag, toggleAttribute} from '../../../src/dom';
import {pureDevAssert as devAssert} from '../../../src/assert';
import {pureDevAssert as devAssert} from '../../../src/core/assert';
import {dict, memo} from '../../../src/utils/object';
import {forwardRef} from '../../../src/preact/compat';
import {toArray} from '../../../src/types';
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-selector/1.0/base-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
toggleAttribute,
tryFocus,
} from '../../../src/dom';
import {pureDevAssert as devAssert} from '../../../src/assert';
import {pureDevAssert as devAssert} from '../../../src/core/assert';
import {dict} from '../../../src/utils/object';
import {toArray} from '../../../src/types';
import {useCallback, useLayoutEffect, useRef} from '../../../src/preact';
Expand Down
27 changes: 27 additions & 0 deletions src/core/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright 2021 The AMP HTML Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

module.exports = {
'rules': {
'no-restricted-imports': [
'error',
{
// Disallow importing dependencies from outside this directory
'patterns': ['..'],
rcebulko marked this conversation as resolved.
Show resolved Hide resolved
},
],
},
};
14 changes: 14 additions & 0 deletions src/core/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// For an explanation of the OWNERS rules and syntax, see:
// https://github.com/ampproject/amp-github-apps/blob/master/owners/OWNERS.example

{
rules: [
{
owners: [
{name: 'dvoytenko'},
{name: 'jridgewell', required: true},
{name: 'ampproject/wg-performance'},
],
},
],
}
File renamed without changes.
2 changes: 1 addition & 1 deletion src/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import {USER_ERROR_SENTINEL} from './assert';
import {USER_ERROR_SENTINEL} from './core/assert';
import {getMode} from './mode';
import {internalRuntimeVersion} from './internal-version';
import {isArray, isEnumValue} from './types';
Expand Down
2 changes: 1 addition & 1 deletion src/utils/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import {
pureDevAssert as devAssert,
pureUserAssert as userAssert,
} from '../assert';
} from '../core/assert';

/**
* Parses the date using the `Date.parse()` rules. Additionally supports the
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
USER_ERROR_SENTINEL,
pureDevAssert as devAssert,
pureUserAssert as userAssert,
} from '../../src/assert';
} from '../../src/core/assert';

describes.sandboxed('assertions', {}, () => {
describe('devAssert', () => {
Expand Down