Skip to content

Commit

Permalink
♻️ Fixit: create src/core with eslint rule disallowing imports (#32916)
Browse files Browse the repository at this point in the history
* Create src/core directory with lint config

* Update references to original assert location

* Add comment to eslint config

* Add Justin as owner

* Lint fixes

* Justion `required: true`
  • Loading branch information
rcebulko committed Feb 26, 2021
1 parent 3223a2a commit a8b0fb1
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 5 deletions.
2 changes: 1 addition & 1 deletion extensions/amp-accordion/1.0/base-element.js
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
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
@@ -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': ['..'],
},
],
},
};
14 changes: 14 additions & 0 deletions src/core/OWNERS
@@ -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
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
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
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

0 comments on commit a8b0fb1

Please sign in to comment.