Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLINTJS-65 Remove decorated rules from ESLint plugin #4925

Merged
merged 26 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f980c2d
ESLINTJS-65 Remove decorated rules from ESLint plugin
vdiez Nov 25, 2024
cf8f4a5
fix tests and eslint plugin
vdiez Nov 25, 2024
42a6e0c
fix tests and eslint plugin
vdiez Nov 25, 2024
f20a77a
fix tests and eslint plugin
vdiez Nov 25, 2024
67092c8
remove decorated rule from its test
vdiez Nov 25, 2024
23c92de
remove unneeded dependencies
vdiez Nov 26, 2024
4484d3d
Use prettier to format markdown on generation
vdiez Nov 26, 2024
aafefae
Update licenses
vdiez Nov 26, 2024
9ab921d
Merge branch 'master' into remove-decorated-eslint
vdiez Nov 26, 2024
7bcfd67
add S1291 to new metadata format
vdiez Nov 26, 2024
26480e6
add source of rule for external rules
vdiez Nov 26, 2024
a050d02
Added metadata for decorated rules
vdiez Nov 26, 2024
26a92c4
Added explanation in README.md about external rules
vdiez Nov 26, 2024
5f8067f
Added explanation in README.md about external rules
vdiez Nov 26, 2024
ddeb3bc
do not limit to eslint 9.14
vdiez Nov 26, 2024
9c55e6e
fix header
vdiez Nov 26, 2024
edb8cb2
Merge branch 'master' into remove-decorated-eslint
vdiez Nov 27, 2024
d167687
Merge branch 'master' into remove-decorated-eslint
vdiez Nov 27, 2024
8403629
Update tools/generate-rule-indexes.ts
vdiez Nov 28, 2024
0dbb35b
Update packages/jsts/src/rules/README.md
vdiez Nov 28, 2024
80ecc27
Update packages/jsts/src/rules/README.md
vdiez Nov 28, 2024
7859912
Update packages/jsts/src/rules/README.md
vdiez Nov 28, 2024
87fa9e6
improve wording on README.md
vdiez Nov 28, 2024
f785d58
changes on index.test.ts after review
vdiez Nov 28, 2024
850c9b1
Merge branch 'master' into remove-decorated-eslint
vdiez Nov 29, 2024
8ff562f
Merge branch 'master' into remove-decorated-eslint
vdiez Nov 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 7 additions & 1 deletion .eslint-doc-generatorrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
* along with this program; if not, see https://sonarsource.com/license/ssal/
*/
const rules = require('./lib').rules;
const prettier = require('prettier');
const { prettier: prettierOpts } = require('./package.json');

