├── .editorconfig ├── .gitattributes ├── .github ├── security.md └── workflows │ └── main.yml ├── .gitignore ├── .npmrc ├── browser.js ├── index.js ├── license ├── package.json ├── readme.md └── test └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.yml] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.github/security.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. 4 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | - push 4 | - pull_request 5 | jobs: 6 | test: 7 | name: Node.js ${{ matrix.node-version }} 8 | runs-on: ubuntu-latest 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | node-version: 13 | - 20 14 | - 18 15 | steps: 16 | - uses: actions/checkout@v4 17 | - uses: actions/setup-node@v4 18 | with: 19 | node-version: ${{ matrix.node-version }} 20 | - run: npm install 21 | - run: npm test 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | yarn.lock 3 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /browser.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: 'xo/browser', 5 | rules: { 6 | indent: [ 7 | 'error', 8 | 2, 9 | { 10 | SwitchCase: 1 11 | } 12 | ] 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: 'xo', 5 | rules: { 6 | indent: [ 7 | 'error', 8 | 2, 9 | { 10 | SwitchCase: 1 11 | } 12 | ] 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Sindre Sorhus (https://sindresorhus.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eslint-config-xo-space", 3 | "version": "0.35.0", 4 | "description": "ESLint shareable config for XO with 2-space indent", 5 | "license": "MIT", 6 | "repository": "xojs/eslint-config-xo-space", 7 | "funding": "https://github.com/sponsors/sindresorhus", 8 | "author": { 9 | "name": "Sindre Sorhus", 10 | "email": "sindresorhus@gmail.com", 11 | "url": "https://sindresorhus.com" 12 | }, 13 | "sideEffects": false, 14 | "engines": { 15 | "node": ">=12" 16 | }, 17 | "scripts": { 18 | "test": "ava" 19 | }, 20 | "files": [ 21 | "index.js", 22 | "esnext.js", 23 | "browser.js" 24 | ], 25 | "keywords": [ 26 | "space", 27 | "spaces", 28 | "eslintconfig", 29 | "xo", 30 | "xoxo", 31 | "code", 32 | "quality", 33 | "style", 34 | "lint", 35 | "linter", 36 | "jscs", 37 | "jshint", 38 | "jslint", 39 | "eslint", 40 | "validate", 41 | "code style", 42 | "standard", 43 | "strict", 44 | "check", 45 | "checker", 46 | "verify", 47 | "enforce", 48 | "hint", 49 | "simple" 50 | ], 51 | "dependencies": { 52 | "eslint-config-xo": "^0.44.0" 53 | }, 54 | "devDependencies": { 55 | "ava": "^2.4.0", 56 | "eslint": "^8.56.0", 57 | "is-plain-obj": "^3.0.0" 58 | }, 59 | "peerDependencies": { 60 | "eslint": ">=8.56.0" 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # eslint-config-xo-space 2 | 3 | > ESLint [shareable config](http://eslint.org/docs/developer-guide/shareable-configs.html) for [XO](https://github.com/xojs/xo) with 2-space indent 4 | 5 | This is for advanced users. [You probably want to use XO directly.](https://github.com/xojs/eslint-config-xo#use-the-xo-cli-instead) 6 | 7 | **Use the [XO issue tracker](https://github.com/xojs/xo/issues) instead of this one.** 8 | 9 | ## Install 10 | 11 | ```sh 12 | npm install --save-dev eslint-config-xo-space 13 | ``` 14 | 15 | ## Usage 16 | 17 | Add some ESLint config to your `package.json`: 18 | 19 | ```json 20 | { 21 | "name": "my-awesome-project", 22 | "eslintConfig": { 23 | "extends": "xo-space" 24 | } 25 | } 26 | ``` 27 | 28 | Or to `.eslintrc`: 29 | 30 | ```json 31 | { 32 | "extends": "xo-space" 33 | } 34 | ``` 35 | 36 | This package also exposes [`xo-space/browser`](browser.js) if you're in the browser: 37 | 38 | ```json 39 | { 40 | "extends": "xo-space/browser" 41 | } 42 | ``` 43 | 44 | ## Related 45 | 46 | - [eslint-config-xo](https://github.com/xojs/eslint-config-xo) - ESLint shareable config for XO 47 | - [eslint-config-xo-react](https://github.com/xojs/eslint-config-xo-react) - ESLint shareable config for React to be used with the above 48 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | import isPlainObj from 'is-plain-obj'; 3 | import {ESLint} from 'eslint'; 4 | 5 | const hasRule = (errors, ruleId) => errors.some(error => error.ruleId === ruleId); 6 | 7 | const fixture = `"use strict";\nconst x = true;\n\nif (x) {\n console.log();\n}\n`; 8 | 9 | async function runEslint(string, config) { 10 | const eslint = new ESLint({ 11 | useEslintrc: false, 12 | overrideConfig: config, 13 | }); 14 | 15 | const [firstResult] = await eslint.lintText(string); 16 | 17 | return firstResult.messages; 18 | } 19 | 20 | test('main', async t => { 21 | const config = require('../index.js'); 22 | 23 | t.true(isPlainObj(config)); 24 | t.true(isPlainObj(config.rules)); 25 | 26 | const errors = await runEslint(fixture, config); 27 | t.true(hasRule(errors, 'quotes'), JSON.stringify(errors)); 28 | }); 29 | 30 | test('browser', async t => { 31 | const config = require('../browser.js'); 32 | 33 | t.true(isPlainObj(config)); 34 | t.true(isPlainObj(config.rules)); 35 | 36 | const errors = await runEslint(fixture, config); 37 | t.true(hasRule(errors, 'quotes'), JSON.stringify(errors)); 38 | }); 39 | --------------------------------------------------------------------------------