diff --git a/README.md b/README.md index 33f3f7d..b2bc85a 100644 --- a/README.md +++ b/README.md @@ -1,52 +1,70 @@ -# ESLint config files for Coremail (c) -[![npm][npm-image]][npm-url] +# eslint-config-email [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [npm-image]: https://img.shields.io/npm/v/eslint-config-coremail.svg [npm-url]: https://npmjs.org/package/eslint-config-coremail +[downloads-image]: https://img.shields.io/npm/dm/eslint-config-coremail.svg +[downloads-url]: https://npmjs.org/package/eslint-config-coremail -## Usage - -This package exports [a flat ESLint configuration](https://eslint.org/blog/2022/08/new-config-system-part-2/) -which is supported since `eslint 8.21.0` - -```bash -npm install --save-dev eslint eslint-config-coremail -``` - -Example `eslint.config.js` in esm: -```js -import {configs} from 'eslint-config-coremail'; - -export default [ - // default using browser & node env - configs.standard, - // for old IE compatible - { - files : ['path/to/legacy/**'], - ...configs.legacy, - }, -] -``` - -Example `eslint.config.js` in commonjs: -```js -module.export = import('eslint-config-coremail').then(({configs}) => [ - // default using browser & node env - configs.standard, - // for old IE compatible - { - files : ['path/to/legacy/**'], - ...configs.legacy, - }, -]); -``` +#### The eslint config for [Coremail (c)](https://www.coremail.cn) + +This module exports [a flat ESLint configuration](https://eslint.org/blog/2022/08/new-config-system-part-2/) which is +supported since `eslint 8.21.0`, basing [eslint-config-standard]. + +Notes that [eslint-config-standard] is likely [deprecated and stop maintaining](https://github.com/standard/eslint-config-standard/issues/351). +It's encouraged to switch to [neo-standard] for [standard] users. + +This project is only focus on eslint config, and not providing framework tooling like [neo-standard]. + +[eslint-config-standard]: https://github.com/standard/eslint-config-standard +[neo-standard]: https://github.com/neostandard/neostandard +[standard]: https://standardjs.com + +## Quick start + +1. `npm install --save-dev eslint eslint-config-coremail` + +2. For projects using esm, add `eslint.config.js` as: + ```js + import {configs} from 'eslint-config-coremail'; + + export default [ + // default enables browser & node env, you can change to `configs.node` for server side project + configs.standard, { + // your overrides here + }, { + // for legacy codes compliant with old IE + ...configs.legacy, + files : ['path/to/legacy/codes/**'], + }, + ] + ``` + +3. For projects using commonjs, add `eslint.config.js` as: + ```js + module.exports = import('eslint-config-coremail').then(({configs}) => [ + // default enables browser & node env, you can change to `configs.node` for server side project + configs.standard, { + // your overrides here + }, { + // for legacy codes compliant with old IE + ...configs.legacy, + files : ['path/to/legacy/codes/**'], + }, + ]); + ``` + +## Migrating from eslint-config-coremail 0.x / eslint-config-standard 17.x + +1. Read [this article](https://eslint.org/blog/2024/04/eslint-v9.0.0-released/) for ESLint 9 migration +2. Migrate [deprecated ESLint style rules](https://eslint.org/blog/2023/10/deprecating-formatting-rules/) + with [eslint-stylistic](https://eslint.style/) rules following [this guide](https://eslint.style/guide/migration) ## Learn more -For the full listing of rules that eslint supports, and more, visit -For more information on the full listing of rules, editor plugins, FAQs, and more, visit the -[ESLint official site](http://eslint.org/docs/rules/). +For more information on the full listing of rules that eslint supports, and more, visit +- [ESLint official site](http://eslint.org/docs/rules/) +- [ESLint Stylistic](https://eslint.style/packages/default#rules) ## License diff --git a/config/imported.js b/config/imported.js new file mode 100644 index 0000000..dc1db98 --- /dev/null +++ b/config/imported.js @@ -0,0 +1,242 @@ +/** + * Copyright (c) 2024 Coremail.cn, Ltd. All Rights Reserved. + */ + +export const plugins = { + n : (await import('eslint-plugin-n')).default, + import : (await import('eslint-plugin-import')).default, + promise : (await import('eslint-plugin-promise')).default, + '@stylistic' : (await import('@stylistic/eslint-plugin')).default, +}; + +// rules imported from +// - https://github.com/neostandard/neostandard/blob/v0.11.6/lib/configs/ +// - https://github.com/standard/eslint-config-standard/tree/v17.1.0 + +/* eslint-disable @stylistic/indent */// @formatter:off +// noinspection SpellCheckingInspection +export const baseRules = { + // imported from https://github.com/neostandard/neostandard/blob/v0.11.6/lib/configs/base.js + // and https://github.com/standard/eslint-config-standard/blob/v17.1.0/.eslintrc.json + 'no-var' : ['warn'], + 'object-shorthand' : ['warn', 'properties'], + + 'accessor-pairs' : ['error', {setWithoutGet: true, enforceForClassMembers: true}], + 'array-callback-return' : ['error', { + allowImplicit : false, + checkForEach : false, + }], + 'camelcase' : ['error', { + allow : ['^UNSAFE_'], + properties : 'never', + ignoreGlobals : true, + }], + 'constructor-super' : ['error'], + 'curly' : ['error', 'multi-line'], + 'default-case-last' : ['error'], + 'dot-notation' : ['error', {allowKeywords: true}], + 'eqeqeq' : ['error', 'always', {null: 'ignore'}], + 'new-cap' : ['error', {newIsCap: true, capIsNew: false, properties: true}], + 'no-array-constructor' : ['error'], + 'no-async-promise-executor' : ['error'], + 'no-caller' : ['error'], + 'no-case-declarations' : ['error'], + 'no-class-assign' : ['error'], + 'no-compare-neg-zero' : ['error'], + 'no-cond-assign' : ['error'], + 'no-const-assign' : ['error'], + 'no-constant-condition' : ['error', {checkLoops: false}], + 'no-control-regex' : ['error'], + 'no-debugger' : ['error'], + 'no-delete-var' : ['error'], + 'no-dupe-args' : ['error'], + 'no-dupe-class-members' : ['error'], + 'no-dupe-keys' : ['error'], + 'no-duplicate-case' : ['error'], + 'no-useless-backreference' : ['error'], + 'no-empty' : ['error', {allowEmptyCatch: true}], + 'no-empty-character-class' : ['error'], + 'no-empty-pattern' : ['error'], + 'no-eval' : ['error'], + 'no-ex-assign' : ['error'], + 'no-extend-native' : ['error'], + 'no-extra-bind' : ['error'], + 'no-extra-boolean-cast' : ['error'], + 'no-fallthrough' : ['error'], + 'no-func-assign' : ['error'], + 'no-global-assign' : ['error'], + 'no-implied-eval' : ['error'], + 'no-import-assign' : ['error'], + 'no-invalid-regexp' : ['error'], + 'no-irregular-whitespace' : ['error'], + 'no-iterator' : ['error'], + 'no-labels' : ['error', {allowLoop: false, allowSwitch: false}], + 'no-lone-blocks' : ['error'], + 'no-loss-of-precision' : ['error'], + 'no-misleading-character-class' : ['error'], + 'no-prototype-builtins' : ['error'], + 'no-useless-catch' : ['error'], + 'no-multi-str' : ['error'], + 'no-new' : ['error'], + 'no-new-func' : ['error'], + 'no-object-constructor' : ['error'], // 'no-new-object' is deprecated + 'no-new-native-nonconstructor' : ['error'], // 'no-new-symbol' is deprecated + 'no-new-wrappers' : ['error'], + 'no-obj-calls' : ['error'], + 'no-octal' : ['error'], + 'no-octal-escape' : ['error'], + 'no-proto' : ['error'], + 'no-redeclare' : ['error', {builtinGlobals : false}], + 'no-regex-spaces' : ['error'], + 'no-return-assign' : ['error', 'except-parens'], + 'no-self-assign' : ['error', {props : true}], + 'no-self-compare' : ['error'], + 'no-sequences' : ['error'], + 'no-shadow-restricted-names' : ['error'], + 'no-sparse-arrays' : ['error'], + 'no-template-curly-in-string' : ['error'], + 'no-this-before-super' : ['error'], + 'no-throw-literal' : ['error'], + 'no-undef' : ['error'], + 'no-undef-init' : ['error'], + 'no-unexpected-multiline' : ['error'], + 'no-unmodified-loop-condition' : ['error'], + 'no-unneeded-ternary' : ['error', {defaultAssignment: false}], + 'no-unreachable' : ['error'], + 'no-unreachable-loop' : ['error'], + 'no-unsafe-finally' : ['error'], + 'no-unsafe-negation' : ['error'], + 'no-unused-expressions' : ['error', { + allowShortCircuit : true, + allowTernary : true, + allowTaggedTemplates : true, + }], + 'no-unused-vars' : ['error', { + args : 'none', + caughtErrors : 'none', + ignoreRestSiblings : true, + vars : 'all', + }], + 'no-use-before-define' : ['error', {functions: false, classes: false, variables: false}], + 'no-useless-call' : ['error'], + 'no-useless-computed-key' : ['error'], + 'no-useless-constructor' : ['error'], + 'no-useless-escape' : ['error'], + 'no-useless-rename' : ['error'], + 'no-useless-return' : ['error'], + 'no-void' : ['error'], + 'no-with' : ['error'], + 'one-var' : ['error', {initialized: 'never'}], + 'prefer-const' : ['error', {destructuring: 'all'}], + 'prefer-promise-reject-errors' : ['error'], + 'prefer-regex-literals' : ['error', {disallowRedundantWrapping: true}], + 'symbol-description' : ['error'], + 'unicode-bom' : ['error', 'never'], + 'use-isnan' : ['error', { + enforceForSwitchCase : true, + enforceForIndexOf : true, + }], + 'valid-typeof' : ['error', {requireStringLiterals: true}], + 'yoda' : ['error', 'never'], + + 'import/export' : ['error'], + 'import/first' : ['error'], + 'import/no-absolute-path' : ['error', {esmodule: true, commonjs: true, amd: false}], + 'import/no-duplicates' : ['error'], + 'import/no-named-default' : ['error'], + 'import/no-webpack-loader-syntax' : ['error'], + + // TODO: Should only be active for server side scripts + 'n/handle-callback-err' : ['error', '^(err|error)$'], + 'n/no-callback-literal' : ['error'], + 'n/no-deprecated-api' : ['error'], + 'n/no-exports-assign' : ['error'], + 'n/no-new-require' : ['error'], + 'n/no-path-concat' : ['error'], + 'n/process-exit-as-throw' : ['error'], + + 'promise/param-names' : ['error'], +} + +export const styleRules = { + // imported from https://github.com/neostandard/neostandard/blob/v0.11.6/lib/configs/style.js + // same to https://github.com/standard/eslint-config-standard/blob/v17.1.0/.eslintrc.json + '@stylistic/array-bracket-spacing' : ['error', 'never'], + '@stylistic/arrow-spacing' : ['error', {before: true, after: true}], + '@stylistic/block-spacing' : ['error', 'always'], + '@stylistic/brace-style' : ['error', '1tbs', {allowSingleLine: true}], + '@stylistic/comma-dangle' : ['error', { + arrays : 'never', + objects : 'never', + imports : 'never', + exports : 'never', + functions : 'never', + }], + '@stylistic/comma-spacing' : ['error', {before: false, after: true}], + '@stylistic/comma-style' : ['error', 'last'], + '@stylistic/computed-property-spacing' : ['error', 'never', {enforceForClassMembers: true}], + '@stylistic/dot-location' : ['error', 'property'], + '@stylistic/eol-last' : ['error'], + '@stylistic/func-call-spacing' : ['error', 'never'], + '@stylistic/generator-star-spacing' : ['error', {before: true, after: true}], + '@stylistic/indent' : ['error', 2, { + SwitchCase : 1, + VariableDeclarator : 1, + outerIIFEBody : 1, + MemberExpression : 1, + FunctionDeclaration : {parameters: 1, body: 1}, + FunctionExpression : {parameters: 1, body: 1}, + CallExpression : {arguments: 1}, + ArrayExpression : 1, + ObjectExpression : 1, + ImportDeclaration : 1, + flatTernaryExpressions : false, + ignoreComments : false, + ignoredNodes : ['TemplateLiteral *', 'JSXElement', 'JSXElement > *', 'JSXAttribute', 'JSXIdentifier', 'JSXNamespacedName', 'JSXMemberExpression', 'JSXSpreadAttribute', 'JSXExpressionContainer', 'JSXOpeningElement', 'JSXClosingElement', 'JSXFragment', 'JSXOpeningFragment', 'JSXClosingFragment', 'JSXText', 'JSXEmptyExpression', 'JSXSpreadChild'], + offsetTernaryExpressions : true, + }], + '@stylistic/key-spacing' : ['error', {beforeColon: false, afterColon: true}], + '@stylistic/keyword-spacing' : ['error', {before: true, after: true}], + '@stylistic/lines-between-class-members' : ['error', 'always', {exceptAfterSingleLine: true}], + '@stylistic/multiline-ternary' : ['error', 'always-multiline'], + '@stylistic/new-parens' : ['error'], + '@stylistic/no-extra-parens' : ['error', 'functions'], + '@stylistic/no-floating-decimal' : ['error'], + '@stylistic/no-mixed-operators' : ['error', { + groups: [ + ['==', '!=', '===', '!==', '>', '>=', '<', '<='], + ['&&', '||'], + ['in', 'instanceof'], + ], + allowSamePrecedence: true, + }], + '@stylistic/no-mixed-spaces-and-tabs' : ['error'], + '@stylistic/no-multi-spaces' : ['error'], + '@stylistic/no-multiple-empty-lines' : ['error', {max: 1, maxBOF: 0, maxEOF: 0}], + '@stylistic/no-tabs' : ['error'], + '@stylistic/no-trailing-spaces' : ['error'], + '@stylistic/no-whitespace-before-property' : ['error'], + '@stylistic/object-curly-newline' : ['error', {multiline: true, consistent: true}], + '@stylistic/object-curly-spacing' : ['error', 'always'], + '@stylistic/object-property-newline' : ['error', {allowMultiplePropertiesPerLine: true}], + '@stylistic/operator-linebreak' : ['error', 'after', {overrides: {'?': 'before', ':': 'before', '|>': 'before'}}], + '@stylistic/padded-blocks' : ['error', {blocks: 'never', switches: 'never', classes: 'never'}], + '@stylistic/quote-props' : ['error', 'as-needed'], + '@stylistic/quotes' : ['error', 'single', {avoidEscape: true, allowTemplateLiterals: false}], + '@stylistic/rest-spread-spacing' : ['error', 'never'], + '@stylistic/semi' : ['error', 'never'], + '@stylistic/semi-spacing' : ['error', {before: false, after: true}], + '@stylistic/space-before-blocks' : ['error', 'always'], + '@stylistic/space-before-function-paren' : ['error', 'always'], + '@stylistic/space-in-parens' : ['error', 'never'], + '@stylistic/space-infix-ops' : ['error'], + '@stylistic/space-unary-ops' : ['error', {words: true, nonwords: false}], + '@stylistic/spaced-comment' : ['error', 'always', { + line : {markers: ['*package', '!', '/', ',', '=']}, + block : {balanced: true, markers: ['*package', '!', ',', ':', '::', 'flow-include'], exceptions: ['*']}, + }], + '@stylistic/template-curly-spacing' : ['error', 'never'], + '@stylistic/template-tag-spacing' : ['error', 'never'], + '@stylistic/wrap-iife' : ['error', 'any', {functionPrototypeMethods: true}], + '@stylistic/yield-star-spacing' : ['error', 'both'], +}; diff --git a/config/legacy.js b/config/legacy.js index d542585..05f2c4b 100644 --- a/config/legacy.js +++ b/config/legacy.js @@ -1,31 +1,23 @@ /** - * Copyright (c) 2023 Coremail.cn, Ltd. All Rights Reserved. + * Copyright (c) 2024 Coremail.cn, Ltd. All Rights Reserved. */ import {error} from './util.js'; export default { - languageOptions : { ecmaVersion : 3, sourceType : 'script', parserOptions : {allowReserved : true}, }, - rules : { - /* eslint-disable indent *//* @formatter:off */ + plugins : {'@stylistic' : (await import('@stylistic/eslint-plugin')).default}, - // here two rules are only for ES3 compliant / IE6 supports - 'quote-props' : [error, 'as-needed', { - keywords : true, - unnecessary : false, - }], - 'dot-notation' : [error, { - allowKeywords : false, - allowPattern : '.*', - }], - 'comma-dangle' : [error, 'never'], - // ES3 compliant END - 'no-tabs' : [error], + // rules only for ES3 compliant / IE6 ~ IE8 + rules : { + 'dot-notation' : [error, {allowKeywords : false, allowPattern : '.*'}], + '@stylistic/quote-props' : [error, 'as-needed', {keywords : true, unnecessary : false}], + '@stylistic/comma-dangle' : [error, 'never'], + '@stylistic/no-tabs' : [error], }, }; diff --git a/config/standard.js b/config/standard.js index d99faec..53276a6 100644 --- a/config/standard.js +++ b/config/standard.js @@ -1,85 +1,82 @@ /** - * Copyright (c) 2023 Coremail.cn, Ltd. All Rights Reserved. + * Copyright (c) 2024 Coremail.cn, Ltd. All Rights Reserved. */ -import standard from 'eslint-config-standard'; +import {baseRules, plugins, styleRules} from './imported.js'; import {error, first, mergeRules, never, off} from './util.js'; export default { - languageOptions : { ecmaVersion : 'latest', parserOptions : {ecmaFeatures : {jsx : true}}, }, - plugins : Object.fromEntries(await Promise.all(standard.plugins.map(async key => [ - key, (await import(`eslint-plugin-${key}`)).default, - ]))), + plugins, + rules : mergeRules(baseRules, styleRules, { /* eslint-disable @stylistic/indent */// @formatter:off + 'no-var' : [error], + '@stylistic/no-tabs' : [error], + '@stylistic/indent' : [error, 4, { + SwitchCase : 0, + VariableDeclarator : {var : 1, let : 1, const : 1}, + ImportDeclaration : first, + ArrayExpression : first, + ObjectExpression : first, + FunctionDeclaration : {parameters: first}, + FunctionExpression : {parameters: first}, + CallExpression : {arguments: 1}, + MemberExpression : off, + ignoreComments : true, + ignoredNodes : styleRules['@stylistic/indent'][2].ignoredNodes, + }], + '@stylistic/semi' : [off], + '@stylistic/quotes' : [error, 'single', 'avoid-escape'], + '@stylistic/arrow-parens' : [error, 'as-needed'], + '@stylistic/operator-linebreak' : [error, 'before'], // ternary operator should have nothing special + '@stylistic/multiline-ternary' : [off], + '@stylistic/comma-dangle' : [error, { // more friendly to VCS system / manual code arrangements + arrays : 'always-multiline', + objects : 'always-multiline', + imports : 'always-multiline', + exports : 'always-multiline', + functions : 'only-multiline', + }], + '@stylistic/padded-blocks' : [off], // extra space in blocks should not be a problem + 'prefer-const' : [off], + 'yoda' : [off], + 'no-new' : [off], + 'no-void' : [off], + 'no-case-declarations' : [off], + 'no-inner-declarations' : [off], + 'default-case' : [off], + 'one-var' : [off], + 'dot-notation' : [off], + '@stylistic/quote-props' : [off], + '@stylistic/object-curly-spacing' : [off], + '@stylistic/space-before-function-paren' : [error, {named: 'never', anonymous: 'ignore', asyncArrow: 'always'}], + '@stylistic/generator-star-spacing' : [error, 'after'], + '@stylistic/yield-star-spacing' : [error, 'after'], + '@stylistic/no-multiple-empty-lines' : [off], + '@stylistic/no-multi-spaces' : [error, { + exceptions: {VariableDeclarator: true, ImportDeclaration: true}, + ignoreEOLComments: true, + }], + '@stylistic/key-spacing' : [off], + 'camelcase' : [error, { + properties : never, + ignoreDestructuring : true, + ignoreGlobals : true, + }], + + 'array-callback-return' : [off], + 'no-empty' : [off], + 'no-restricted-globals' : [error, { + name : 'event', + message : 'Use local parameter instead.', + }], - /* eslint-disable indent */// @formatter:off - rules : mergeRules(standard.rules, { - 'no-var' : [error], - 'no-tabs' : [error], - 'indent' : [error, 4, { - SwitchCase : 0, - VariableDeclarator : { var : 1, let : 1, const : 1 }, - ImportDeclaration : first, - ArrayExpression : first, - ObjectExpression : first, - FunctionDeclaration : {parameters: first}, - FunctionExpression : {parameters: first}, - CallExpression : {arguments: 1}, - MemberExpression : off, - ignoreComments : true, - }], - 'semi' : [off, never], - 'quotes' : [error, 'single', 'avoid-escape'], - 'arrow-parens' : [error, 'as-needed'], - 'operator-linebreak' : [error, 'before'], // corrected now, ternary operator should have nothing special - 'comma-dangle' : [error, { // more friendly to VCS system / manual code arrangements - arrays : 'always-multiline', - objects : 'always-multiline', - imports : 'always-multiline', - exports : 'always-multiline', - functions : 'only-multiline', - }], - 'padded-blocks' : [off], // extra space in blocks should not be a problem - 'prefer-const' : [off], - 'yoda' : [off], - 'no-new' : [off], - 'no-void' : [off], - 'no-case-declarations' : [off], - 'no-inner-declarations' : [off], - 'default-case' : [off], - 'one-var' : [off], - 'dot-notation' : [off], - 'quote-props' : [off], - 'object-curly-spacing' : [off], - 'space-before-function-paren' : [error, {named: never, anonymous: 'ignore', asyncArrow: 'always'}], - 'space-before-blocks' : [error], - 'no-multiple-empty-lines' : [off], - 'no-multi-spaces' : [error, { - exceptions: {VariableDeclarator: true, ImportDeclaration: true}, - ignoreEOLComments: true, - }], - 'keyword-spacing' : [error], - 'key-spacing' : [off], - 'comma-spacing' : [error], - 'space-infix-ops' : [error], - 'spaced-comment' : [error], - 'eol-last' : [error], - 'camelcase' : [error, { - properties : never, - ignoreDestructuring : true, - ignoreGlobals : true, - }], - 'multiline-ternary' : [off], - 'array-callback-return' : [off], - 'no-empty' : [off], - 'n/no-path-concat' : [off], - 'n/no-exports-assign' : [off], + 'n/no-path-concat' : [off], + 'n/no-exports-assign' : [off], - // waiting https://github.com/import-js/eslint-plugin-import/issues/2556 - 'import/export' : [off], + 'import/no-webpack-loader-syntax' : [off], }), }; diff --git a/eslint.config.js b/eslint.config.js index b5bfd7f..b6abd9e 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,13 +1,16 @@ -// noinspection JSUnusedGlobalSymbols +/** + * Copyright (c) 2024 Coremail.cn, Ltd. All Rights Reserved. + */ import {configs} from './config/index.js'; -export default [configs.es, { +export default [configs.node, { files : ['test/samples/**'], rules : { // disable debatable rules - 'semi' : 'off', - 'quotes' : 'off', + '@stylistic/semi' : 'off', + '@stylistic/quotes' : 'off', + // sample test codes have many unused / undeclared symbols 'no-undef' : 'off', 'no-unused-vars' : 'off', diff --git a/package.json b/package.json index f70565d..51131d0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name" : "eslint-config-coremail", "description" : "Javascript Standard Style - ESLint Shareable Config for coremail.cn", - "version" : "0.99.1", + "version" : "1.0.1", "author" : { "name" : "William Leung", "email" : "williamleung2006@gmail.com" @@ -24,6 +24,10 @@ "license" : "MIT", "main" : "config/index.js", + "exports" : { + "." : "./config/index.js", + "./package.json" : "./package.json" + }, "files" : [ "config/*" ], @@ -33,15 +37,18 @@ }, "peerDependencies" : { - "eslint" : "^8.52.0", + "eslint" : "^9.12.0", "globals" : "*" }, "devDependencies" : { - "eslint" : "~8.52.0" + "eslint" : "~9.12.0" }, "dependencies" : { - "eslint-config-standard" : "~17.1.0" + "eslint-plugin-import" : "^2.31.0", + "eslint-plugin-n" : "^17.11.1", + "eslint-plugin-promise" : "^7.1.0", + "@stylistic/eslint-plugin" : "~2.9.0" } } diff --git a/test/samples/esm1.js b/test/samples/esm1.js new file mode 100644 index 0000000..1051664 --- /dev/null +++ b/test/samples/esm1.js @@ -0,0 +1,4 @@ +// + +export const one = 1; +export const two = 2; diff --git a/test/samples/esm2.js b/test/samples/esm2.js new file mode 100644 index 0000000..9755a87 --- /dev/null +++ b/test/samples/esm2.js @@ -0,0 +1,3 @@ +// + +export * from './esm1.js' diff --git a/test/samples/sample1-indent-const.js b/test/samples/sample1-indent-const.js index 25e1e07..5bf7c69 100644 --- a/test/samples/sample1-indent-const.js +++ b/test/samples/sample1-indent-const.js @@ -1,9 +1,8 @@ // -// The indent rule do not supports '1.5' as unit (6 space) or other multiline alignment technic -/* eslint indent: "off" */ +// The indent rule does not support '1.5' as unit (6 space) or other multiline alignment technic +/* eslint @stylistic/indent: "off" */ // noinspection JSUnusedGlobalSymbols const A = 'a', B = 'b', C = 'c'; - diff --git a/test/samples/sample2-general.js b/test/samples/sample2-general.js index 1920f41..f095de3 100644 --- a/test/samples/sample2-general.js +++ b/test/samples/sample2-general.js @@ -5,7 +5,7 @@ let object = {}; foo( 'demo', - /* eslint indent: "off" */ + /* eslint @stylistic/indent: "off" */ { title : 'Demo', width : 100, @@ -47,6 +47,3 @@ let offset = 10; // noinspection JSUnresolvedVariable varName = val; - - - diff --git a/test/samples/sample4-wrapping.js b/test/samples/sample4-wrapping.js index 966bd1e..c946578 100644 --- a/test/samples/sample4-wrapping.js +++ b/test/samples/sample4-wrapping.js @@ -145,4 +145,4 @@ function funDeclare($, } /* eslint curly: off */ -/* eslint brace-style: off */ +/* eslint @stylistic/brace-style: off */ diff --git a/test/samples/sample6-generator-function.js b/test/samples/sample6-generator-function.js new file mode 100644 index 0000000..f875173 --- /dev/null +++ b/test/samples/sample6-generator-function.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 Coremail.cn, Ltd. All Rights Reserved. + */ + +function* anotherGenerator(i) { + yield i + 1; + yield i + 2; + yield i + 3; +} + +const anonymous = function* (i) { + yield i; + yield* anotherGenerator(i); + yield i + 10; +} + +// noinspection JSUnusedGlobalSymbols +const object = { + anonymous, + normal : function* () {}, + * shorthand() {}, +};