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

chore(eslint): Enforce import order #52499

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 11 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ module.exports = {
// These two rules are to ensure packages don't import from calypso by accident to avoid circular deps.
'no-restricted-imports': [ 'error', { patterns: [ 'calypso/*' ] } ],
'no-restricted-modules': [ 'error', { patterns: [ 'calypso/*' ] } ],

'wpcalypso/import-docblock': 'off',
'import/order': [
'error',
{
'newlines-between': 'always',
alphabetize: {
order: 'asc',
},
},
],
},
},
{
Expand Down
3 changes: 0 additions & 3 deletions packages/accessible-focus/src/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
* @jest-environment jsdom
*/

/**
* Internal dependencies
*/
import { detectKeyboardNavigation } from '..';

describe( 'detectKeyboardNavigation', () => {
Expand Down
8 changes: 3 additions & 5 deletions packages/babel-plugin-i18n-calypso/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@
*
*/

/**
* External dependencies
*/
const { existsSync, mkdirSync, writeFileSync } = require( 'fs' );
const { relative, sep } = require( 'path' );

const { po } = require( 'gettext-parser' );
const { merge, isEmpty, forEach } = require( 'lodash' );
const { relative, sep } = require( 'path' );
const { existsSync, mkdirSync, writeFileSync } = require( 'fs' );

/**
* Default output headers if none specified in plugin options.
Expand Down
4 changes: 0 additions & 4 deletions packages/babel-plugin-transform-wpcalypso-async/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* External dependencies
*/

const kebabCase = require( 'lodash' ).kebabCase;

module.exports = ( { types: t } ) => {
Expand Down
3 changes: 0 additions & 3 deletions packages/babel-plugin-transform-wpcalypso-async/test/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* External dependencies
*/
const babel = require( '@babel/core' );

describe( 'babel-plugin-transform-wpcalypso-async', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/**
* Internal dependencies
*/
import { getResources } from '../api/resources-timing';
import { getDomContentLoadedEventStart, getNavigationStart } from '../api/performance-timing';
import { getResources } from '../api/resources-timing';

export const collector: Collector = ( report ) => {
const domContentLoaded = getDomContentLoadedEventStart() - getNavigationStart();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* Internal dependencies
*/
import { getMemory } from '../api/device-memory';

export const collector: Collector = ( report ) => {
Expand Down
3 changes: 0 additions & 3 deletions packages/browser-data-collector/src/collectors/environment.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* Internal dependencies
*/
import { getCalypsoVersion, getTarget, getEnvironment } from '../api/environment';

export const collector: Collector = ( report ) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* Internal dependencies
*/
import { getNavigationStart } from '../api/performance-timing';

export const collector: Collector = ( report ) => {
Expand Down
3 changes: 0 additions & 3 deletions packages/browser-data-collector/src/collectors/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* Internal dependencies
*/
export { collector as deviceMemory } from './device-memory';
export { collector as performanceTiming } from './performance-timing';
export { collector as environment } from './environment';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* Internal dependencies
*/
import { getEffectiveType } from '../api/network-information';

export const collector: Collector = ( report ) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* Internal dependencies
*/
import { getMarks } from '../api/user-timing';

export const collector: Collector = ( report ) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* Internal dependencies
*/
import { getMeasures } from '../api/user-timing';

export const collector: Collector = ( report ) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* Internal dependencies
*/
import {
getNavigationStart,
getUnloadEventStart,
Expand Down
5 changes: 2 additions & 3 deletions packages/browser-data-collector/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* Internal dependencies
*/
import { ReportImpl } from './report';
import { send } from './transports/logstash';

Expand All @@ -12,6 +9,7 @@ const inFlightReporters: Map< string, Promise< ReportImpl > > = new Map();
* @param id id of the report, must be passed to `stop()` to stop it
* @param obj Options
* @param obj.fullPageLoad `true` if the report should start measuring from the load of the page, `false` to start measuring from now.
* @param obj.collectors
*/
export const start = async (
id: string,
Expand All @@ -33,6 +31,7 @@ export const start = async (
* Stops a report and sends it to the transporter.
*
* @param id id of the report to send, comes from `start()`
* @param collectors.collectors
* @param collectors list of collectors to run
* @returns `true` if the report was sent successfully, `false` otherwise
*/
Expand Down
3 changes: 0 additions & 3 deletions packages/browser-data-collector/src/report.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* Internal dependencies
*/
import {
deviceMemory,
performanceTiming,
Expand Down
3 changes: 0 additions & 3 deletions packages/browser-data-collector/src/transports/logstash.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* External dependencies
*/
import request from 'wpcom-proxy-request';

export const send = async ( payload: object ): Promise< boolean > => {
Expand Down
15 changes: 5 additions & 10 deletions packages/calypso-analytics/src/tracks.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

/**
* External dependencies
*/
import { includes, isObjectLike, omitBy, times } from 'lodash';
import cookie from 'cookie';
import { EventEmitter } from 'events';

import { loadScript } from '@automattic/load-script';
import cookie from 'cookie';
import { includes, isObjectLike, omitBy, times } from 'lodash';

/**
* Internal Dependencies
*/
import { getCurrentUser, setCurrentUser } from './utils/current-user';
import getDoNotTrack from './utils/do-not-track';
import { getPageViewParams } from './page-view-params';
import { getCurrentUser, setCurrentUser } from './utils/current-user';
import debug from './utils/debug';
import getDoNotTrack from './utils/do-not-track';

declare global {
interface Window {
Expand Down
6 changes: 0 additions & 6 deletions packages/calypso-analytics/src/train-tracks.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
/**
* External Dependencies
*/
import { v4 as uuid } from 'uuid';

/**
* Internal Dependencies
*/
import { recordTracksEvent } from './tracks';

interface TrainTracksRenderProps {
Expand Down
3 changes: 0 additions & 3 deletions packages/calypso-analytics/src/utils/current-user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* Internal dependencies
*/
import hashPii from './hash-pii';

/**
Expand Down
3 changes: 0 additions & 3 deletions packages/calypso-analytics/src/utils/debug.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* External dependencies
*/
import debugFactory from 'debug';

/**
Expand Down
3 changes: 0 additions & 3 deletions packages/calypso-analytics/src/utils/do-not-track.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* Internal dependencies
*/
import debug from './debug';

/**
Expand Down
3 changes: 0 additions & 3 deletions packages/calypso-analytics/src/utils/hash-pii.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* External dependencies
*/
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
import sha256 from 'hash.js/lib/hash/sha/256';
Expand Down
3 changes: 0 additions & 3 deletions packages/calypso-build/bin/calypso-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
*/
/* eslint-disable import/no-nodejs-modules */

/**
* External dependencies
*/
const fs = require( 'fs' );
const path = require( 'path' );

Expand Down
1 change: 1 addition & 0 deletions packages/calypso-build/bin/copy-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

// find all the packages
const path = require( 'path' );

const rcopy = require( 'recursive-copy' );

const dir = process.cwd();
Expand Down
2 changes: 1 addition & 1 deletion packages/calypso-build/bin/transpile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/* eslint-disable import/no-nodejs-modules,no-console */

// find all the packages
const path = require( 'path' );
const { execSync } = require( 'child_process' );
const path = require( 'path' );

const dir = process.cwd();
const root = path.dirname( __dirname );
Expand Down
4 changes: 1 addition & 3 deletions packages/calypso-build/jest-preset.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* External dependencies
*/
const path = require( 'path' );

const { defaults } = require( 'jest-config' );

module.exports = {
Expand Down
3 changes: 0 additions & 3 deletions packages/calypso-build/jest/setup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* External dependencies
*/
const { configure } = require( 'enzyme' );
const Adapter = require( 'enzyme-adapter-react-16' );

Expand Down
3 changes: 0 additions & 3 deletions packages/calypso-build/jest/transform/asset.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* External dependencies
*/
const path = require( 'path' );

module.exports = {
Expand Down
6 changes: 2 additions & 4 deletions packages/calypso-build/jest/transform/babel.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/**
* External dependencies
*/
const babelJest = require( 'babel-jest' );
const path = require( 'path' );

const babelJest = require( 'babel-jest' );

module.exports = babelJest.createTransformer( {
presets: [
[ path.join( __dirname, '..', '..', 'babel', 'default.js' ), { modules: 'commonjs' } ],
Expand Down
13 changes: 4 additions & 9 deletions packages/calypso-build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,18 @@
*/
/* eslint-disable import/no-nodejs-modules */

/**
* External dependencies
*/
const fs = require( 'fs' );
const path = require( 'path' );
const process = require( 'process' );
const webpack = require( 'webpack' );

const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' );
const DuplicatePackageCheckerPlugin = require( 'duplicate-package-checker-webpack-plugin' );
const webpack = require( 'webpack' );

const FileConfig = require( './webpack/file-loader' );
const Minify = require( './webpack/minify' );
const SassConfig = require( './webpack/sass' );
const TranspileConfig = require( './webpack/transpile' );
const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' );

/**
* Internal dependencies
*/
const { cssNameFromFilename, shouldTranspileDependency } = require( './webpack/util' );
// const { workerCount } = require( './webpack.common' ); // todo: shard...

Expand Down
9 changes: 3 additions & 6 deletions packages/calypso-build/webpack/minify.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
/**
* External Dependencies
*/
const TerserPlugin = require( 'terser-webpack-plugin' );
const browserslist = require( 'browserslist' );
const babelPlugins = require( '@babel/compat-data/plugins' );
const semver = require( 'semver' );
const browserslist = require( 'browserslist' );
const CssMinimizerPlugin = require( 'css-minimizer-webpack-plugin' );
const semver = require( 'semver' );
const TerserPlugin = require( 'terser-webpack-plugin' );

const supportedBrowsers = browserslist();

Expand Down
5 changes: 1 addition & 4 deletions packages/calypso-build/webpack/sass.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/**
* External dependencies
*/
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
const WebpackRTLPlugin = require( '@automattic/webpack-rtl-plugin' );
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );

/**
* Internal dependnecies
Expand Down
3 changes: 0 additions & 3 deletions packages/calypso-build/webpack/util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* External dependencies
*/
const webpack = require( 'webpack' );

/**
Expand Down
8 changes: 1 addition & 7 deletions packages/calypso-codemods/api.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
#!/usr/bin/env node

/**
* External dependencies
*/
const child_process = require( 'child_process' );
const fs = require( 'fs' );
const path = require( 'path' );
const child_process = require( 'child_process' );

/**
* Internal dependencies
*/
const config = require( path.join( __dirname, 'config' ) );
const transformsDir = path.join( __dirname, './transforms' );

Expand Down
3 changes: 0 additions & 3 deletions packages/calypso-codemods/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/usr/bin/env node

/**
* Internal dependencies
*/
const api = require( './api' );

function main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`basic.js 1`] = `
"/**
* Internal dependencies
*/
"
import hello from 'internal/lib';

import { combineReducers } from \\"state/utils\\";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { combineReducers } from 'redux';

/**
* Internal dependencies
*/

import hello from 'internal/lib';
Loading