-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: Use XO as baseline instead of Standard (#240)
- Loading branch information
1 parent
b4e0b30
commit 413dff9
Showing
16 changed files
with
3,511 additions
and
1,092 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
'@zazen/eslint-config': major | ||
--- | ||
|
||
Use XO instead of Standard as a baseline | ||
|
||
Extends `eslint-config-xo` (and `eslint-config-xo-typescript`) rules, as well as the config for `import`, `promise`, and `node` plugins from the XO CLI. | ||
|
||
Internal configs do not extend each other, in order to keep things flexible. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
plugins: ['unicorn'], | ||
extends: ['./index.js'], | ||
parserOptions: { | ||
sourceType: 'module', | ||
}, | ||
env: { | ||
node: true, | ||
}, | ||
rules: { | ||
'unicorn/prefer-module': 'off', | ||
}, | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"extends": ["github>tidaltheory/.github:renovate-config"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
name: Node ${{ matrix.node }} | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node: ['16.x'] | ||
|
||
steps: | ||
# https://github.com/actions/checkout | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
# https://github.com/actions/setup-node | ||
- name: Setup Node ${{ matrix.node }} | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
|
||
# https://github.com/bahmutov/npm-install | ||
- name: Install dependencies | ||
uses: bahmutov/npm-install@v1 | ||
|
||
- name: Test | ||
run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "test-package", | ||
"version": "0.0.0", | ||
"type": "module", | ||
"dependencies": { | ||
"eslint": "8.8.0", | ||
"is-plain-obj": "4.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=16" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { createRequire } from 'node:module' | ||
|
||
import test from 'ava' | ||
import { ESLint } from 'eslint' | ||
import isPlainObj from 'is-plain-obj' | ||
|
||
const require = createRequire(import.meta.url) | ||
const hasRule = (errors, ruleId) => | ||
errors.some((error) => error.ruleId === ruleId) | ||
|
||
async function runEslint(string, config) { | ||
let eslint = new ESLint({ | ||
useEslintrc: false, | ||
overrideConfig: config, | ||
}) | ||
|
||
let [firstResult] = await eslint.lintText(string) | ||
|
||
return firstResult.messages | ||
} | ||
|
||
test('main', async (t) => { | ||
let config = require('../index.js') | ||
|
||
t.true(isPlainObj(config)) | ||
t.true(isPlainObj(config.rules)) | ||
|
||
let errors = await runEslint( | ||
"'use strict';\nfunction q() { const foo = 'FOO' }\n", | ||
config, | ||
) | ||
t.true(hasRule(errors, 'prefer-let/prefer-let'), JSON.stringify(errors)) | ||
}) | ||
|
||
test('node', async (t) => { | ||
let config = require('../node.js') | ||
|
||
t.true(isPlainObj(config)) | ||
t.true(isPlainObj(config.rules)) | ||
|
||
let errors = await runEslint( | ||
"import path from 'path'\nimport foo from './utils/foo'\n", | ||
{ | ||
parserOptions: { sourceType: 'module', ecmaVersion: 2020 }, | ||
...config, | ||
}, | ||
) | ||
/** @todo Figure out why this rule isn't being caught in tests. */ | ||
t.false( | ||
hasRule(errors, 'n/file-extension-in-import'), | ||
JSON.stringify(errors), | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
plugins: ['n'], | ||
/** | ||
* @see https://github.com/weiran-zsd/eslint-plugin-node | ||
*/ | ||
extends: ['plugin:prettier/recommended'], | ||
rules: { | ||
/** | ||
* We have this enabled in addition to `import/extensions` as | ||
* this one has an auto-fix. | ||
*/ | ||
'n/file-extension-in-import': [ | ||
'error', | ||
'always', | ||
/** | ||
* TypeScript doesn't yet support using extensions and | ||
* fails with error TS2691. | ||
*/ | ||
{ '.ts': 'never', '.tsx': 'never' }, | ||
], | ||
'n/no-deprecated-api': 'error', | ||
'n/no-missing-import': 'off', | ||
'n/no-mixed-requires': ['error', { grouping: true, allowCall: true }], | ||
'n/no-new-require': 'error', | ||
'n/no-path-concat': 'error', | ||
'n/no-unpublished-bin': 'error', | ||
'n/no-unpublished-import': 'off', | ||
'n/no-unpublished-require': 'off', | ||
'n/prefer-global/buffer': ['error', 'never'], | ||
'n/prefer-global/console': ['error', 'always'], | ||
'n/prefer-global/process': ['error', 'never'], | ||
'n/prefer-global/text-decoder': ['error', 'always'], | ||
'n/prefer-global/text-encoder': ['error', 'always'], | ||
'n/prefer-global/url-search-params': ['error', 'always'], | ||
'n/prefer-global/url': ['error', 'always'], | ||
'n/prefer-promises/dns': 'error', | ||
'n/prefer-promises/fs': 'error', | ||
'n/process-exit-as-throw': 'error', | ||
}, | ||
} |
Oops, something went wrong.