Skip to content

Commit

Permalink
chore: init
Browse files Browse the repository at this point in the history
  • Loading branch information
manniL committed Oct 12, 2018
0 parents commit 1c648cd
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
@@ -0,0 +1,8 @@
# Dependencies
node_modules
package-lock.json
yarn.lock

# Intellij idea
*.iml
.idea
2 changes: 2 additions & 0 deletions .npmignore
@@ -0,0 +1,2 @@
.travis.yml
tests/
4 changes: 4 additions & 0 deletions .travis.yml
@@ -0,0 +1,4 @@
language: node_js
node_js:
- 8
- 10
31 changes: 31 additions & 0 deletions README.md
@@ -0,0 +1,31 @@
# Nuxt ESLint Config

[ESlint](https://eslint.org/) config used for Nuxt.js

## Usage

Do you want to add the config to your own projects? There you go:

1. Add this package to your devDependencies (`npm i -D @nuxtjs/eslint-config` or `yarn add -D @nuxtjs/eslint-config`)
2. Add the [`peerDependencies`](./package.json) to your project

`npm i -D eslint eslint-config-standard eslint-plugin-import eslint-plugin-jest eslint-plugin-node eslint-plugin-promise eslint-plugin-standard eslint-plugin-vue`

3. Create a `.eslintrc.js` file

4. Extend our config (you can use just the scope name as ESLint will assume the `eslint-config` prefix):

```json
{
"extends": [
"@nuxtjs"
]
}
```


## License

Setup inspired by [eslint-config-standard](https://github.com/standard/eslint-config-standard)

MIT - Nuxt.js team
77 changes: 77 additions & 0 deletions index.js
@@ -0,0 +1,77 @@
module.exports = {
env: {
browser: true,
node: true,
'jest/globals': true
},
extends: [
'standard',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:vue/recommended'
],
plugins: [
'vue',
'jest'
],
settings: {
'import/resolver': {
node: { extensions: ['.js', '.mjs'] }
}
},
rules: {
// Enforce import order
'import/order': 2,

// Imports should come first
'import/first': 2,

// Other import rules
'import/no-mutable-exports': 2,

// Allow unresolved imports
'import/no-unresolved': 0,

// Allow paren-less arrow functions only when there's no braces
'arrow-parens': [2, 'as-needed', { requireForBlockBody: true }],

// Allow async-await
'generator-star-spacing': 0,

// Allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,

// Prefer const over let
'prefer-const': [2, {
'destructuring': 'any',
'ignoreReadBeforeAssign': false
}],

// No single if in an "else" block
'no-lonely-if': 2,

// Force curly braces for control flow
curly: 2,

// No async function without await
'require-await': 2,

// Force dot notation when possible
'dot-notation': 2,

'no-var': 2,

// Do not allow console.logs etc...
'no-console': 2,
'space-before-function-paren': [2, {
anonymous: 'always',
named: 'never'
}],
'vue/no-parsing-error': [2, {
'x-invalid-end-tag': false
}],
'vue/max-attributes-per-line': [2, {
'singleline': 5
}]
}
}
47 changes: 47 additions & 0 deletions package.json
@@ -0,0 +1,47 @@
{
"name": "@nuxtjs/eslint-config",
"version": "0.0.1",
"description": "Nuxt.js eslint config",
"contributors": [
"Alexander Lichter <npm@lichter.io>"
],
"license": "MIT",
"homepage": "https://github.com/nuxt/eslint-config",
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt/eslint-config.git"
},
"bugs": {
"url": "https://github.com/nuxt/eslint-config/issues"
},
"scripts": {
"lint": "eslint . --config=index.js",
"test": "npm run lint && jest",
"release": "standard-version && git push --follow-tags && npm publish"
},
"files": [
"index.js"
],
"peerDependencies": {
"eslint": ">=5.0.0",
"eslint-config-standard": ">=12.0.0",
"eslint-plugin-import": ">=2.14.0",
"eslint-plugin-jest": ">=21.24.1",
"eslint-plugin-node": ">=7.0.1",
"eslint-plugin-promise": ">=4.0.1",
"eslint-plugin-standard": ">=4.0.0",
"eslint-plugin-vue": ">=5.0.0-beta.3"
},
"devDependencies": {
"eslint": "^5.0.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jest": "^21.24.1",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^5.0.0-beta.3",
"jest": "^23.6.0",
"standard-version": "^4.4.0"
}
}
5 changes: 5 additions & 0 deletions renovate.json
@@ -0,0 +1,5 @@
{
"extends": [
"@nuxtjs"
]
}
10 changes: 10 additions & 0 deletions tests/basic.test.js
@@ -0,0 +1,10 @@
const config = require('../')

test('test basic properties of config', () => {
expect(isObject(config.env)).toBe(true)
expect(isObject(config.rules)).toBe(true)
})

function isObject(obj) {
return typeof obj === 'object' && obj !== null
}
14 changes: 14 additions & 0 deletions tests/validate-config.test.js
@@ -0,0 +1,14 @@
const eslint = require('eslint')

test('load config in eslint to validate all rule syntax is correct', () => {
const CLIEngine = eslint.CLIEngine

const cli = new CLIEngine({
useEslintrc: false,
configFile: 'index.js'
})

const code = 'const foo = 1\nconst bar = function () {}\nbar(foo)\n'

expect(cli.executeOnText(code).errorCount).toEqual(0)
})

0 comments on commit 1c648cd

Please sign in to comment.