Skip to content

Commit bee6a36

Browse files
authored
Sort and group imports (#381)
1 parent c76a567 commit bee6a36

41 files changed

Lines changed: 163 additions & 91 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/ten-pets-pay.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@cloudfour/eslint-plugin': major
3+
---
4+
5+
Sort imports
6+
7+
**Newly Enabled Rules**
8+
9+
- [`@cloudfour/import/order`](https://github.com/import-js/eslint-plugin-import/blob/v2.25.4/docs/rules/order.md)
10+
- [`sort-imports`](https://eslint.org/docs/rules/sort-imports)
11+
12+
These rules sort imports into separate categories, with empty lines between the categories, and with the imports within a category sorted alphabetically. The variable bindings within an import statement are also sorted alphabetically.
13+
14+
These rules are auto-fixable, however in some cases manual sorting may be needed. Occasionally, the auto-fix will detach comments from the import statements they refer to.

build.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const prettier = require('prettier');
21
const { writeFileSync } = require('fs');
32
const { join, sep } = require('path');
43

4+
const prettier = require('prettier');
5+
56
const { configs, environments } = require('./src/config');
67

78
const resolveStart = '__REQUIRE_RESOLVE__';

fixtures/babel/packages/babel-helper-create-class-features-plugin/src/decorators.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { types as t, template } from '@babel/core';
2-
import ReplaceSupers from '@babel/helper-replace-supers';
32
import nameFunction from '@babel/helper-function-name';
3+
import ReplaceSupers from '@babel/helper-replace-supers';
44

55
export function hasOwnDecorators(node) {
66
return Boolean(node.decorators && node.decorators.length > 0);

fixtures/babel/packages/babel-helper-create-class-features-plugin/src/fields.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* eslint-disable max-params */
2-
import { template, traverse, types as t } from '@babel/core';
2+
import { types as t, template, traverse } from '@babel/core';
3+
import memberExpressionToFunctions from '@babel/helper-member-expression-to-functions';
4+
import optimiseCall from '@babel/helper-optimise-call-expression';
35
import ReplaceSupers, {
46
environmentVisitor,
57
} from '@babel/helper-replace-supers';
6-
import memberExpressionToFunctions from '@babel/helper-member-expression-to-functions';
7-
import optimiseCall from '@babel/helper-optimise-call-expression';
88

99
import * as ts from './typescript';
1010

fixtures/babel/packages/babel-plugin-transform-for-of/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { types as t, template } from '@babel/core';
12
import { declare } from '@babel/helper-plugin-utils';
2-
import { template, types as t } from '@babel/core';
33

44
import transformWithoutHelper from './no-helper-implementation';
55

fixtures/babel/packages/babel-plugin-transform-modules-amd/src/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { declare } from '@babel/helper-plugin-utils';
1+
import { types as t, template } from '@babel/core';
22
import {
3-
isModule,
4-
rewriteModuleStatementsAndPrepareHeader,
5-
hasExports,
6-
isSideEffectImport,
73
buildNamespaceInitStatements,
84
ensureStatementsHoisted,
9-
wrapInterop,
105
getModuleName,
6+
hasExports,
7+
isModule,
8+
isSideEffectImport,
9+
rewriteModuleStatementsAndPrepareHeader,
10+
wrapInterop,
1111
} from '@babel/helper-module-transforms';
12-
import { template, types as t } from '@babel/core';
12+
import { declare } from '@babel/helper-plugin-utils';
1313
import { getImportSource } from 'babel-plugin-dynamic-import-node/utils';
1414

1515
const buildWrapper = template(`

fixtures/babel/packages/babel-plugin-transform-modules-commonjs/src/index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
import { declare } from '@babel/helper-plugin-utils';
1+
import { types as t, template } from '@babel/core';
22
import {
3-
isModule,
4-
rewriteModuleStatementsAndPrepareHeader,
5-
isSideEffectImport,
63
buildNamespaceInitStatements,
74
ensureStatementsHoisted,
8-
wrapInterop,
95
getModuleName,
6+
isModule,
7+
isSideEffectImport,
8+
rewriteModuleStatementsAndPrepareHeader,
9+
wrapInterop,
1010
} from '@babel/helper-module-transforms';
11+
import { declare } from '@babel/helper-plugin-utils';
1112
import simplifyAccess from '@babel/helper-simple-access';
12-
import { template, types as t } from '@babel/core';
13-
1413
import { createDynamicImportTransform } from 'babel-plugin-dynamic-import-node/utils';
1514

1615
export default declare((api, options) => {

fixtures/babel/packages/babel-plugin-transform-parameters/src/params.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { template, types as t } from '@babel/core';
1+
import { types as t, template } from '@babel/core';
22

33
const buildDefaultParam = template(`
44
let VARIABLE_NAME =

fixtures/babel/packages/babel-plugin-transform-runtime/scripts/build-dist.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
'use strict';
22

33
const path = require('path');
4-
const outputFile = require('output-file-sync');
5-
const helpers = require('@babel/helpers');
4+
65
const babel = require('@babel/core');
6+
const helpers = require('@babel/helpers');
7+
const runtimeVersion = require('@babel/runtime/package.json').version;
78
const template = require('@babel/template');
89
const t = require('@babel/types');
10+
const outputFile = require('output-file-sync');
911

1012
const transformRuntime = require('..');
11-
12-
const runtimeVersion = require('@babel/runtime/package.json').version;
1313
const corejs2Definitions =
1414
require('../lib/runtime-corejs2-definitions').default();
1515
const corejs3Definitions =

fixtures/cloudfour.com-patterns/gulpfile.js/tasks/svg-to-twig.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
const { readFileSync } = require('fs');
2+
const path = require('path');
3+
14
const { src, dest } = require('gulp');
2-
const svgmin = require('gulp-svgmin');
35
const rename = require('gulp-rename');
4-
const { obj } = require('through2');
5-
const ltx = require('ltx');
6+
const svgmin = require('gulp-svgmin');
67
const yaml = require('js-yaml');
7-
const path = require('path');
8-
const { readFileSync } = require('fs');
8+
const ltx = require('ltx');
9+
const { obj } = require('through2');
910

1011
// Load SVGO preferences from config file to keep things DRY
1112
const svgoPath = path.join(__dirname, '../../.svgo.yml');

0 commit comments

Comments
 (0)