Skip to content

🔪/✨ 5.0 #316

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

Merged
merged 10 commits into from
Jan 20, 2021
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .babelrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "10"
}
}
]
]
}
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,26 @@ module.exports = {
}
```

##### Strict Preset

> ✨ The strict preset is recommended for new projects!

A strict preset is also available that includes more agressive linting rules
that enforce the order and grouping of imports.

```js
module.exports = {
extends: [
require.resolve('@hover/javascript/eslint'),
require.resolve('@hover/javascript/eslint/strict'),
],
// Include this when using TypeScript
parserOptions: {
project: ['./tsconfig.json'],
},
}
```

#### Prettier

Or, for Prettier, a `.prettierrc.js` with:
Expand Down
1 change: 0 additions & 1 deletion api.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion api.js

This file was deleted.

1 change: 1 addition & 0 deletions api/commit.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../dist/api/commit'
1 change: 1 addition & 0 deletions api/commit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../dist/api/commit')
1 change: 1 addition & 0 deletions api/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../dist/api'
1 change: 1 addition & 0 deletions api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../dist/api')
1 change: 0 additions & 1 deletion babel.js

This file was deleted.

1 change: 0 additions & 1 deletion eslint.js

This file was deleted.

1 change: 1 addition & 0 deletions eslint/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../dist/config/eslintrc')
1 change: 1 addition & 0 deletions eslint/strict.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../dist/config/eslintrc-strict')
37 changes: 7 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"test": "node src test",
"test:update": "node src test --updateSnapshot",
"build": "run-p build:*",
"build:source": "node src build",
"build:source": "babel --source-maps --out-dir dist --ignore '**/__tests__/**','**/__mocks__/**' --copy-files --no-copy-ignored src",
"build:types": "tsc -p src/",
"lint": "node src lint",
"format": "node src format",
Expand All @@ -34,13 +34,12 @@
"files": [
"api",
"api.d.ts",
"api.js",
"babel.js",
"dist",
"commitlint.js",
"config.js",
"dist",
"eslint-react.js",
"eslint.js",
"eslint",
"jest.js",
"lint-staged.js",
"prettier.js",
Expand All @@ -51,33 +50,13 @@
"author": "Jamie Rolfs <[email protected]>",
"license": "MIT",
"dependencies": {
"@babel/cli": "^7.11.6",
"@babel/core": "^7.11.6",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-transform-modules-commonjs": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.11.5",
"@babel/preset-flow": "^7.8.3",
"@babel/preset-react": "^7.8.3",
"@babel/runtime": "^7.11.2",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@commitlint/prompt": "^11.0.0",
"@rollup/plugin-commonjs": "^15.0.0",
"@rollup/plugin-json": "^4.0.2",
"@rollup/plugin-node-resolve": "^7.1.1",
"@rollup/plugin-replace": "^2.3.1",
"@types/jest": "^26.0.14",
"@typescript-eslint/eslint-plugin": "^4.4.0",
"@typescript-eslint/parser": "^4.4.0",
"arrify": "^2.0.1",
"babel-jest": "^26.3.0",
"babel-plugin-macros": "^2.8.0",
"babel-plugin-minify-dead-code-elimination": "^0.5.1",
"babel-plugin-module-resolver": "^4.0.0",
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"browserslist": "^4.14.5",
"chalk": "^4.1.0",
"commitizen": "^4.2.1",
"concurrently": "^5.1.0",
Expand Down Expand Up @@ -109,12 +88,6 @@
"read-pkg-up": "^7.0.1",
"resolve": "^1.15.1",
"rimraf": "^3.0.2",
"rollup": "^2.26.4",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-size-snapshot": "^0.12.0",
"rollup-plugin-terser": "^7.0.2",
"semver": "^7.1.3",
"typescript": "^4.0.3",
"which": "^2.0.2",
Expand Down Expand Up @@ -148,6 +121,10 @@
},
"homepage": "https://github.com/hoverinc/hover-javascript#readme",
"devDependencies": {
"@babel/cli": "^7.11.6",
"@babel/core": "^7.11.6",
"@babel/preset-env": "^7.11.5",
"babel-jest": "^26.5.2",
"jest-in-case": "^1.0.2",
"npm-run-all": "^4.1.5",
"slash": "^3.0.0"
Expand Down
9 changes: 0 additions & 9 deletions src/__tests__/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,13 @@ Array [
]
`;

