Skip to content

Commit fc760b8

Browse files
committed
Align code style with jQuery - use tab indents
1 parent d4b04ae commit fc760b8

File tree

7 files changed

+449
-450
lines changed

7 files changed

+449
-450
lines changed

.editorconfig

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
root = true
55

66
[*]
7-
indent_style = space
8-
indent_size = 4
7+
indent_style = tab
98
end_of_line = lf
109
charset = utf-8
1110
trim_trailing_whitespace = true

.release-it.js

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
"use strict";
22

33
module.exports = {
4-
preReleaseBase: 1,
5-
hooks: {
6-
"before:init": "bash ./build/release/pre-release.sh",
7-
"after:version:bump":
4+
preReleaseBase: 1,
5+
hooks: {
6+
"before:init": "bash ./build/release/pre-release.sh",
7+
"after:version:bump":
88
"sed -i 's/main\\/AUTHORS.txt/${version}\\/AUTHORS.txt/' package.json",
9-
"after:bump": "cross-env VERSION=${version} npm run build",
10-
"before:git:release": "git add -f dist/",
11-
"after:release": "echo 'Run the following to complete the release:' && " +
9+
"after:bump": "cross-env VERSION=${version} npm run build",
10+
"before:git:release": "git add -f dist/",
11+
"after:release": "echo 'Run the following to complete the release:' && " +
1212
"echo './build/release/post-release.sh $\{version}'"
13-
},
14-
git: {
15-
commitMessage: "Release: ${version}",
16-
getLatestTagFromAllRefs: true,
17-
pushRepo: "[email protected]:jquery/jquery-mousewheel.git",
18-
requireBranch: "main",
19-
requireCleanWorkingDir: true
20-
},
21-
github: {
22-
pushRepo: "[email protected]:jquery/jquery-mousewheel.git",
23-
release: true,
24-
tokenRef: "JQUERY_GITHUB_TOKEN"
25-
},
26-
npm: {
27-
publish: true
28-
}
13+
},
14+
git: {
15+
commitMessage: "Release: ${version}",
16+
getLatestTagFromAllRefs: true,
17+
pushRepo: "[email protected]:jquery/jquery-mousewheel.git",
18+
requireBranch: "main",
19+
requireCleanWorkingDir: true
20+
},
21+
github: {
22+
pushRepo: "[email protected]:jquery/jquery-mousewheel.git",
23+
release: true,
24+
tokenRef: "JQUERY_GITHUB_TOKEN"
25+
},
26+
npm: {
27+
publish: true
28+
}
2929
};

build/tasks/build.mjs

+31-31
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,43 @@ const exec = util.promisify( nodeExec );
99
const pkg = JSON.parse( await fs.readFile( "./package.json", "utf8" ) );
1010

1111
async function isCleanWorkingDir() {
12-
const { stdout } = await exec( "git status --untracked-files=no --porcelain" );
13-
return !stdout.trim();
12+
const { stdout } = await exec( "git status --untracked-files=no --porcelain" );
13+
return !stdout.trim();
1414
}
1515

1616
async function versionForDist( { srcPath, destPath, version } ) {
17-
const code = await fs.readFile( srcPath, "utf8" );
18-
const compiledContents = code.replace( /@VERSION/g, version );
17+
const code = await fs.readFile( srcPath, "utf8" );
18+
const compiledContents = code.replace( /@VERSION/g, version );
1919

20-
await fs.mkdir( path.dirname( destPath ), { recursive: true } );
21-
await fs.writeFile( destPath, compiledContents );
22-
console.log( `${ destPath } v${ version } created.` );
20+
await fs.mkdir( path.dirname( destPath ), { recursive: true } );
21+
await fs.writeFile( destPath, compiledContents );
22+
console.log( `${ destPath } v${ version } created.` );
2323
}
2424