/** @type {import('eslint-doc-generator').GenerateOptions} */
const config = {
urlRuleDoc(name) {
return rules[name].meta.docs.url;
},
postprocess: content => content.replace('<table>', '&lt;table&gt;'),
ignoreConfig: ['recommended-legacy'],
pathRuleDoc(name) {
return `docs/${name}.md`;
Expand All @@ -36,6 +37,11 @@ const config = {
'requiresTypeChecking',
'deprecated',
],
postprocess: content =>
vdiez marked this conversation as resolved.
Show resolved Hide resolved
prettier.format(content.replace('<table>', '&lt;table&gt;'), {
...prettierOpts,
parser: 'markdown',
}),
};

module.exports = config;
10 changes: 1 addition & 9 deletions generate-eslint-package-json.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,14 @@ const eslintPluginDependencies = [
'@babel/preset-flow',
'@babel/preset-react',
'@eslint-community/regexpp',
'@typescript-eslint/eslint-plugin',
'@typescript-eslint/utils',
'builtin-modules',
'bytes',
'eslint-plugin-import',
'eslint-plugin-jsx-a11y',
'eslint-plugin-react',
'eslint-plugin-react-hooks',
'eslint-scope',
'functional-red-black-tree',
'jsx-ast-utils',
'minimatch',
'scslre',
'semver',
'typescript',
'vue-eslint-parser',
];

const mainPackageJson = JSON.parse(
Expand Down Expand Up @@ -90,7 +82,7 @@ await fs.writeFile(
'https://github.com/SonarSource/SonarJS/blob/master/packages/jsts/src/rules/README.md',
dependencies,
peerDependencies: {
eslint: '8.0.0 - 9.14',
eslint: '^8.0.0 || ^9.0.0',
},
},
null,
Expand Down
1 change: 0 additions & 1 deletion its/eslint8-plugin-sonarjs/eslint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ module.exports = [
plugin.configs.recommended,
{
rules: {
'sonarjs/accessor-pairs': 'error',
'sonarjs/no-implicit-dependencies': 'error',
},
},
Expand Down
1 change: 0 additions & 1 deletion its/eslint8-plugin-sonarjs/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default [
plugin.configs.recommended,
{
rules: {
'sonarjs/accessor-pairs': 'error',
'sonarjs/no-implicit-dependencies': 'error',
},
},
Expand Down
1 change: 0 additions & 1 deletion its/eslint8-plugin-sonarjs/tseslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import parser from '@typescript-eslint/parser';
console.log(`Loaded ${Object.keys(plugin.configs.recommended.rules ?? {}).length} rules`);

export default tseslint.config(plugin.configs.recommended, {
rules: { 'sonarjs/accessor-pairs': 'error' },
files: ['**/*.ts'],
languageOptions: {
parser,
Expand Down
1 change: 0 additions & 1 deletion its/eslint9-plugin-sonarjs/eslint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ module.exports = [
plugin.configs.recommended,
{
rules: {
'sonarjs/accessor-pairs': 'error',
'sonarjs/no-implicit-dependencies': 'error',
},
},
Expand Down
1 change: 0 additions & 1 deletion its/eslint9-plugin-sonarjs/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default [
plugin.configs.recommended,
{
rules: {
'sonarjs/accessor-pairs': 'error',
'sonarjs/no-implicit-dependencies': 'error',
},
},
Expand Down
1 change: 0 additions & 1 deletion its/eslint9-plugin-sonarjs/tseslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import parser from '@typescript-eslint/parser';
console.log(`Loaded ${Object.keys(plugin.configs.recommended.rules ?? {}).length} rules`);

export default tseslint.config(plugin.configs.recommended, {
rules: { 'sonarjs/accessor-pairs': 'error' },
files: ['**/*.ts'],
languageOptions: {
parser,
Expand Down
72 changes: 20 additions & 52 deletions package-lock.json

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

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"ruling-parametrized": "node tools/prepare-ruling.js && SONAR_RULING_SETTINGS=../settings.js tsx --tsconfig packages/tsconfig.test.json --test packages/ruling/tests/projects/*.ruling.test.ts",
"ruling-sync": "rsync -avh packages/ruling/tests/actual/jsts/ its/ruling/src/test/expected/jsts/ --delete",
"update-ruling-data": "mvn -f sonar-plugin/sonar-javascript-plugin/pom.xml compile && npx tsx packages/ruling/tests/tools/parseRulesData.ts",
"create-rule-indexes": "tsx tools/generate-rule-indexes.ts",
vdiez marked this conversation as resolved.
Show resolved Hide resolved
"bridge:compile": "tsc -b packages profiling && npm run _:bridge:copy-protofiles",
"bridge:test": "tsx --tsconfig packages/tsconfig.test.json --test --test-reporter spec --test-reporter-destination stdout \"packages/*/src/rules/*[!node_modules]/**/*.test.ts\" \"packages/*[!ruling]/tests/**/*.test.ts\"",
"bridge:test:cov": "odz run npm run bridge:test || true && odz report --reporters=text-lcov > lcov.info",
Expand All @@ -28,7 +29,7 @@
"plugin:build:fast": "mvn install -DskipTests && npm run update-ruling-data",
"pbf": "npm run plugin:build:fast",
"td": "npm --prefix typedoc/searchable-parameters-plugin run setup && npx typedoc --options typedoc/typedoc.js",
"prepare": "husky",
"prepare": "husky && npm run create-rule-indexes",
"precommit": "pretty-quick --staged",
"count-rules": "node tools/count-rules.js",
"_:bridge:copy-protofiles": "cpy --flat packages/jsts/src/parsers/estree.proto sonar-plugin/bridge/src/main/protobuf && cpy --flat packages/jsts/src/parsers/estree.proto lib/jsts/src/parsers",
Expand All @@ -44,7 +45,7 @@
"eslint-plugin:types": "tsc -p tsconfig-plugin.json --declaration true --emitDeclarationOnly --outDir lib/types",
"eslint-plugin:package-json": "node generate-eslint-package-json.mjs",
"eslint-plugin:copy-assets": "cpy LICENSE.txt lib/ --rename LICENSE && cpy packages/jsts/src/rules/README.md lib/ --flat",
"eslint-docs": "npm run eslint-plugin:compile && eslint-doc-generator lib --init-rule-docs"
"eslint-docs": "npm run eslint-plugin:compile && eslint-doc-generator lib --init-rule-docs && tsx tools/generate-external-rules-docs.ts"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -121,7 +122,7 @@
"htmlparser2": "9.1.0",
"jsx-ast-utils": "3.3.5",
"lodash.clone": "4.5.0",
"minimatch": "10.0.1",
"minimatch": "9.0.5",
zglicz marked this conversation as resolved.
Show resolved Hide resolved
"module-alias": "2.2.3",
"postcss": "8.4.49",
"postcss-html": "0.36.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/jsts/src/analysis/analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { debug, info } from '../../../shared/src/helpers/logging.js';
import { SourceCode } from 'eslint';
import { JsTsAnalysisInput, JsTsAnalysisOutput } from './analysis.js';
import { TSESTree } from '@typescript-eslint/utils';
import type { TSESTree } from '@typescript-eslint/utils';
import { JsTsLanguage } from '../../../shared/src/helpers/language.js';
import { getLinter } from '../linter/linters.js';
import { buildSourceCode } from '../builders/build.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/jsts/src/linter/visitors/cpd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program; if not, see https://sonarsource.com/license/ssal/
*/
import estree from 'estree';
import { TSESTree } from '@typescript-eslint/utils';
import type { TSESTree } from '@typescript-eslint/utils';
import { SourceCode, AST } from 'eslint';
import { visit } from './visitor.js';
import { Location } from './metrics/helpers/location.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/jsts/src/linter/visitors/symbol-highlighting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import { Rule, Scope } from 'eslint';
import estree from 'estree';
import { TSESTree } from '@typescript-eslint/utils';
import type { TSESTree } from '@typescript-eslint/utils';
import { AST } from 'vue-eslint-parser';
import { convertLocation, extractTokensAndComments, Location } from './metrics/helpers/index.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/jsts/src/parsers/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program; if not, see https://sonarsource.com/license/ssal/
*/
import protobuf from 'protobufjs';
import { TSESTree } from '@typescript-eslint/utils';
import type { TSESTree } from '@typescript-eslint/utils';
import { debug } from '../../../shared/src/helpers/logging.js';

import path from 'path';
Expand Down
2 changes: 2 additions & 0 deletions packages/jsts/src/rules/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rules.ts
plugin-rules.ts
Loading