exports[`format logs for SIGTERM signal 1`] = `
Array [
Array [
The script "build" failed because the process exited too early. Someone might have called \`kill\` or \`killall\`, or the system could be shutting down.,
],
]
`;

exports[`format logs help with no args 1`] = `
Array [
Array [

Usage: ../ [script] [--flags]

Available Scripts:
build
ci-after-success
commit-msg
commit
Expand Down
4 changes: 0 additions & 4 deletions src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ cases(
args: ['lint'],
signal: 'SIGKILL',
},
'logs for SIGTERM signal': {
args: ['build'],
signal: 'SIGTERM',
},
'does not log for other signals': {
args: ['test'],
signal: 'SIGBREAK',
Expand Down
4 changes: 0 additions & 4 deletions src/config/__tests__/umbrella.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
test('requiring some files does not blow up', () => {
require('../babel-transform')
require('../babelrc')
require('../eslintrc')
require('../eslintrc-react')
require('../jest.config')
require('../lintstagedrc')
require('../prettierrc')
require('../rollup.config')
require('../').getRollupConfig()
})
5 changes: 0 additions & 5 deletions src/config/babel-transform.js

This file was deleted.

97 changes: 0 additions & 97 deletions src/config/babelrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/config/eslintrc-react.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const {buildConfig} = require('./helpers/eslint')
const {buildConfig} = require('./helpers/build-eslint')

module.exports = buildConfig({withReact: true})
17 changes: 17 additions & 0 deletions src/config/eslintrc-strict.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
rules: {
'import/order': [
'error',
{
alphabetize: {order: 'asc'},
'newlines-between': 'always',
pathGroups: [
{pattern: 'src/**/*', group: 'parent', position: 'before'},
{pattern: 'assets/**/*', group: 'parent', position: 'before'},
],
pathGroupsExcludedImportTypes: ['builtin'],
},
],
'sort-imports': ['error', {ignoreDeclarationSort: true}],
},
}
2 changes: 1 addition & 1 deletion src/config/eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const {buildConfig} = require('./helpers/eslint')
const {buildConfig} = require('./helpers/build-eslint')

module.exports = buildConfig()
26 changes: 11 additions & 15 deletions src/config/helpers/build-eslint.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const {rules} = require('eslint-config-airbnb-typescript/lib/shared')
const {
rules: airbnbRules,
} = require('eslint-config-airbnb-typescript/lib/shared')

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

const hasReact = hasAnyDep('react')

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

Expand Down Expand Up @@ -44,7 +53,7 @@ const buildConfig = ({withReact = false} = {}) => {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: rules[
devDependencies: airbnbRules[
'import/no-extraneous-dependencies'
][1].devDependencies.concat([
'jest/**',
Expand All @@ -54,21 +63,8 @@ const buildConfig = ({withReact = false} = {}) => {
optionalDependencies: false,
},
],
'import/order': [
'error',
{
alphabetize: {order: 'asc'},
'newlines-between': 'always',
pathGroups: [
{pattern: 'src/**/*', group: 'parent', position: 'before'},
{pattern: 'assets/**/*', group: 'parent', position: 'before'},
],
pathGroupsExcludedImportTypes: ['builtin'],
},
],
'no-void': ['error', {allowAsStatement: true}],
'prettier/prettier': 'error',
'sort-imports': ['error', {ignoreDeclarationSort: true}],
...parserRules(false, isReact),
},
overrides: [
Expand Down
Loading