Skip to content

Commit 0192dc9

Browse files
authored
Merge pull request #316 from hoverinc/beta
2 parents 8ad93c8 + 4beb297 commit 0192dc9

30 files changed

+265
-1436
lines changed

.babelrc.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"targets": {
7+
"node": "10"
8+
}
9+
}
10+
]
11+
]
12+
}

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,26 @@ module.exports = {
9595
}
9696
```
9797

98+
##### Strict Preset
99+
100+
> ✨ The strict preset is recommended for new projects!
101+
102+
A strict preset is also available that includes more agressive linting rules
103+
that enforce the order and grouping of imports.
104+
105+
```js
106+
module.exports = {
107+
extends: [
108+
require.resolve('@hover/javascript/eslint'),
109+
require.resolve('@hover/javascript/eslint/strict'),
110+
],
111+
// Include this when using TypeScript
112+
parserOptions: {
113+
project: ['./tsconfig.json'],
114+
},
115+
}
116+
```
117+
98118
#### Prettier
99119

100120
Or, for Prettier, a `.prettierrc.js` with:

api.d.ts

-1
This file was deleted.

api.js

-1
This file was deleted.

api/commit.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '../dist/api/commit'

api/commit.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../dist/api/commit')

api/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '../dist/api'

api/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../dist/api')

babel.js

-1
This file was deleted.

eslint.js

-1
This file was deleted.

eslint/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../dist/config/eslintrc')

eslint/strict.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../dist/config/eslintrc-strict')

package.json

+7-30
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"test": "node src test",
1515
"test:update": "node src test --updateSnapshot",
1616
"build": "run-p build:*",
17-
"build:source": "node src build",
17+
"build:source": "babel --source-maps --out-dir dist --ignore '**/__tests__/**','**/__mocks__/**' --copy-files --no-copy-ignored src",
1818
"build:types": "tsc -p src/",
1919
"lint": "node src lint",
2020
"format": "node src format",
@@ -34,13 +34,12 @@
3434
"files": [
3535
"api",
3636
"api.d.ts",
37-
"api.js",
38-
"babel.js",
37+
"dist",
3938
"commitlint.js",
4039
"config.js",
4140
"dist",
4241
"eslint-react.js",
43-
"eslint.js",
42+
"eslint",
4443
"jest.js",
4544
"lint-staged.js",
4645
"prettier.js",
@@ -51,33 +50,13 @@
5150
"author": "Jamie Rolfs <[email protected]>",
5251
"license": "MIT",
5352
"dependencies": {
54-
"@babel/cli": "^7.11.6",
55-
"@babel/core": "^7.11.6",
56-
"@babel/plugin-proposal-class-properties": "^7.8.3",
57-
"@babel/plugin-transform-modules-commonjs": "^7.8.3",
58-
"@babel/plugin-transform-runtime": "^7.12.1",
59-
"@babel/preset-env": "^7.11.5",
60-
"@babel/preset-flow": "^7.8.3",
61-
"@babel/preset-react": "^7.8.3",
62-
"@babel/runtime": "^7.11.2",
6353
"@commitlint/cli": "^11.0.0",
6454
"@commitlint/config-conventional": "^11.0.0",
6555
"@commitlint/prompt": "^11.0.0",
66-
"@rollup/plugin-commonjs": "^15.0.0",
67-
"@rollup/plugin-json": "^4.0.2",
68-
"@rollup/plugin-node-resolve": "^7.1.1",
69-
"@rollup/plugin-replace": "^2.3.1",
7056
"@types/jest": "^26.0.14",
7157
"@typescript-eslint/eslint-plugin": "^4.4.0",
7258
"@typescript-eslint/parser": "^4.4.0",
7359
"arrify": "^2.0.1",
74-
"babel-jest": "^26.3.0",
75-
"babel-plugin-macros": "^2.8.0",
76-
"babel-plugin-minify-dead-code-elimination": "^0.5.1",
77-
"babel-plugin-module-resolver": "^4.0.0",
78-
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
79-
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
80-
"browserslist": "^4.14.5",
8160
"chalk": "^4.1.0",
8261
"commitizen": "^4.2.1",
8362
"concurrently": "^5.1.0",
@@ -109,12 +88,6 @@
10988
"read-pkg-up": "^7.0.1",
11089
"resolve": "^1.15.1",
11190
"rimraf": "^3.0.2",
112-
"rollup": "^2.26.4",
113-
"rollup-plugin-babel": "^4.3.3",
114-
"rollup-plugin-node-builtins": "^2.1.2",
115-
"rollup-plugin-node-globals": "^1.4.0",
116-
"rollup-plugin-size-snapshot": "^0.12.0",
117-
"rollup-plugin-terser": "^7.0.2",
11891
"semver": "^7.1.3",
11992
"typescript": "^4.0.3",
12093
"which": "^2.0.2",
@@ -148,6 +121,10 @@
148121
},
149122
"homepage": "https://github.com/hoverinc/hover-javascript#readme",
150123
"devDependencies": {
124+
"@babel/cli": "^7.11.6",
125+
"@babel/core": "^7.11.6",
126+
"@babel/preset-env": "^7.11.5",
127+
"babel-jest": "^26.5.2",
151128
"jest-in-case": "^1.0.2",
152129
"npm-run-all": "^4.1.5",
153130
"slash": "^3.0.0"

src/__tests__/__snapshots__/index.js.snap

-9
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,13 @@ Array [
1414
]
1515
`;
1616
17-
exports[`format logs for SIGTERM signal 1`] = `
18-
Array [
19-
Array [
20-
The script "build" failed because the process exited too early. Someone might have called \`kill\` or \`killall\`, or the system could be shutting down.,
21-
],
22-
]
23-
`;
24-
2517
exports[`format logs help with no args 1`] = `
2618
Array [
2719
Array [
2820
2921
Usage: ../ [script] [--flags]
3022
3123
Available Scripts:
32-
build
3324
ci-after-success
3425
commit-msg
3526
commit

src/__tests__/index.js

-4
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ cases(
7373
args: ['lint'],
7474
signal: 'SIGKILL',
7575
},
76-
'logs for SIGTERM signal': {
77-
args: ['build'],
78-
signal: 'SIGTERM',
79-
},
8076
'does not log for other signals': {
8177
args: ['test'],
8278
signal: 'SIGBREAK',

src/config/__tests__/umbrella.js

-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
test('requiring some files does not blow up', () => {
2-
require('../babel-transform')
3-
require('../babelrc')
42
require('../eslintrc')
53
require('../eslintrc-react')
64
require('../jest.config')
75
require('../lintstagedrc')
86
require('../prettierrc')
9-
require('../rollup.config')
10-
require('../').getRollupConfig()
117
})

src/config/babel-transform.js

-5
This file was deleted.

src/config/babelrc.js

-97
This file was deleted.

src/config/eslintrc-react.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
const {buildConfig} = require('./helpers/eslint')
1+
const {buildConfig} = require('./helpers/build-eslint')
22

33
module.exports = buildConfig({withReact: true})

src/config/eslintrc-strict.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
rules: {
3+
'import/order': [
4+
'error',
5+
{
6+
alphabetize: {order: 'asc'},
7+
'newlines-between': 'always',
8+
pathGroups: [
9+
{pattern: 'src/**/*', group: 'parent', position: 'before'},
10+
{pattern: 'assets/**/*', group: 'parent', position: 'before'},
11+
],
12+
pathGroupsExcludedImportTypes: ['builtin'],
13+
},
14+
],
15+
'sort-imports': ['error', {ignoreDeclarationSort: true}],
16+
},
17+
}

src/config/eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
const {buildConfig} = require('./helpers/eslint')
1+
const {buildConfig} = require('./helpers/build-eslint')
22

33
module.exports = buildConfig()

src/config/helpers/build-eslint.js

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
const {rules} = require('eslint-config-airbnb-typescript/lib/shared')
1+
const {
2+
rules: airbnbRules,
3+
} = require('eslint-config-airbnb-typescript/lib/shared')
24

35
const {hasAnyDep} = require('../../utils')
46
const {testMatch} = require('../jest.config')
@@ -11,6 +13,13 @@ const prettier = withBaseConfig('eslint-config-prettier')
1113

1214
const hasReact = hasAnyDep('react')
1315

16+
/**
17+
* Helper that applies some rules conditionally based on whether the TypeScript
18+
* parser and type-aware linting rules are enabled
19+
*
20+
* @param {boolean} [typescript] - whether specific TypeScript parsing is applied
21+
* @param {boolean} [react] - whether in React support is enabled
22+
*/
1423
const parserRules = (typescript = false, react = false) => {
1524
const isOff = off => (off ? 'off' : 'error')
1625

@@ -44,7 +53,7 @@ const buildConfig = ({withReact = false} = {}) => {
4453
'import/no-extraneous-dependencies': [
4554
'error',
4655
{
47-
devDependencies: rules[
56+
devDependencies: airbnbRules[
4857
'import/no-extraneous-dependencies'
4958
][1].devDependencies.concat([
5059
'jest/**',
@@ -54,21 +63,8 @@ const buildConfig = ({withReact = false} = {}) => {
5463
optionalDependencies: false,
5564
},
5665
],
57-
'import/order': [
58-
'error',
59-
{
60-
alphabetize: {order: 'asc'},
61-
'newlines-between': 'always',
62-
pathGroups: [
63-
{pattern: 'src/**/*', group: 'parent', position: 'before'},
64-
{pattern: 'assets/**/*', group: 'parent', position: 'before'},
65-
],
66-
pathGroupsExcludedImportTypes: ['builtin'],
67-
},
68-
],
6966
'no-void': ['error', {allowAsStatement: true}],
7067
'prettier/prettier': 'error',
71-
'sort-imports': ['error', {ignoreDeclarationSort: true}],
7268
...parserRules(false, isReact),
7369
},
7470
overrides: [

0 commit comments

Comments
 (0)