2525
export async function build( { version = process.env.VERSION } = {} ) {
2626

27-
// Add the short commit hash to the version string
28-
// when the version is not for a release.
29-
if ( !version ) {
30-
const { stdout } = await exec( "git rev-parse --short HEAD" );
31-
const isClean = await isCleanWorkingDir();
32-
33-
// "+SHA" is semantically correct
34-
// Add ".dirty" as well if the working dir is not clean
35-
version = `${ pkg.version }+${ stdout.trim() }${
36-
isClean ? "" : ".dirty"
37-
}`;
38-
}
39-
40-
await versionForDist( {
41-
srcPath: "src/jquery.mousewheel.js",
42-
destPath: "dist/jquery.mousewheel.js",
43-
version
44-
} );
45-
46-
await minify( {
47-
srcPath: "dist/jquery.mousewheel.js",
48-
destPath: "dist/jquery.mousewheel.min.js",
49-
version
50-
} );
27+
// Add the short commit hash to the version string
28+
// when the version is not for a release.
29+
if ( !version ) {
30+
const { stdout } = await exec( "git rev-parse --short HEAD" );
31+
const isClean = await isCleanWorkingDir();
32+
33+
// "+SHA" is semantically correct
34+
// Add ".dirty" as well if the working dir is not clean
35+
version = `${ pkg.version }+${ stdout.trim() }${
36+
isClean ? "" : ".dirty"
37+
}`;
38+
}
39+
40+
await versionForDist( {
41+
srcPath: "src/jquery.mousewheel.js",
42+
destPath: "dist/jquery.mousewheel.js",
43+
version
44+
} );
45+
46+
await minify( {
47+
srcPath: "dist/jquery.mousewheel.js",
48+
destPath: "dist/jquery.mousewheel.min.js",
49+
version
50+
} );
5151
}

build/tasks/minify.mjs

+27-27
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,37 @@ import swc from "@swc/core";
33
import path from "node:path";
44

55
export async function minify( { srcPath, destPath, version } ) {
6-
const contents = await fs.readFile( srcPath, "utf8" );
6+
const contents = await fs.readFile( srcPath, "utf8" );
77

8-
await fs.mkdir( path.dirname( destPath ), { recursive: true } );
8+
await fs.mkdir( path.dirname( destPath ), { recursive: true } );
99

10-
const { code } = await swc.minify(
11-
contents,
12-
{
13-
compress: {
14-
ecma: 5,
15-
hoist_funs: false,
16-
loops: false
17-
},
18-
format: {
19-
ecma: 5,
20-
asciiOnly: true,
21-
comments: false,
22-
preamble: `/*! jQuery Mousewheel ${ version }` +
10+
const { code } = await swc.minify(
11+
contents,
12+
{
13+
compress: {
14+
ecma: 5,
15+
hoist_funs: false,
16+
loops: false
17+
},
18+
format: {
19+
ecma: 5,
20+
asciiOnly: true,
21+
comments: false,
22+
preamble: `/*! jQuery Mousewheel ${ version }` +
2323
" | (c) OpenJS Foundation and other contributors" +
2424
" | jquery.org/license */\n"
25-
},
26-
inlineSourcesContent: false,
27-
mangle: true,
28-
module: false,
29-
sourceMap: false
30-
}
31-
);
25+
},
26+
inlineSourcesContent: false,
27+
mangle: true,
28+
module: false,
29+
sourceMap: false
30+
}
31+
);
3232

33-
await fs.writeFile(
34-
destPath,
35-
code
36-
);
33+
await fs.writeFile(
34+
destPath,
35+
code
36+
);
3737

38-
console.log( `file ${ destPath } created.` );
38+
console.log( `file ${ destPath } created.` );
3939
}

eslint.config.mjs

+80-80
Original file line numberDiff line numberDiff line change
@@ -2,93 +2,93 @@ import jqueryConfig from "eslint-config-jquery";
22
import globals from "globals";
33

