Skip to content

Commit

Permalink
fix: eslint configs
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Jun 26, 2019
1 parent 16de037 commit 280981f
Show file tree
Hide file tree
Showing 48 changed files with 144 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
**/dist
**/**/dist/**
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"javascript.format.enable": false,
"eslint.autoFixOnSave": true,
"eslint.validate": [
"javascript",
"javascriptreact",
{ "language": "javascript", "autoFix": true },
{ "language": "javascriptreact", "autoFix": true },
{ "language": "typescript", "autoFix": true },
{ "language": "typescriptreact", "autoFix": true }
]
Expand Down
1 change: 1 addition & 0 deletions core/docz-core/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
2 changes: 1 addition & 1 deletion core/docz-core/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['eslint-config-docz'],
extends: 'docz-ts',
}
3 changes: 2 additions & 1 deletion core/docz-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@types/shelljs": "^0.8.5",
"@types/signale": "^1.2.1",
"cpy": "^7.3.0",
"docz-rollup": "^1.2.0"
"docz-rollup": "^1.2.0",
"eslint-config-docz-ts": "^1.2.0"
}
}
4 changes: 3 additions & 1 deletion core/docz-core/src/bundler/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { ServerHooks as Hooks } from '../lib/Bundler'

import * as paths from '../config/paths'

export const createConfig = (args: Args, env: Env) => async (hooks: Hooks) => {
export const createConfig = (args: Args, _env: Env) => async (
_hooks: Hooks
) => {
return {
gatsbyConfig: {
siteMetadata: {
Expand Down
2 changes: 1 addition & 1 deletion core/docz-core/src/bundler/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Config as Args } from '../config/argv'
import { ServerHooks as Hooks } from '../lib/Bundler'
import { devServerMachine } from '../machines/devServer'

export const server = (args: Args) => async (config: any, hooks: Hooks) => {
export const server = (args: Args) => async (config: any, _hooks: Hooks) => {
const doczrcFilepath = await findUp(finds('docz'))
const machine = devServerMachine.withContext({
args,
Expand Down
2 changes: 1 addition & 1 deletion core/docz-core/src/commands/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import sh from 'shelljs'

import * as paths from '../config/paths'

export const serve = async (args: Arguments<any>) => {
export const serve = async (_args: Arguments<any>) => {
sh.cd(paths.docz)
spawn.sync('yarn', ['serve'], { stdio: 'inherit' })
}
2 changes: 1 addition & 1 deletion core/docz-rollup/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['eslint-config-docz'],
extends: 'docz-js',
}
3 changes: 3 additions & 0 deletions core/docz-rollup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@
"rollup-plugin-postcss": "^2.0.3",
"rollup-plugin-progress": "^1.1.1",
"rollup-plugin-typescript2": "^0.21.2"
},
"devDependencies": {
"eslint-config-docz-js": "^1.2.0"
}
}
3 changes: 0 additions & 3 deletions core/docz-rollup/src/plugins/size.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ const filesize = require('filesize')
const gzip = require('gzip-size')
const logUpdate = require('log-update')

const cwd = process.cwd()
const label = `${chalk.cyan.bold(figures.arrowRight)}`

const placeholder = text => chalk.gray(`${text}:`)
const getFilesize = file => filesize(fs.statSync(file).size)
const getGzipSize = file => filesize(gzip.sync(fs.readFileSync(file, 'utf-8')))
Expand All @@ -19,7 +17,6 @@ module.exports = dest => ({
generateBundle(opts, bundle, isWrite) {
if (!isWrite) return

const destDir = path.join(cwd, dest)
const keys = Object.keys(bundle)
const builds = keys.map(key => bundle[key])

Expand Down
1 change: 1 addition & 0 deletions core/docz-utils/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib
2 changes: 1 addition & 1 deletion core/docz-utils/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['eslint-config-docz'],
extends: 'docz-ts',
}
3 changes: 2 additions & 1 deletion core/docz-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"unist-util-visit": "^1.4.1"
},
"devDependencies": {
"docz-rollup": "^1.2.0"
"docz-rollup": "^1.2.0",
"eslint-config-docz-ts": "^1.2.0"
}
}
2 changes: 1 addition & 1 deletion core/docz-utils/src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const formatter = (code: string) =>
} as any)

export const format = (code: string): Promise<string> =>
new Promise((resolve, reject) => {
new Promise(resolve => {
try {
const result = formatter(code)

Expand Down
1 change: 1 addition & 0 deletions core/docz/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
2 changes: 1 addition & 1 deletion core/docz/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['eslint-config-docz'],
extends: 'docz-ts',
}
3 changes: 2 additions & 1 deletion core/docz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"@types/node": "^12.0.10",
"@types/reach__router": "^1.2.4",
"@types/react": "^16.8.22",
"docz-rollup": "^1.2.0"
"docz-rollup": "^1.2.0",
"eslint-config-docz-ts": "^1.2.0"
},
"resolutions": {
"react": "^16.8.6"
Expand Down
2 changes: 1 addition & 1 deletion core/docz/src/hooks/useWindowSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const getSize = (initialWidth: number, initialHeight: number) => ({

export const useWindowSize = (
throttleMs: number = 300,
initialWidth = Infinity,
_initialWidth = Infinity,
initialHeight = Infinity
) => {
const [windowSize, setWindowSize] = useState(
Expand Down
1 change: 0 additions & 1 deletion core/gatsby-theme-docz/.eslintignore

This file was deleted.

2 changes: 1 addition & 1 deletion core/gatsby-theme-docz/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['eslint-config-docz'],
extends: 'docz-js',
}
2 changes: 1 addition & 1 deletion core/gatsby-theme-docz/lib/createPages.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const ENTRIES_QUERY = `
}
`

module.exports = ({ graphql, actions, ...props }) => {
module.exports = ({ graphql, actions }) => {
return graphql(ENTRIES_QUERY).then(({ data, errors }) => {
const hasErrors = errors && errors.length > 0
const entries = get('allDoczEntries.edges', data)
Expand Down
2 changes: 1 addition & 1 deletion core/gatsby-theme-docz/lib/sourceNodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = async ({ actions, createNodeId }, opts) => {
const values = Object.entries(map)
const contentDigest = digest(JSON.stringify(values))

values.forEach(([key, entry]) => {
values.forEach(([, entry]) => {
if (!entry) return null
createNode({
...entry,
Expand Down
7 changes: 1 addition & 6 deletions core/gatsby-theme-docz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@
"devDependencies": {
"babel-eslint": "10.0.2",
"eslint": "^5.16.0",
"eslint-config-react-app": "^4.0.1",
"eslint-plugin-flowtype": "3.11.1",
"eslint-plugin-import": "2.18.0",
"eslint-plugin-jsx-a11y": "6.2.1",
"eslint-plugin-react": "7.14.2",
"eslint-plugin-react-hooks": "^1.6.0"
"eslint-config-docz-js": "^1.2.0"
}
}
1 change: 0 additions & 1 deletion core/gatsby-theme-docz/src/components/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Link, useConfig, useCurrentDoc } from 'docz'
import styled from '@emotion/styled'

import { themeProp } from '~utils/theme'
import { breakpoints } from '~theme/breakpoints'

import { Edit, Sun, Menu, Github } from '../Icons'
import * as styles from './styles'
Expand Down
1 change: 1 addition & 0 deletions core/rehype-docz/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
2 changes: 1 addition & 1 deletion core/rehype-docz/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['eslint-config-docz'],
extends: 'docz-ts',
}
1 change: 1 addition & 0 deletions core/rehype-docz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"devDependencies": {
"@mdx-js/mdx": "^1.0.21",
"docz-rollup": "^1.2.0",
"eslint-config-docz-ts": "^1.2.0",
"remark-docz": "^1.2.0"
}
}
1 change: 1 addition & 0 deletions core/remark-docz/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
2 changes: 1 addition & 1 deletion core/remark-docz/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['eslint-config-docz'],
extends: 'docz-ts',
}
3 changes: 2 additions & 1 deletion core/remark-docz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"devDependencies": {
"@mdx-js/mdx": "^1.0.21",
"docz-rollup": "^1.2.0"
"docz-rollup": "^1.2.0",
"eslint-config-docz-ts": "^1.2.0"
}
}
26 changes: 9 additions & 17 deletions core/remark-docz/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,13 @@ const imageToJsx = (node: any): string =>

// turns `html` nodes into `jsx` nodes
export default () => (tree: any) => {
visit(
tree,
'image',
(node: any, idx: any): void => {
// check if a node has just open tag
node.type = 'jsx'
node.value = imageToJsx(node)
}
)
visit(
tree,
'jsx',
(node: any, idx: any): void => {
// check if a node has just open tag
mergeNodeWithoutCloseTag(tree, node, idx)
}
)
visit(tree, 'image', (node: any): void => {
// check if a node has just open tag
node.type = 'jsx'
node.value = imageToJsx(node)
})
visit(tree, 'jsx', (node: any, idx: any): void => {
// check if a node has just open tag
mergeNodeWithoutCloseTag(tree, node, idx)
})
}
2 changes: 1 addition & 1 deletion other-packages/babel-plugin-export-metadata/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['eslint-config-docz'],
extends: 'docz-js',
}
1 change: 1 addition & 0 deletions other-packages/babel-plugin-export-metadata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"devDependencies": {
"babel-jest": "^24.8.0",
"docz-rollup": "^1.2.0",
"eslint-config-docz-js": "^1.2.0",
"jest": "^24.8.0"
}
}
7 changes: 0 additions & 7 deletions other-packages/babel-plugin-export-metadata/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ const renameDefaultAddFileMetaProperties = (t, path, filename, name) => {
SOURCE: sourceValue,
})

// insert
const newNode = buildFileMeta({
ID: t.identifier(fallbackName),
NAME: t.stringLiteral(fallbackName),
FILENAME: t.stringLiteral(filename),
})

pathToInsert.replaceWithMultiple(nameExport)
}

Expand Down
32 changes: 32 additions & 0 deletions other-packages/eslint-config-docz-js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
parser: 'babel-eslint',
extends: ['plugin:react/recommended', 'plugin:prettier/recommended'],
rules: {
'no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: false,
argsIgnorePattern: '^_',
},
],
'comma-dangle': ['error', 'always-multiline'],
'no-mixed-operators': 'error',
'no-console': 'off',
'no-undef': 'off',
'react/prop-types': 'off',
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
settings: {
react: {
version: 'detect',
},
},
}
26 changes: 26 additions & 0 deletions other-packages/eslint-config-docz-js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "eslint-config-docz-js",
"version": "1.2.0",
"description": "Eslint config of Docz for Javascript",
"license": "MIT",
"author": {
"name": "Pedro Nauck",
"email": "[email protected]"
},
"main": "index.js",
"files": [
"index.js",
"package.json"
],
"scripts": {
"fix": "run-s fix:*",
"fix:prettier": "prettier \"src/**/*.js\" --write"
},
"dependencies": {
"babel-eslint": "^10.0.2",
"eslint": "^5.16.0",
"eslint-config-prettier": "^5.0.0",
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-react": "^7.13.0"
}
}
16 changes: 16 additions & 0 deletions other-packages/eslint-config-docz-ts/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.2.0](https://github.com/pedronauck/docz/compare/v1.1.0...v1.2.0) (2019-05-08)

**Note:** Version bump only for package eslint-config-docz





# [1.1.0](https://github.com/pedronauck/docz/compare/v1.0.4...v1.1.0) (2019-05-01)

**Note:** Version bump only for package eslint-config-docz
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ module.exports = {
'no-console': 'off',
'no-undef': 'off',
'react/prop-types': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: false,
argsIgnorePattern: '^_',
},
],
'@typescript-eslint/indent': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "eslint-config-docz",
"name": "eslint-config-docz-ts",
"version": "1.2.0",
"description": "Eslint config of Docz",
"description": "Eslint config of Docz for Typescript",
"license": "MIT",
"author": {
"name": "Pedro Nauck",
"email": "[email protected]"
},
"main": "src/index.js",
"main": "index.js",
"files": [
"src/",
"index.js",
"package.json"
],
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions other-packages/load-cfg/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
2 changes: 1 addition & 1 deletion other-packages/load-cfg/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['eslint-config-docz'],
extends: 'docz-ts',
}
Loading

0 comments on commit 280981f

Please sign in to comment.