Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Jun 29, 2023
2 parents 0f97070 + c135523 commit df3a40b
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 72 deletions.
33 changes: 26 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,40 @@ Simply add the following to your `package.json`:

### VS Code Integration

Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and create `.vscode/settings.json`, and add the following setting:
Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and create `.vscode/settings.json` to add the following

```json
Add the following settings to your `settings.json`:

```jsonc
{
"prettier.enable": false,
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
"source.fixAll.eslint": true,
"source.organizeImports": false,
},
// The following is optional.
// It's better to put under project setting `.vscode/settings.json`
// to avoid conflicts with working with different eslint configs
// that does not support all formats.
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml"
]
}
```

### TypeScript Aware Rules

Type aware rules are enabled when a `tsconfig.eslint.json` is found in the project root, which will introduce some stricter rules into your project. If you want to enable it while have no `tsconfig.eslint.json` in the project root, you can change tsconfig name by modifying `ESLINT_TSCONFIG` env.
Type aware rules are enabled when a `tsconfig.eslint.json` is found in the project root, which will introduce some stricter rules into your project. If you want to enable it while have no `tsconfig.eslint.json` in the project root, you can change tsconfig name by modifying `ESLINT_TSCONFIG` env.

```js
// .eslintrc.js
Expand Down Expand Up @@ -118,7 +137,7 @@ npm i -D lint-staged simple-git-hooks

This config does NOT lint CSS. I personally use [UnoCSS](https://github.com/unocss/unocss) so I don't write CSS. If you still prefer CSS, you can use [stylelint](https://stylelint.io/) for CSS linting.

### I prefer XXX...
### I prefer XXX

Sure, you can override the rules in your `.eslintrc` file.

Expand All @@ -138,10 +157,10 @@ Or you can always fork this repo and make your own.
## Check Also

- [stacksjs/stacks](https://github.com/stacksjs/stacks) - Stacks - The modern way to create & distribute component libraries
- [stacksjs/vue-starter](https://github.com/stacksjs/vue-starter) - Starter template for Vue libraries
- [stacksjs/web-components-starter](https://github.com/stacksjs/web-components-starter) - Starter template for Web Component libraries
- [stacksjs/composable-starter](https://github.com/stacksjs/composable-starter) - Starter template for Composable libraries
- [stacksjs/ts-starter](https://github.com/stacksjs/ts-starter) - Starter template for TypeScript libraries
- [stacksjs/vue-starter](https://github.com/stacksjs/vue-starter) - Starter template for Vue libraries

## 📈 Changelog

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
"rimraf": "^5.0.1",
"typescript": "^5.1.3"
}
}
}
2 changes: 2 additions & 0 deletions packages/eslint-plugin-ow3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import topLevelFunction from './rules/top-level-function'
import orderClasses from './rules/order-classes'
import noTsExportEqual from './rules/no-ts-export-equal'
import noCjsExports from './rules/no-cjs-exports'
import noConstEnum from './rules/no-const-enum'

export default {
rules: {
Expand All @@ -17,5 +18,6 @@ export default {
'order-classes': orderClasses,
'no-cjs-exports': noCjsExports,
'no-ts-export-equal': noTsExportEqual,
'no-const-enum': noConstEnum,
},
}
25 changes: 25 additions & 0 deletions packages/eslint-plugin-ow3/src/rules/no-const-enum.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { RuleTester } from '@typescript-eslint/utils/dist/ts-eslint'
import { it } from 'vitest'
import rule, { RULE_NAME } from './no-const-enum'

const valids = [
'enum E {}',
]

const invalids = [
'const enum E {}',
]

it('runs', () => {
const ruleTester: RuleTester = new RuleTester({
parser: require.resolve('@typescript-eslint/parser'),
})

ruleTester.run(RULE_NAME, rule, {
valid: valids,
invalid: invalids.map(i => ({
code: i,
errors: [{ messageId: 'noConstEnum' }],
})),
})
})
33 changes: 33 additions & 0 deletions packages/eslint-plugin-ow3/src/rules/no-const-enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { createEslintRule } from '../utils'

export const RULE_NAME = 'no-const-enum'
export type MessageIds = 'noConstEnum'
export type Options = []

export default createEslintRule<Options, MessageIds>({
name: RULE_NAME,
meta: {
type: 'problem',
docs: {
description: 'Disallow using `const enum` expression',
recommended: 'error',
},
schema: [],
messages: {
noConstEnum: 'Do not use `const enum` expression',
},
},
defaultOptions: [],
create: (context) => {
return {
TSEnumDeclaration: (node) => {
if (node.const) {
context.report({
node,
messageId: 'noConstEnum',
})
}
},
}
},
})
98 changes: 34 additions & 64 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit df3a40b

Please sign in to comment.