44
export default [
5-
{
6-
ignores: [ "dist/**/*.js" ],
7-
rules: {
8-
...jqueryConfig.rules,
9-
indent: [ "error", 4 ]
10-
}
11-
},
5+
{
6+
ignores: [ "dist/**/*.js" ],
7+
rules: {
8+
...jqueryConfig.rules,
9+
indent: [ "error", "tab" ]
10+
}
11+
},
1212

13-
{
14-
files: [
15-
"src/**/*.js",
16-
"dist/**/*.js",
17-
"test/**/*.js"
18-
],
19-
languageOptions: {
13+
{
14+
files: [
15+
"src/**/*.js",
16+
"dist/**/*.js",
17+
"test/**/*.js"
18+
],
19+
languageOptions: {
2020

21-
// Support: IE 9 - 11+
22-
ecmaVersion: 5,
21+
// Support: IE 9 - 11+
22+
ecmaVersion: 5,
2323

24-
sourceType: "script",
24+
sourceType: "script",
2525

26-
// Support: Non-browser envs like jsdom
27-
// Don't include `globals.browser`, take browser globals from `window`.
28-
globals: {
29-
window: "readonly",
30-
define: "readonly",
31-
module: "readonly",
32-
jQuery: "readonly"
33-
}
34-
}
35-
},
26+
// Support: Non-browser envs like jsdom
27+
// Don't include `globals.browser`, take browser globals from `window`.
28+
globals: {
29+
window: "readonly",
30+
define: "readonly",
31+
module: "readonly",
32+
jQuery: "readonly"
33+
}
34+
}
35+
},
3636

37-
{
38-
files: [ "src/**/*.js" ],
39-
rules: {
40-
strict: [ "error", "function" ],
41-
indent: [
42-
"error",
43-
4,
44-
{
37+
{
38+
files: [ "src/**/*.js" ],
39+
rules: {
40+
strict: [ "error", "function" ],
41+
indent: [
42+
"error",
43+
"tab",
44+
{
4545

46-
// This makes it so code within the wrapper is not indented.
47-
ignoredNodes: [
48-
"Program > FunctionDeclaration > *"
49-
]
50-
}
51-
]
52-
}
53-
},
46+
// This makes it so code within the wrapper is not indented.
47+
ignoredNodes: [
48+
"Program > FunctionDeclaration > *"
49+
]
50+
}
51+
]
52+
}
53+
},
5454

55-
{
56-
files: [ "test/**/*.js" ],
57-
languageOptions: {
58-
globals: {
59-
QUnit: "readonly"
60-
}
61-
},
62-
rules: {
63-
strict: [ "error", "global" ]
64-
}
65-
},
55+
{
56+
files: [ "test/**/*.js" ],
57+
languageOptions: {
58+
globals: {
59+
QUnit: "readonly"
60+
}
61+
},
62+
rules: {
63+
strict: [ "error", "global" ]
64+
}
65+
},
6666

67-
{
68-
files: [ "*.js" ],
69-
languageOptions: {
70-
ecmaVersion: "latest",
71-
sourceType: "commonjs",
72-
globals: {
73-
...globals.node
74-
}
75-
},
76-
rules: {
77-
...jqueryConfig.rules
78-
}
79-
},
67+
{
68+
files: [ "*.js" ],
69+
languageOptions: {
70+
ecmaVersion: "latest",
71+
sourceType: "commonjs",
72+
globals: {
73+
...globals.node
74+
}
75+
},
76+
rules: {
77+
...jqueryConfig.rules
78+
}
79+
},
8080

81-
{
82-
files: [ "*.mjs", "build/**/*.mjs" ],
83-
languageOptions: {
84-
ecmaVersion: "latest",
85-
sourceType: "module",
86-
globals: {
87-
...globals.node
88-
}
89-
},
90-
rules: {
91-
...jqueryConfig.rules
92-
}
93-
}
81+
{
82+
files: [ "*.mjs", "build/**/*.mjs" ],
83+
languageOptions: {
84+
ecmaVersion: "latest",
85+
sourceType: "module",
86+
globals: {
87+
...globals.node
88+
}
89+
},
90+
rules: {
91+
...jqueryConfig.rules
92+
}
93+
}
9494
];

0 commit comments

Comments
 (0)